| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Consensus.Mempool.Util
Synopsis
- type TestBlock = SimpleBftBlock SimpleMockCrypto BftMockCrypto
- type TestTx = GenTx TestBlock
- type TestTxError = ApplyTxErr TestBlock
- type TestTxId = TxId TestTx
- type TheMeasure = IgnoringOverflow ByteSize32
- applyTxToLedger ∷ LedgerConfig TestBlock → LedgerState TestBlock ValuesMK → TestTx → Except TestTxError (LedgerState TestBlock ValuesMK)
- bumpTip ∷ LedgerState TestBlock ValuesMK → LedgerState TestBlock ValuesMK
- genInvalidTx ∷ LedgerState TestBlock ValuesMK → Gen TestTx
- genLargeInvalidTx ∷ TheMeasure → Gen TestTx
- genTxs ∷ Int → LedgerState TestBlock ValuesMK → Gen ([(TestTx, Bool)], LedgerState TestBlock ValuesMK)
- genValidTx ∷ LedgerState TestBlock ValuesMK → Gen (TestTx, LedgerState TestBlock ValuesMK)
- genValidTxs ∷ Int → LedgerState TestBlock ValuesMK → Gen ([TestTx], LedgerState TestBlock ValuesMK)
- mkTestLedgerConfig ∷ MockConfig → LedgerConfig TestBlock
- mustBeValid ∷ HasCallStack ⇒ Except TestTxError (LedgerState TestBlock ValuesMK) → LedgerState TestBlock ValuesMK
- testInitLedger ∷ LedgerState TestBlock ValuesMK
- testLedgerConfigNoSizeLimits ∷ LedgerConfig TestBlock
- txIsValid ∷ LedgerConfig TestBlock → LedgerState TestBlock ValuesMK → TestTx → Bool
Documentation
type TestBlock = SimpleBftBlock SimpleMockCrypto BftMockCrypto Source #
type TestTxError = ApplyTxErr TestBlock Source #
type TheMeasure = IgnoringOverflow ByteSize32 Source #
applyTxToLedger ∷ LedgerConfig TestBlock → LedgerState TestBlock ValuesMK → TestTx → Except TestTxError (LedgerState TestBlock ValuesMK) Source #
Apply a transaction to the ledger
We don't have blocks in this test, but transactions only. In this function we pretend the transaction is a block, apply it to the UTxO, and then update the tip of the ledger state, incrementing the slot number and faking a hash.
bumpTip ∷ LedgerState TestBlock ValuesMK → LedgerState TestBlock ValuesMK Source #
Advance the ledger tip by one slot while keeping the UTxO unchanged.
Unlike applyTxToLedger, this consumes no inputs, so any transaction that was
valid against the input state is still valid against the result. This is
exactly the base change needed to make a mempool sync do real work without
invalidating any of the transactions it already holds.
genLargeInvalidTx ∷ TheMeasure → Gen TestTx Source #
Generate an invalid tx that is larger than the given measure.
Arguments
| ∷ Int | The number of transactions to generate |
| → LedgerState TestBlock ValuesMK | |
| → Gen ([(TestTx, Bool)], LedgerState TestBlock ValuesMK) |
Generate a number of valid and invalid transactions and apply the valid
transactions to the given LedgerState. The transactions along with a
Bool indicating whether its valid (True) or invalid (False) and the
resulting LedgerState are returned.
genValidTx ∷ LedgerState TestBlock ValuesMK → Gen (TestTx, LedgerState TestBlock ValuesMK) Source #
Generate a valid transaction (but ignoring any per-tx size limits, see Note [Transaction size limit]).
Arguments
| ∷ Int | The number of valid transactions to generate |
| → LedgerState TestBlock ValuesMK | |
| → Gen ([TestTx], LedgerState TestBlock ValuesMK) |
Generate a number of valid transactions and apply these to the given
LedgerState. The transactions and the resulting LedgerState are
returned.
mkTestLedgerConfig ∷ MockConfig → LedgerConfig TestBlock Source #
Test config
(We don't really care about these values here)