| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.NodeSpec
Synopsis
- spec :: Spec
- primeWith :: MonadSTM m => [Input tx] -> HydraNode tx m -> m (HydraNode tx m)
- primeWithTime :: MonadSTM m => HydraNode SimpleTx m -> m (HydraNode SimpleTx m)
- notConnect :: MonadThrow m => DraftHydraNode tx m -> m (HydraNode tx m)
- mockServer :: Monad m => Server tx m
- mockNetwork :: Monad m => Network m (Message tx)
- mockChain :: MonadThrow m => Chain tx m
- mockSink :: Monad m => EventSink a m
- mockEventStore :: forall a m. Monad m => [a] -> EventStore a m
- mockSource :: Monad m => [a] -> EventSource a m
- createRecordingSink :: IO (EventSink a IO, IO [a])
- createMockEventStore :: MonadLabelledSTM m => m (EventStore a m)
- createMockEventStoreWithReader :: MonadLabelledSTM m => m (EventStore a m, m [a])
- inputsToOpenHead :: [Input SimpleTx]
- observationInput :: OnChainTx SimpleTx -> Input SimpleTx
- runToCompletion :: IsChainState tx => HydraNode tx IO -> IO ()
- testHydraNode :: (MonadTime m, MonadDelay m, MonadAsync m, MonadLabelledSTM m, MonadThrow m, MonadUnliftIO m) => Tracer m (HydraNodeLog SimpleTx) -> Secret (SigningKey HydraKey) -> [Party] -> ContestationPeriod -> [Input SimpleTx] -> m (HydraNode SimpleTx m)
- testTTL :: TTL
- recordNetwork :: HydraNode tx IO -> IO (HydraNode tx IO, IO [Message tx])
- recordChain :: HydraNode tx IO -> IO (HydraNode tx IO, IO [PostChainTx tx])
- withRunningHydraNode :: IsChainState tx => HydraNode tx IO -> IO a -> IO a
- awaitRecorded :: (HasCallStack, Show a) => IO [a] -> (a -> Bool) -> IO a
- recordServerOutputs :: IsChainState tx => HydraNode tx IO -> IO (HydraNode tx IO, IO [Either (ServerOutput tx) (ClientMessage tx)])
- messageRecorder :: IO (msg -> IO (), IO [msg])
- throwExceptionOnPostTx :: IsChainState tx => PostTxError tx -> HydraNode tx IO -> IO (HydraNode tx IO)
- testDeposit :: Integer -> Deposit SimpleTx
Documentation
primeWith :: MonadSTM m => [Input tx] -> HydraNode tx m -> m (HydraNode tx m) Source #
Add given list of inputs to the InputQueue. A preceding Tick is enqueued
to advance the chain slot and ensure the NodeState is in sync. This is
returning the node to allow for chaining with runToCompletion.
primeWithTime :: MonadSTM m => HydraNode SimpleTx m -> m (HydraNode SimpleTx m) Source #
A preceding Tick is enqueued to advance the chain slot and ensure the NodeState is in sync. This is
returning the node to allow for chaining with runToCompletion.
notConnect :: MonadThrow m => DraftHydraNode tx m -> m (HydraNode tx m) Source #
Convert a DraftHydraNode to a HydraNode by providing mock implementations.
mockServer :: Monad m => Server tx m Source #
mockNetwork :: Monad m => Network m (Message tx) Source #
mockEventStore :: forall a m. Monad m => [a] -> EventStore a m Source #
mockSource :: Monad m => [a] -> EventSource a m Source #
createMockEventStore :: MonadLabelledSTM m => m (EventStore a m) Source #
createMockEventStoreWithReader :: MonadLabelledSTM m => m (EventStore a m, m [a]) Source #
Like createMockEventStore, but also returns a direct reader of the
stored events. The EventSource conduit needs MonadUnliftIO to run
(getEvents), which IOSim does not provide — the reader gives IOSim-based
tests (e.g. a node restart in Model) access to the events anyway.
inputsToOpenHead :: [Input SimpleTx] Source #
Synthetic inputs that simulate a head opening. The head will be empty
though and this test hardness can not reliably simulate deposits. Use
aValidTx to create utxos out of thin air instead.
Explanation why we can't just emualte OnDepositTx and OnIncrementTx here: While the deposit will be seen as finalized, there is no ConfirmedSnapshot here that could be adopted and thus the confirmed utxo (legder state).
observationInput :: OnChainTx SimpleTx -> Input SimpleTx Source #
runToCompletion :: IsChainState tx => HydraNode tx IO -> IO () Source #
testHydraNode :: (MonadTime m, MonadDelay m, MonadAsync m, MonadLabelledSTM m, MonadThrow m, MonadUnliftIO m) => Tracer m (HydraNodeLog SimpleTx) -> Secret (SigningKey HydraKey) -> [Party] -> ContestationPeriod -> [Input SimpleTx] -> m (HydraNode SimpleTx m) Source #
Creates a full HydraNode with given parameters and primed Inputs. Note
that this node is notConnected to any components.
A lot shorter than the real world ttl which requires to be long to overcome some longer chain observation delays, but would just make tests longer.
recordChain :: HydraNode tx IO -> IO (HydraNode tx IO, IO [PostChainTx tx]) Source #
Record every $sel:postTx:Chain call, in the shape of recordNetwork. mockChain
discards them, so tests asserting on OnChainEffects have nothing to look
at otherwise.
withRunningHydraNode :: IsChainState tx => HydraNode tx IO -> IO a -> IO a Source #
Drive the node like runHydraNode does, but on a background thread and
using the node's own notion of chain time the way runToCompletion does.
Nodes built here start at initialChainTime, so driving them with the wall
clock would leave them permanently out of sync.
awaitRecorded :: (HasCallStack, Show a) => IO [a] -> (a -> Bool) -> IO a Source #
Wait for a recorder (see messageRecorder) to hold a matching item,
failing with everything recorded so far so a wedged node names the effect it
never produced instead of just timing out.
recordServerOutputs :: IsChainState tx => HydraNode tx IO -> IO (HydraNode tx IO, IO [Either (ServerOutput tx) (ClientMessage tx)]) Source #
throwExceptionOnPostTx :: IsChainState tx => PostTxError tx -> HydraNode tx IO -> IO (HydraNode tx IO) Source #
testDeposit :: Integer -> Deposit SimpleTx Source #
A minimal deposit for exercising the DepositHistory functions; the
Integer distinguishes deposits by their deposited UTxO.