tests
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.HeadLogicSpec

Description

Unit tests of the the protocol logic in HeadLogic. These are very fine grained and specific to individual steps in the protocol. More high-level of the protocol logic, especially between multiple parties can be found in BehaviorSpec.

Synopsis

Documentation

spec :: Spec Source #

Properties

Utilities

chainEffect :: PostChainTx SimpleTx -> Effect SimpleTx Source #

Create a chain effect with fixed chain state and slot.

observeTxAtSlot :: Natural -> OnChainTx SimpleTx -> Input SimpleTx Source #

Create an observation chain input with chain state at given slot.

observeTx :: OnChainTx SimpleTx -> Input SimpleTx Source #

Create an observation chain input with fixed chain state and slot.

inIdleState :: HeadState SimpleTx Source #

inInitialState :: [Party] -> HeadState SimpleTx Source #

inOpenState :: [Party] -> HeadState SimpleTx Source #

inOpenState' :: [Party] -> CoordinatedHeadState SimpleTx -> HeadState SimpleTx Source #

inClosedState :: [Party] -> HeadState SimpleTx Source #

inClosedState' :: [Party] -> ConfirmedSnapshot SimpleTx -> HeadState SimpleTx Source #

getConfirmedSnapshot :: HeadState tx -> Maybe (Snapshot tx) Source #

data StepState tx Source #

Constructors

StepState 

Fields

runHeadLogic :: Monad m => Environment -> Ledger tx -> HeadState tx -> StateT (StepState tx) m a -> m a Source #

getState :: MonadState (StepState tx) m => m (HeadState tx) Source #

Retrieves the latest HeadState from within runHeadLogic.

step :: (MonadState (StepState tx) m, IsChainState tx) => Input tx -> m (Outcome tx) Source #

Calls update and aggregate to drive the runHeadLogic monad forward.

hasEffect :: (HasCallStack, IsChainState tx) => Outcome tx -> Effect tx -> IO () Source #

assertWait :: (HasCallStack, IsChainState tx) => Outcome tx -> WaitReason tx -> IO () Source #

hasEffectSatisfying :: (HasCallStack, IsChainState tx) => Outcome tx -> (Effect tx -> Bool) -> IO () Source #

hasNoEffectSatisfying :: (HasCallStack, IsChainState tx) => Outcome tx -> (Effect tx -> Bool) -> IO () Source #

testSnapshot :: SnapshotNumber -> UTxOType tx -> [TxIdType tx] -> Snapshot tx Source #