ouroboros-network-protocols:testlib
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.Protocol.Handshake.Test

Synopsis

Documentation

data VersionNumber Source #

Testing version number

Constructors

Version_0 
Version_1 
Version_2 

Instances

Instances details
Arbitrary VersionNumber Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Bounded VersionNumber Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Enum VersionNumber Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Show VersionNumber Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Eq VersionNumber Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Ord VersionNumber Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Arbitrary (AnyMessage (Handshake VersionNumber Term)) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Eq (AnyMessage (Handshake VersionNumber Term)) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

data VersionData Source #

Instances

Instances details
Arbitrary VersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

CoArbitrary VersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Methods

coarbitrary :: VersionData -> Gen b -> Gen b #

Generic VersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Associated Types

type Rep VersionData 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

type Rep VersionData = D1 ('MetaData "VersionData" "Ouroboros.Network.Protocol.Handshake.Test" "ouroboros-network-protocols-0.12.0.0-inplace-testlib" 'False) (C1 ('MetaCons "VersionData" 'PrefixI 'True) (S1 ('MetaSel ('Just "dataVersion0") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: (S1 ('MetaSel ('Just "dataVersion1") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "dataVersion2") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))))
Show VersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Eq VersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Acceptable VersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Queryable VersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

type Rep VersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

type Rep VersionData = D1 ('MetaData "VersionData" "Ouroboros.Network.Protocol.Handshake.Test" "ouroboros-network-protocols-0.12.0.0-inplace-testlib" 'False) (C1 ('MetaCons "VersionData" 'PrefixI 'True) (S1 ('MetaSel ('Just "dataVersion0") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: (S1 ('MetaSel ('Just "dataVersion1") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "dataVersion2") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))))

genValidVersion :: VersionNumber -> Gen (Version VersionData Bool) Source #

Generate a valid ProtocolVersion VersionNumber r

genInvalidVersion :: VersionNumber -> Gen (Version VersionData Bool) Source #

Generate an invalid ProtocolVersion VersionNumber r.

genVersions :: Gen (Versions VersionNumber VersionData Bool) Source #

Generate possibly invalid Versions.

validVersion :: VersionNumber -> Version VersionData Bool -> Bool Source #

Check if a ProtocolVersion VersionNumber r is valid.

prop_connect :: ArbitraryVersions -> Property Source #

Run a handshake protocol, without going via a channel.

prop_channel :: (MonadAsync m, MonadCatch m, MonadST m) => m (Channel m ByteString, Channel m ByteString) -> Versions VersionNumber VersionData Bool -> Versions VersionNumber VersionData Bool -> m Property Source #

Run a simple block-fetch client and server using connected channels.

prop_pipe_IO :: ArbitraryVersions -> Property Source #

Run prop_channel in the IO monad using local pipes.

prop_channel_asymmetric Source #

Run a simple handshake client and server using connected channels. The server can only decode a subset of versions send by client. This test is using a fixed server Versions which can only accept a single version Version_1 (it cannot decode any other version).

prop_pipe_asymmetric_IO :: ArbitraryVersions -> Property Source #

Run prop_channel in the IO monad using local pipes.

newtype ArbitraryNodeToNodeVersionData Source #

Instances

Instances details
Arbitrary ArbitraryNodeToNodeVersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Show ArbitraryNodeToNodeVersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Eq ArbitraryNodeToNodeVersionData Source #

With the introduction of PeerSharing to NodeToNodeVersionData this type's Acceptable instance is no longer symmetric. Because when handshake is performed we keep only the remote's side PeerSharing information. Due to this, the ArbitraryNodeToNodeVersionData needs to have a custom Eq type that ignores this parameter. We also ignore the query field which may differ between parties.

Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Acceptable ArbitraryNodeToNodeVersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

Queryable ArbitraryNodeToNodeVersionData Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Test

prop_acceptable_symmetric :: (Acceptable vData, Eq vData) => vData -> vData -> Bool Source #

prop_query_version :: (MonadAsync m, MonadCatch m, MonadST m, Eq vData, Acceptable vData, Queryable vData, Show vData, Ord vNumber, Show vNumber) => m (Channel m ByteString, Channel m ByteString) -> Codec (Handshake vNumber Term) DeserialiseFailure m ByteString -> VersionDataCodec Term vNumber vData -> Versions vNumber vData Bool -> Versions vNumber vData Bool -> (vData -> vData) -> m Property Source #

Run a query for the server's supported version.

prop_acceptOrRefuse_symmetric :: forall vNumber vData r. (Acceptable vData, Eq vData, Show vData, Ord vNumber, Show vNumber, Eq r, Show r) => Versions vNumber vData r -> Versions vNumber vData r -> Property Source #

acceptOrRefuse is symmetric in the following sense:

Either both sides: * accept the same version and version data; or * refuse

The refuse reason might differ, although if one side refuses it with Refused the other side must refuse the same version.

prop_channel_simultaneous_open :: (MonadAsync m, MonadCatch m, MonadST m, Acceptable vData, Ord vNumber) => m (Channel m ByteString, Channel m ByteString) -> Codec (Handshake vNumber Term) DeserialiseFailure m ByteString -> VersionDataCodec Term vNumber vData -> Versions vNumber vData Bool -> Versions vNumber vData Bool -> m Property Source #

Run two handshake clients against each other, which simulates a TCP simultaneous open.

prop_codec_valid_cbor :: AnyMessage (Handshake VersionNumber Term) -> Property Source #

Check that the encoder produces a valid CBOR.