ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

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

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

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.

newEnvChain ∷ [Blk] → IOSim s (EnvChain (IOSim s)) Source #

A chain of these blocks, oldest first.

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.