Safe Haskell | None |
---|---|
Language | Haskell2010 |
Test.Util.TestBlock
Description
Minimal instantiation of the consensus layer to be able to run the ChainDB
Synopsis
- data family BlockConfig blk
- data family BlockQuery blk ∷ Type → Type
- data family CodecConfig blk
- data family Header blk
- data family StorageConfig blk
- data TestBlockError ptype
- = InvalidHash (ChainHash (TestBlockWith ptype)) (ChainHash (TestBlockWith ptype))
- | InvalidBlock
- | InvalidPayload (PayloadDependentError ptype)
- data TestBlockWith ptype
- data TestHash where
- data Validity
- firstBlockWithPayload ∷ Word64 → ptype → TestBlockWith ptype
- forkBlock ∷ TestBlock → TestBlock
- modifyFork ∷ (Word64 → Word64) → TestBlock → TestBlock
- successorBlockWithPayload ∷ TestHash → SlotNo → ptype → TestBlockWith ptype
- testHashFromList ∷ [Word64] → TestHash
- unTestHash ∷ TestHash → NonEmpty Word64
- type TestBlock = TestBlockWith ()
- firstBlock ∷ Word64 → TestBlock
- successorBlock ∷ TestBlock → TestBlock
- class (Typeable ptype, Eq ptype, NoThunks ptype, Eq (PayloadDependentState ptype), Show (PayloadDependentState ptype), Generic (PayloadDependentState ptype), ToExpr (PayloadDependentState ptype), Serialise (PayloadDependentState ptype), NoThunks (PayloadDependentState ptype), Eq (PayloadDependentError ptype), Show (PayloadDependentError ptype), Generic (PayloadDependentError ptype), ToExpr (PayloadDependentError ptype), Serialise (PayloadDependentError ptype), NoThunks (PayloadDependentError ptype), NoThunks (CodecConfig (TestBlockWith ptype)), NoThunks (StorageConfig (TestBlockWith ptype))) ⇒ PayloadSemantics ptype where
- type PayloadDependentState ptype ∷ Type
- type PayloadDependentError ptype ∷ Type
- applyPayload ∷ PayloadDependentState ptype → ptype → Either (PayloadDependentError ptype) (PayloadDependentState ptype)
- applyDirectlyToPayloadDependentState ∷ PayloadSemantics ptype ⇒ Ticked (LedgerState (TestBlockWith ptype)) → ptype → Either (PayloadDependentError ptype) (Ticked (LedgerState (TestBlockWith ptype)))
- data family LedgerState blk
- data family Ticked st
- lastAppliedPoint ∷ LedgerState (TestBlockWith ptype) → Point (TestBlockWith ptype)
- payloadDependentState ∷ LedgerState (TestBlockWith ptype) → PayloadDependentState ptype
- newtype BlockChain = BlockChain Word64
- blockChain ∷ BlockChain → Chain TestBlock
- chainToBlocks ∷ BlockChain → [TestBlock]
- newtype BlockTree = BlockTree (Tree ())
- blockTree ∷ BlockTree → Tree TestBlock
- treePreferredChain ∷ BlockTree → Chain TestBlock
- treeToBlocks ∷ BlockTree → [TestBlock]
- treeToChains ∷ BlockTree → [Chain TestBlock]
- singleNodeTestConfig ∷ TopLevelConfig TestBlock
- singleNodeTestConfigWith ∷ CodecConfig (TestBlockWith ptype) → StorageConfig (TestBlockWith ptype) → SecurityParam → TopLevelConfig (TestBlockWith ptype)
- singleNodeTestConfigWithK ∷ SecurityParam → TopLevelConfig TestBlock
- testInitExtLedger ∷ ExtLedgerState TestBlock
- testInitExtLedgerWithState ∷ PayloadDependentState ptype → ExtLedgerState (TestBlockWith ptype)
- testInitLedger ∷ LedgerState TestBlock
- testInitLedgerWithState ∷ PayloadDependentState ptype → LedgerState (TestBlockWith ptype)
- newtype Permutation = Permutation Int
- permute ∷ Permutation → [a] → [a]
Blocks
data family BlockConfig blk Source #
Static configuration required to work with this type of blocks
Instances
data family BlockQuery blk ∷ Type → Type Source #
Different queries supported by the ledger, indexed by the result type.
Instances
data family CodecConfig blk Source #
Static configuration required for serialisation and deserialisation of types pertaining to this type of block.
Data family instead of type family to get better type inference.
Instances
data family Header blk Source #
Instances
data family StorageConfig blk Source #
Config needed for the
NodeInitStorage
class. Defined here to
avoid circular dependencies.
Instances
data TestBlockError ptype Source #
Constructors
InvalidHash | The hashes don't line up |
Fields
| |
InvalidBlock | The block itself is invalid |
InvalidPayload (PayloadDependentError ptype) |
Instances
data TestBlockWith ptype Source #
Test block parametrized on the payload type
For blocks without payload see the TestBlock
type alias.
By defining a PayloadSemantics
it is possible to obtain an ApplyBlock
instance. See the former class for more details.
Instances
Instances
Eq TestHash Source # | |
Ord TestHash Source # | |
Show TestHash Source # | |
Generic TestHash Source # | |
Serialise TestHash Source # | |
Defined in Test.Util.TestBlock | |
Condense TestHash Source # | |
NoThunks TestHash Source # | |
ToExpr TestHash Source # | |
Defined in Test.Util.TestBlock | |
type Rep TestHash Source # | |
Defined in Test.Util.TestBlock |
Instances
Bounded Validity Source # | |
Enum Validity Source # | |
Defined in Test.Util.TestBlock Methods succ ∷ Validity → Validity Source # pred ∷ Validity → Validity Source # toEnum ∷ Int → Validity Source # fromEnum ∷ Validity → Int Source # enumFrom ∷ Validity → [Validity] Source # enumFromThen ∷ Validity → Validity → [Validity] Source # enumFromTo ∷ Validity → Validity → [Validity] Source # enumFromThenTo ∷ Validity → Validity → Validity → [Validity] Source # | |
Eq Validity Source # | |
Ord Validity Source # | |
Show Validity Source # | |
Generic Validity Source # | |
Serialise Validity Source # | |
Defined in Test.Util.TestBlock | |
NoThunks Validity Source # | |
ToExpr Validity Source # | |
Defined in Test.Util.TestBlock | |
type Rep Validity Source # | |
firstBlockWithPayload ∷ Word64 → ptype → TestBlockWith ptype Source #
Create the first block in the given fork, [fork]
, with the given payload.
The SlotNo
will be 1.
successorBlockWithPayload ∷ TestHash → SlotNo → ptype → TestBlockWith ptype Source #
Create the successor of the given block without forking: b -> b ++ [0]
(in
the printed representation) The SlotNo
is increased by 1.
In Zipper parlance, this corresponds to going down in a tree.
testHashFromList ∷ [Word64] → TestHash Source #
Test block without payload
type TestBlock = TestBlockWith () Source #
Block without payload
Payload semantics
class (Typeable ptype, Eq ptype, NoThunks ptype, Eq (PayloadDependentState ptype), Show (PayloadDependentState ptype), Generic (PayloadDependentState ptype), ToExpr (PayloadDependentState ptype), Serialise (PayloadDependentState ptype), NoThunks (PayloadDependentState ptype), Eq (PayloadDependentError ptype), Show (PayloadDependentError ptype), Generic (PayloadDependentError ptype), ToExpr (PayloadDependentError ptype), Serialise (PayloadDependentError ptype), NoThunks (PayloadDependentError ptype), NoThunks (CodecConfig (TestBlockWith ptype)), NoThunks (StorageConfig (TestBlockWith ptype))) ⇒ PayloadSemantics ptype where Source #
Associated Types
type PayloadDependentState ptype ∷ Type Source #
type PayloadDependentError ptype ∷ Type Source #
Methods
applyPayload ∷ PayloadDependentState ptype → ptype → Either (PayloadDependentError ptype) (PayloadDependentState ptype) Source #
Instances
PayloadSemantics () Source # | |
Defined in Test.Util.TestBlock Methods applyPayload ∷ PayloadDependentState () → () → Either (PayloadDependentError ()) (PayloadDependentState ()) Source # |
applyDirectlyToPayloadDependentState ∷ PayloadSemantics ptype ⇒ Ticked (LedgerState (TestBlockWith ptype)) → ptype → Either (PayloadDependentError ptype) (Ticked (LedgerState (TestBlockWith ptype))) Source #
Apply the payload directly to the payload dependent state portion of a ticked state, leaving the rest of the input ticked state unaltered.
LedgerState
data family LedgerState blk Source #
Ledger state associated with a block
Instances
data family Ticked st Source #
" Ticked " piece of state (LedgerState
, LedgerView
, ChainIndepState
)
Ticking refers to the passage of time (the ticking of the clock). When a piece of state is marked as ticked, it means that time-related changes have been applied to the state (or forecast).
Some examples of time related changes:
- Scheduled delegations might have been applied in Byron
- New leader schedule computed for Shelley
- Transition from Byron to Shelley activated in the hard fork combinator.
- Nonces switched out at the start of a new epoch.
Instances
lastAppliedPoint ∷ LedgerState (TestBlockWith ptype) → Point (TestBlockWith ptype) Source #
payloadDependentState ∷ LedgerState (TestBlockWith ptype) → PayloadDependentState ptype Source #
Chain
newtype BlockChain Source #
Constructors
BlockChain Word64 |
Instances
Show BlockChain Source # | |
Defined in Test.Util.TestBlock | |
Arbitrary BlockChain Source # | |
Defined in Test.Util.TestBlock |
chainToBlocks ∷ BlockChain → [TestBlock] Source #
Tree
treeToBlocks ∷ BlockTree → [TestBlock] Source #
Ledger infrastructure
singleNodeTestConfig ∷ TopLevelConfig TestBlock Source #
Trivial test configuration with a single core node
singleNodeTestConfigWith ∷ CodecConfig (TestBlockWith ptype) → StorageConfig (TestBlockWith ptype) → SecurityParam → TopLevelConfig (TestBlockWith ptype) Source #
testInitExtLedgerWithState ∷ PayloadDependentState ptype → ExtLedgerState (TestBlockWith ptype) Source #
testInitLedgerWithState ∷ PayloadDependentState ptype → LedgerState (TestBlockWith ptype) Source #
Support for tests
newtype Permutation Source #
Constructors
Permutation Int |
Instances
Show Permutation Source # | |
Defined in Test.Util.TestBlock | |
Arbitrary Permutation Source # | |
Defined in Test.Util.TestBlock |
permute ∷ Permutation → [a] → [a] Source #