| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.Chain.Direct.HandlersSpec
Synopsis
- genTimeHandleWithSlotInsideHorizon :: Gen (TimeHandle, SlotNo)
- genTimeHandleWithSlotPastHorizon :: Gen (TimeHandle, SlotNo)
- spec :: Spec
- sizeLimit :: Tx -> Gen Int
- genFailingReport :: Gen EvaluationReport
- recordEventsHandler :: ChainContext -> ChainStateAt -> (SlotNo -> GetTimeHandle IO) -> IO (ChainSyncHandler IO, IO [ChainEvent Tx])
- withinSizeLimits :: Tx -> Bool
- chunkSizeOf :: Tx -> Int
- countingWallet :: IORef Int -> TinyWallet IO
- searchForChunk :: (ChainContext, ClosedState, UTxO, SlotNo, UTxO) -> IO (Int, Tx)
- fitsUnderRealLimits :: ChainContext -> UTxO -> Tx -> IO Bool
- maxChunkSearchBuilds :: Int
- describeCandidate :: ChainContext -> UTxO -> TxIn -> Int -> UTxO -> SlotNo -> String
- permissiveWallet :: TinyWallet IO
- data TestBlock = TestBlock BlockHeader [Tx]
- genBlockAt :: SlotNo -> [Tx] -> Gen TestBlock
- genRollbackPoint :: [TestBlock] -> Gen ChainPoint
- genRollbackBlocks :: [TestBlock] -> Gen (ChainPoint, [TestBlock])
- genSequenceOfObservableBlocks :: Gen (ChainContext, ChainStateAt, [TestBlock])
Documentation
genTimeHandleWithSlotInsideHorizon :: Gen (TimeHandle, SlotNo) Source #
genTimeHandleWithSlotPastHorizon :: Gen (TimeHandle, SlotNo) Source #
sizeLimit :: Tx -> Gen Int Source #
Generate a byte-count limit that straddles the real serialised size of
tx, giving roughly equal probability of the size check passing or failing.
genFailingReport :: Gen EvaluationReport Source #
Generate an EvaluationReport that contains at least one script failure
at an arbitrary witness index, optionally mixed with passing entries.
recordEventsHandler :: ChainContext -> ChainStateAt -> (SlotNo -> GetTimeHandle IO) -> IO (ChainSyncHandler IO, IO [ChainEvent Tx]) Source #
Create a chain sync handler which records events as they are called back.
withinSizeLimits :: Tx -> Bool Source #
Whether a transaction is within the protocol's maximum transaction size,
measured the same way the real wallet measures it: Wallet
accepts a transaction of exactly the maximum size, so this is <=, not <.
chunkSizeOf :: Tx -> Int Source #
Number of outputs a fanout transaction distributes. Output 0 is the continuing head output; the rest are the chunk.
countingWallet :: IORef Int -> TinyWallet IO Source #
A wallet that answers findFittingFanoutTx truthfully - real script
evaluation, real size limit - while counting the candidate transactions it is
asked about.
The count is exact: the chunk search reaches the outside world only through
these two fields, and fitsTx calls $sel:isTxWithinSizeLimits:TinyWallet once per
constructed candidate before anything else, so one increment is one candidate
built. Building a candidate rebuilds the head's accumulators, which is what
makes the count worth bounding.
searchForChunk :: (ChainContext, ClosedState, UTxO, SlotNo, UTxO) -> IO (Int, Tx) Source #
Run the chunk search against a closed head, returning how many candidate transactions were built and the one the search settled on.
fitsUnderRealLimits :: ChainContext -> UTxO -> Tx -> IO Bool Source #
Whether a transaction passes the size limit and script execution budget the chunk search is held to.
maxChunkSearchBuilds :: Int Source #
Most candidates a capped binary search can build: the range is
[1..deployedFanoutBatchSize] and each probe halves it, so this counts the
halvings. Notably it does not depend on the head size.
describeCandidate :: ChainContext -> UTxO -> TxIn -> Int -> UTxO -> SlotNo -> String Source #
Why a chunk of the given size is or is not a usable fanout candidate, naming the limit it runs into. Only ever rendered into a counterexample.
permissiveWallet :: TinyWallet IO Source #
A wallet that accepts every transaction, for tests that only care about which error the chunk search reports.
A block used for testing. This is a simpler version of the cardano-api
Block and can be de-/constructed easily.
Constructors
| TestBlock BlockHeader [Tx] |
genBlockAt :: SlotNo -> [Tx] -> Gen TestBlock Source #
Thin wrapper which generates a TestBlock at some specific slot.
genRollbackPoint :: [TestBlock] -> Gen ChainPoint Source #
Pick a block point in a list of blocks.
genRollbackBlocks :: [TestBlock] -> Gen (ChainPoint, [TestBlock]) Source #
Pick a rollback point from a list of blocks and also yield the tail of blocks to be replayed.
genSequenceOfObservableBlocks :: Gen (ChainContext, ChainStateAt, [TestBlock]) Source #
Generate a non-sparse sequence of blocks each containing an observable transaction, starting from the returned on-chain head state.
Note that this does not generate the entire spectrum of observable transactions in Hydra, but only init and deposits, which is already sufficient to observe at least one state transition and different levels of rollback.