| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.Model.MockChain
Synopsis
- mockChainAndNetwork :: forall m. (MonadTimer m, MonadAsync m, MonadMask m, MonadThrow (STM m), MonadLabelledSTM m, MonadFork m, MonadDelay m, MonadTime m) => Tracer m CardanoChainLog -> [(Secret (SigningKey HydraKey), CardanoSigningKey)] -> m (SimulatedChainNetwork Tx m)
- timeHandleAt :: SlotNo -> TimeHandle
- scriptLedger :: Ledger Tx
- findOwnCardanoKey :: Party -> [(Secret (SigningKey HydraKey), CardanoSigningKey)] -> (VerificationKey PaymentKey, [VerificationKey PaymentKey])
- createMockNetwork :: (MonadSTM m, MonadTime m) => DraftHydraNode Tx m -> TVar m [(Party, Message Tx)] -> TVar m [MockHydraNode m] -> Network m (Message Tx)
- maxNetworkLatency :: DiffTime
- data MockHydraNode m = MockHydraNode {
- node :: HydraNode Tx m
- chainHandler :: ChainSyncHandler m
- mailbox :: TQueue m (UTCTime, Party, Message Tx)
- createMockChain :: (MonadTimer m, MonadThrow (STM m)) => Tracer m CardanoChainLog -> ChainContext -> DepositPeriod -> SubmitTx m -> m TimeHandle -> TxIn -> LocalChainState m Tx -> Chain Tx m
- flushQueue :: MonadSTM m => TQueue m a -> STM m [a]
Documentation
mockChainAndNetwork :: forall m. (MonadTimer m, MonadAsync m, MonadMask m, MonadThrow (STM m), MonadLabelledSTM m, MonadFork m, MonadDelay m, MonadTime m) => Tracer m CardanoChainLog -> [(Secret (SigningKey HydraKey), CardanoSigningKey)] -> m (SimulatedChainNetwork Tx m) Source #
Create a mocked chain which connects nodes through ChainSyncHandler and
Chain interfaces. It calls connected chain sync handlers $sel:onRollForward:ChainSyncHandler on
every blockTime and performs $sel:rollbackAndForward:SimulatedChainNetwork every couple blocks.
timeHandleAt :: SlotNo -> TimeHandle Source #
A TimeHandle at the given slot, for a chain that starts at time 0 and
has the era horizon far in the future. This is used in our Model tests and
we want to make sure the tests finish before the horizon is reached to
prevent the PastHorizon exceptions.
scriptLedger :: Ledger Tx Source #
A trimmed down ledger whose only purpose is to validate on-chain scripts.
findOwnCardanoKey :: Party -> [(Secret (SigningKey HydraKey), CardanoSigningKey)] -> (VerificationKey PaymentKey, [VerificationKey PaymentKey]) Source #
Find Cardano vkey corresponding to our Hydra vkey using signing keys lookup.
This is a bit cumbersome and a tribute to the fact the HydraNode itself has no
direct knowledge of the cardano keys which are stored only at the ChainComponent level.
createMockNetwork :: (MonadSTM m, MonadTime m) => DraftHydraNode Tx m -> TVar m [(Party, Message Tx)] -> TVar m [MockHydraNode m] -> Network m (Message Tx) Source #
maxNetworkLatency :: DiffTime Source #
Upper bound of the random delivery delay per network message and node,
see createMockNetwork. One block time: enough for messages to routinely
cross block boundaries relative to other nodes' chain observations, while
staying far below the ~600s a parked network input survives (TTL x
waitDelay) so delays alone never exhaust a message's retry budget.
data MockHydraNode m Source #
Constructors
| MockHydraNode | |
Fields
| |
createMockChain :: (MonadTimer m, MonadThrow (STM m)) => Tracer m CardanoChainLog -> ChainContext -> DepositPeriod -> SubmitTx m -> m TimeHandle -> TxIn -> LocalChainState m Tx -> Chain Tx m Source #
flushQueue :: MonadSTM m => TQueue m a -> STM m [a] Source #
Drain the queue, preserving submission order (a mempool applies dependent transactions oldest first; reversing them would drop e.g. a re-queued increment flushed together with its deposit after a chain fork).