tests
Safe HaskellSafe-Inferred
LanguageHaskell2010

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 #

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

chainEffect :: PostChainTx SimpleTx -> Effect SimpleTx Source #

Create a chain effect with fixed chain state and slot.

observeEventAtSlot :: Natural -> OnChainTx SimpleTx -> Event SimpleTx Source #

observationEvent :: OnChainTx SimpleTx -> Event SimpleTx Source #

Create an observation event with fixed chain state and slot.

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

inOpenState :: [Party] -> Ledger SimpleTx -> 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

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

Retrieves the latest HeadState from within runEvents.

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

Calls update and aggregate to drive the runEvents monad forward.

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

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

hasWait :: (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 #

testHeadId :: HeadId Source #