Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains experiments which can be executed either in IO
or
in IOSim
.
Synopsis
- data ClientAndServerData req = ClientAndServerData {
- accumulatorInit :: req
- hotInitiatorRequests :: [[req]]
- warmInitiatorRequests :: [[req]]
- establishedInitiatorRequests :: [[req]]
- unidirectionalExperiment :: forall peerAddr socket acc req resp m. (ConnectionManagerMonad m, MonadAsync m, MonadDelay m, MonadFix m, MonadLabelledSTM m, MonadTraceSTM m, MonadSay m, acc ~ [req], resp ~ [req], Ord peerAddr, Show peerAddr, Typeable peerAddr, Eq peerAddr, Serialise req, Show req, Serialise resp, Show resp, Eq resp, Typeable req, Typeable resp) => StdGen -> Timeouts -> Snocket m socket peerAddr -> MakeBearer m socket -> (socket -> m ()) -> socket -> ClientAndServerData req -> m Property
- bidirectionalExperiment :: forall peerAddr socket acc req resp m. (ConnectionManagerMonad m, MonadAsync m, MonadDelay m, MonadFix m, MonadLabelledSTM m, MonadTraceSTM m, MonadSay m, acc ~ [req], resp ~ [req], Ord peerAddr, Show peerAddr, Typeable peerAddr, Eq peerAddr, Serialise req, Show req, Serialise resp, Show resp, Eq resp, Typeable req, Typeable resp, Show acc) => Bool -> StdGen -> Timeouts -> Snocket m socket peerAddr -> MakeBearer m socket -> (socket -> m ()) -> socket -> socket -> peerAddr -> peerAddr -> ClientAndServerData req -> ClientAndServerData req -> m Property
- type ConnectionManagerMonad (m :: Type -> Type) = (Alternative (STM m), MonadAsync m, MonadCatch m, MonadEvaluate m, MonadFork m, MonadMask m, MonadST m, MonadTime m, MonadTimer m, MonadThrow m, MonadThrow (STM m))
- withInitiatorOnlyConnectionManager :: forall name peerAddr socket req resp m a. (ConnectionManagerMonad m, resp ~ [req], Ord peerAddr, Show peerAddr, Typeable peerAddr, Serialise req, Typeable req, MonadAsync m, MonadDelay m, MonadFix m, MonadLabelledSTM m, MonadTraceSTM m, MonadSay m, Show req, Show name) => name -> Timeouts -> Tracer m (WithName name (AbstractTransitionTrace peerAddr)) -> Tracer m (WithName name (Trace peerAddr (ConnectionHandlerTrace UnversionedProtocol DataFlowProtocolData))) -> StdGen -> Snocket m socket peerAddr -> MakeBearer m socket -> Maybe peerAddr -> TemperatureBundle (ConnectionId peerAddr -> STM m [req]) -> ProtocolTimeLimits (Handshake UnversionedProtocol Term) -> AcceptedConnectionsLimit -> (ConnectionManagerWithExpandedCtx 'InitiatorMode socket peerAddr DataFlowProtocolData UnversionedProtocol ByteString m [resp] Void -> m a) -> m a
- withBidirectionalConnectionManager :: forall name peerAddr socket acc req resp m a. (ConnectionManagerMonad m, acc ~ [req], resp ~ [req], Ord peerAddr, Show peerAddr, Typeable peerAddr, Serialise req, Typeable req, MonadAsync m, MonadDelay m, MonadFix m, MonadLabelledSTM m, MonadTraceSTM m, MonadSay m, Show req, Show name) => name -> Timeouts -> Tracer m (WithName name (RemoteTransitionTrace peerAddr)) -> Tracer m (WithName name (AbstractTransitionTrace peerAddr)) -> Tracer m (WithName name (Trace peerAddr (ConnectionHandlerTrace UnversionedProtocol DataFlowProtocolData))) -> Tracer m (WithName name (Trace peerAddr)) -> Tracer m (WithName name (Debug peerAddr DataFlowProtocolData)) -> StdGen -> Snocket m socket peerAddr -> MakeBearer m socket -> (socket -> m ()) -> socket -> Maybe peerAddr -> acc -> TemperatureBundle (ConnectionId peerAddr -> STM m [req]) -> ProtocolTimeLimits (Handshake UnversionedProtocol Term) -> AcceptedConnectionsLimit -> (ConnectionManagerWithExpandedCtx 'InitiatorResponderMode socket peerAddr DataFlowProtocolData UnversionedProtocol ByteString m [resp] acc -> peerAddr -> Async m Void -> m a) -> m a
- runInitiatorProtocols :: forall (muxMode :: Mode) addr m a b. (Alternative (STM m), MonadAsync m, MonadCatch m, MonadLabelledSTM m, MonadMask m, MonadSTM m, MonadThrow (STM m), HasInitiator muxMode ~ 'True, MonadSay m) => SingMuxMode muxMode -> Mux muxMode m -> OuroborosBundle muxMode (ExpandedInitiatorContext addr m) (ResponderContext addr) ByteString m a b -> TemperatureBundle (StrictTVar m ControlMessage) -> ConnectionId addr -> m (TemperatureBundle a)
- oneshotNextRequests :: forall req peerAddr m. MonadSTM m => ClientAndServerData req -> m (TemperatureBundle (ConnectionId peerAddr -> STM m [req]))
Documentation
data ClientAndServerData req Source #
The protocol will run three instances of ReqResp
protocol; one for each
state: warm, hot and established.
ClientAndServerData | |
|
Instances
Arbitrary req => Arbitrary (ClientAndServerData req) Source # | |
Defined in Ouroboros.Network.ConnectionManager.Test.Experiments arbitrary :: Gen (ClientAndServerData req) # shrink :: ClientAndServerData req -> [ClientAndServerData req] # | |
Show req => Show (ClientAndServerData req) Source # | |
Defined in Ouroboros.Network.ConnectionManager.Test.Experiments showsPrec :: Int -> ClientAndServerData req -> ShowS # show :: ClientAndServerData req -> String # showList :: [ClientAndServerData req] -> ShowS # |
unidirectionalExperiment :: forall peerAddr socket acc req resp m. (ConnectionManagerMonad m, MonadAsync m, MonadDelay m, MonadFix m, MonadLabelledSTM m, MonadTraceSTM m, MonadSay m, acc ~ [req], resp ~ [req], Ord peerAddr, Show peerAddr, Typeable peerAddr, Eq peerAddr, Serialise req, Show req, Serialise resp, Show resp, Eq resp, Typeable req, Typeable resp) => StdGen -> Timeouts -> Snocket m socket peerAddr -> MakeBearer m socket -> (socket -> m ()) -> socket -> ClientAndServerData req -> m Property Source #
This test runs an initiator only connection manager (client side) and bidirectional connection manager (which runs a server). The client connect to the server and runs protocols to completion.
There is a good reason why we don't run two bidirectional connection managers; If we would do that, when the either side terminates the connection the client side server would through an exception as it is listening.
bidirectionalExperiment Source #
:: forall peerAddr socket acc req resp m. (ConnectionManagerMonad m, MonadAsync m, MonadDelay m, MonadFix m, MonadLabelledSTM m, MonadTraceSTM m, MonadSay m, acc ~ [req], resp ~ [req], Ord peerAddr, Show peerAddr, Typeable peerAddr, Eq peerAddr, Serialise req, Show req, Serialise resp, Show resp, Eq resp, Typeable req, Typeable resp, Show acc) | |
=> Bool | |
-> StdGen | |
-> Timeouts | |
-> Snocket m socket peerAddr | |
-> MakeBearer m socket | |
-> (socket -> m ()) | configure socket |
-> socket | |
-> socket | |
-> peerAddr | |
-> peerAddr | |
-> ClientAndServerData req | |
-> ClientAndServerData req | |
-> m Property |
Bidirectional send and receive.
type ConnectionManagerMonad (m :: Type -> Type) = (Alternative (STM m), MonadAsync m, MonadCatch m, MonadEvaluate m, MonadFork m, MonadMask m, MonadST m, MonadTime m, MonadTimer m, MonadThrow m, MonadThrow (STM m)) Source #
withInitiatorOnlyConnectionManager Source #
:: forall name peerAddr socket req resp m a. (ConnectionManagerMonad m, resp ~ [req], Ord peerAddr, Show peerAddr, Typeable peerAddr, Serialise req, Typeable req, MonadAsync m, MonadDelay m, MonadFix m, MonadLabelledSTM m, MonadTraceSTM m, MonadSay m, Show req, Show name) | |
=> name | identifier (for logging) |
-> Timeouts | |
-> Tracer m (WithName name (AbstractTransitionTrace peerAddr)) | |
-> Tracer m (WithName name (Trace peerAddr (ConnectionHandlerTrace UnversionedProtocol DataFlowProtocolData))) | |
-> StdGen | |
-> Snocket m socket peerAddr | |
-> MakeBearer m socket | series of request possible to do with the bidirectional connection manager towards some peer. |
-> Maybe peerAddr | |
-> TemperatureBundle (ConnectionId peerAddr -> STM m [req]) | Functions to get the next requests for a given connection |
-> ProtocolTimeLimits (Handshake UnversionedProtocol Term) | Handshake time limits |
-> AcceptedConnectionsLimit | |
-> (ConnectionManagerWithExpandedCtx 'InitiatorMode socket peerAddr DataFlowProtocolData UnversionedProtocol ByteString m [resp] Void -> m a) | |
-> m a |
withBidirectionalConnectionManager Source #
:: forall name peerAddr socket acc req resp m a. (ConnectionManagerMonad m, acc ~ [req], resp ~ [req], Ord peerAddr, Show peerAddr, Typeable peerAddr, Serialise req, Typeable req, MonadAsync m, MonadDelay m, MonadFix m, MonadLabelledSTM m, MonadTraceSTM m, MonadSay m, Show req, Show name) | |
=> name | |
-> Timeouts | identifier (for logging) |
-> Tracer m (WithName name (RemoteTransitionTrace peerAddr)) | |
-> Tracer m (WithName name (AbstractTransitionTrace peerAddr)) | |
-> Tracer m (WithName name (Trace peerAddr (ConnectionHandlerTrace UnversionedProtocol DataFlowProtocolData))) | |
-> Tracer m (WithName name (Trace peerAddr)) | |
-> Tracer m (WithName name (Debug peerAddr DataFlowProtocolData)) | |
-> StdGen | |
-> Snocket m socket peerAddr | |
-> MakeBearer m socket | |
-> (socket -> m ()) | configure socket |
-> socket | listening socket |
-> Maybe peerAddr | |
-> acc | Initial state for the server |
-> TemperatureBundle (ConnectionId peerAddr -> STM m [req]) | Functions to get the next requests for a given connection ^ series of request possible to do with the bidirectional connection manager towards some peer. |
-> ProtocolTimeLimits (Handshake UnversionedProtocol Term) | Handshake time limits |
-> AcceptedConnectionsLimit | |
-> (ConnectionManagerWithExpandedCtx 'InitiatorResponderMode socket peerAddr DataFlowProtocolData UnversionedProtocol ByteString m [resp] acc -> peerAddr -> Async m Void -> m a) | |
-> m a |
Runs an example server which runs a single ReqResp
protocol for any hot
/ warm / established peers and also gives access to bidirectional
ConnectionManager
. This gives a way to connect to other peers.
Slightly unfortunate design decision does not give us a way to create
a client per connection. This means that this connection manager takes list
of req
type which it will make to the other side (they will be multiplexed
across warm / how / established) protocols.
runInitiatorProtocols :: forall (muxMode :: Mode) addr m a b. (Alternative (STM m), MonadAsync m, MonadCatch m, MonadLabelledSTM m, MonadMask m, MonadSTM m, MonadThrow (STM m), HasInitiator muxMode ~ 'True, MonadSay m) => SingMuxMode muxMode -> Mux muxMode m -> OuroborosBundle muxMode (ExpandedInitiatorContext addr m) (ResponderContext addr) ByteString m a b -> TemperatureBundle (StrictTVar m ControlMessage) -> ConnectionId addr -> m (TemperatureBundle a) Source #
Run all initiator mini-protocols and collect results. Throw exception if any of the thread returned an exception.
This function assumes that there's one established, one warm and one hot mini-protocol, which is compatible with both
oneshotNextRequests :: forall req peerAddr m. MonadSTM m => ClientAndServerData req -> m (TemperatureBundle (ConnectionId peerAddr -> STM m [req])) Source #
Next requests bundle for bidirectional and unidirectional experiments.