| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Consensus.Leios.Environment
Description
The node's peers, as run by the Leios node-vs-environment tests.
A peer connects to the node as the node's diffusion layer would have it: over an in-memory bearer, the two run the handshake and then a mux each. The node's end runs its whole negotiated bundle, starting every initiator as for a hot peer and every responder as the bundle says. The peer's end answers each of the node's initiators:
- KeepAlive and PeerSharing with the servers a node runs;
- BlockFetch and TxSubmission by never saying anything, which is all the node sees of a peer with nothing to offer;
- ChainSync, LeiosNotify and LeiosFetch with whatever the test gives it.
Synopsis
- data ChainSyncStep
- = SendRollForward (Header Blk)
- | SendRollBackward (Point Blk) (Tip Blk)
- data EnvChain (m ∷ Type → Type)
- data EnvPeer (m ∷ Type → Type) = EnvPeer {
- epChainSyncServer ∷ ChainSyncServer (Header Blk) (Point Blk) (Tip Blk) m ()
- epLeiosNotifyServer ∷ Channel m ByteString → m ()
- epLeiosNotifyClient ∷ Maybe (Channel m ByteString → m ())
- epLeiosFetchServer ∷ Channel m ByteString → m ()
- epLeiosFetchClient ∷ Maybe (Channel m ByteString → m ())
- type LeiosFetchCodec s = Codec (LeiosFetch LeiosPoint (Serialised EndorserBlock) LeiosTx) DeserialiseFailure (IOSim s) ByteString
- type LeiosNotifyCodec s = Codec (LeiosNotify LeiosPoint (Header Blk) LeiosVote) DeserialiseFailure (IOSim s) ByteString
- data NodeVsEnvConnection (m ∷ Type → Type) = NodeVsEnvConnection {
- connTerminate ∷ m ()
- connNodeInitiators ∷ Map MiniProtocolNum (STM m (Either SomeException NodeToNodeInitiatorResult))
- connNodeResponders ∷ Map MiniProtocolNum (STM m (Either SomeException ()))
- connPeerLeiosNotifyClient ∷ Maybe (STM m (Either SomeException ()))
- connPeerLeiosFetchClient ∷ Maybe (STM m (Either SomeException ()))
- chainSyncServerOf ∷ EnvChain (IOSim s) → ChainSyncServer (Header Blk) (Point Blk) (Tip Blk) (IOSim s) ()
- envLeiosFetchCodec ∷ NodeUnderTest (IOSim s) → LeiosFetchCodec s
- envLeiosNotifyCodec ∷ NodeUnderTest (IOSim s) → LeiosNotifyCodec s
- newEnvChain ∷ [Blk] → IOSim s (EnvChain (IOSim s))
- quietChainSyncServer ∷ ChainSyncServer (Header Blk) (Point Blk) (Tip Blk) (IOSim s) ()
- refusingLeiosFetchServer ∷ NodeUnderTest (IOSim s) → Channel (IOSim s) ByteString → IOSim s ()
- scriptedChainSyncServer ∷ [ChainSyncStep] → ChainSyncServer (Header Blk) (Point Blk) (Tip Blk) (IOSim s) ()
- serveChain ∷ EnvChain (IOSim s) → [Blk] → IOSim s ()
- silentLeiosFetchServer ∷ NodeUnderTest (IOSim s) → Channel (IOSim s) ByteString → IOSim s ()
- withNodeVsEnvConnection ∷ NodeUnderTest (IOSim s) → PeerAddr → EnvPeer (IOSim s) → (NodeVsEnvConnection (IOSim s) → IOSim s a) → IOSim s a
Documentation
data ChainSyncStep Source #
What scriptedChainSyncServer answers a request for the next update with.
Constructors
| SendRollForward (Header Blk) | The header, which it reports as its tip. |
| SendRollBackward (Point Blk) (Tip Blk) |
data EnvChain (m ∷ Type → Type) Source #
A chain a peer serves over ChainSync, which the test can change while the peer serves it.
data EnvPeer (m ∷ Type → Type) Source #
What a peer runs for the Leios mini-protocols.
Constructors
| EnvPeer | |
Fields
| |
type LeiosFetchCodec s = Codec (LeiosFetch LeiosPoint (Serialised EndorserBlock) LeiosTx) DeserialiseFailure (IOSim s) ByteString Source #
type LeiosNotifyCodec s = Codec (LeiosNotify LeiosPoint (Header Blk) LeiosVote) DeserialiseFailure (IOSim s) ByteString Source #
data NodeVsEnvConnection (m ∷ Type → Type) Source #
A connection from the node to a peer, once the handshake has settled on a version.
Constructors
| NodeVsEnvConnection | |
Fields
| |
chainSyncServerOf ∷ EnvChain (IOSim s) → ChainSyncServer (Header Blk) (Point Blk) (Tip Blk) (IOSim s) () Source #
A ChainSync server of the chain, which says nothing once the node holds all of it, until the chain changes.
A real peer would say that it has no more headers for now, and ChainSync jumping stops relying on a peer that says so. But the node gives the peer only 10 seconds to say something, so a test must change the chain within that time to keep the connection.
envLeiosFetchCodec ∷ NodeUnderTest (IOSim s) → LeiosFetchCodec s Source #
envLeiosNotifyCodec ∷ NodeUnderTest (IOSim s) → LeiosNotifyCodec s Source #
quietChainSyncServer ∷ ChainSyncServer (Header Blk) (Point Blk) (Tip Blk) (IOSim s) () Source #
A ChainSync server whose chain is empty and never grows.
The node gives a peer that is not trustable a random 135 to 269 seconds to send its next header, and then disconnects, so a test that keeps a connection open longer than 135 seconds loses it. That is probably not what such a test intends, so it should serve a chain that grows instead.
refusingLeiosFetchServer ∷ NodeUnderTest (IOSim s) → Channel (IOSim s) ByteString → IOSim s () Source #
A LeiosFetch server that disconnects a client that sends any request.
scriptedChainSyncServer ∷ [ChainSyncStep] → ChainSyncServer (Header Blk) (Point Blk) (Tip Blk) (IOSim s) () Source #
A ChainSync server that finds the intersection at genesis, answers each request for the next update with the next step, and then never answers again.
serveChain ∷ EnvChain (IOSim s) → [Blk] → IOSim s () Source #
Serve these blocks instead, oldest first. If they do not extend the old chain, the peer rolls the node back, as a real peer would.
silentLeiosFetchServer ∷ NodeUnderTest (IOSim s) → Channel (IOSim s) ByteString → IOSim s () Source #
A LeiosFetch server that never replies, as a peer that offers what it then does not serve.
withNodeVsEnvConnection ∷ NodeUnderTest (IOSim s) → PeerAddr → EnvPeer (IOSim s) → (NodeVsEnvConnection (IOSim s) → IOSim s a) → IOSim s a Source #
Connect the node to the peer at the given address, run the body, then shut both ends down.