| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Network.Mock.ChainGenerators
Description
Arbitrary generators for chains, headers and blocks
Synopsis
- data TestAddBlock = TestAddBlock (Chain Block) Block
- data TestBlockChainAndUpdates = TestBlockChainAndUpdates (Chain Block) [ChainUpdate Block Block]
- newtype TestBlockChain = TestBlockChain {}
- newtype TestHeaderChain = TestHeaderChain (Chain BlockHeader)
- data TestChainAndPoint = TestChainAndPoint (Chain Block) (Point Block)
- data TestChainAndRange = TestChainAndRange (Chain Block) (Point Block) (Point Block)
- data TestChainAndPoints = TestChainAndPoints (Chain Block) [Point Block]
- data TestChainFork = TestChainFork (Chain Block) (Chain Block) (Chain Block)
- data TestChainRange = TestChainRange (Point Block) (Point Block)
- genNonNegative :: Gen Int
- genSlotGap :: Gen Int
- addSlotGap :: Int -> WithOrigin SlotNo -> SlotNo
- genChainAnchor :: Gen (Anchor Block)
- mkPartialBlock :: SlotNo -> BlockBody -> Block
- mkRollbackPoint :: HasHeader block => Chain block -> Int -> Point block
- tests :: TestTree
Arbitrary chains generators
data TestAddBlock Source #
A test generator for a chain and a block that can be appended to it.
Constructors
| TestAddBlock (Chain Block) Block |
Instances
| Arbitrary TestAddBlock Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators | |
| Show TestAddBlock Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods showsPrec :: Int -> TestAddBlock -> ShowS # show :: TestAddBlock -> String # showList :: [TestAddBlock] -> ShowS # | |
data TestBlockChainAndUpdates Source #
A test generator for a chain and a sequence of updates that can be applied to it.
Constructors
| TestBlockChainAndUpdates (Chain Block) [ChainUpdate Block Block] |
Instances
| Arbitrary TestBlockChainAndUpdates Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods arbitrary :: Gen TestBlockChainAndUpdates # shrink :: TestBlockChainAndUpdates -> [TestBlockChainAndUpdates] # | |
| Show TestBlockChainAndUpdates Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods showsPrec :: Int -> TestBlockChainAndUpdates -> ShowS # show :: TestBlockChainAndUpdates -> String # showList :: [TestBlockChainAndUpdates] -> ShowS # | |
newtype TestBlockChain Source #
A test generator for a valid chain of blocks.
Constructors
| TestBlockChain | |
Fields | |
Instances
| Arbitrary TestBlockChain Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators | |
| Show TestBlockChain Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods showsPrec :: Int -> TestBlockChain -> ShowS # show :: TestBlockChain -> String # showList :: [TestBlockChain] -> ShowS # | |
| Eq TestBlockChain Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods (==) :: TestBlockChain -> TestBlockChain -> Bool # (/=) :: TestBlockChain -> TestBlockChain -> Bool # | |
newtype TestHeaderChain Source #
A test generator for a valid chain of block headers.
Constructors
| TestHeaderChain (Chain BlockHeader) |
Instances
| Arbitrary TestHeaderChain Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators | |
| Show TestHeaderChain Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods showsPrec :: Int -> TestHeaderChain -> ShowS # show :: TestHeaderChain -> String # showList :: [TestHeaderChain] -> ShowS # | |
| Eq TestHeaderChain Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods (==) :: TestHeaderChain -> TestHeaderChain -> Bool # (/=) :: TestHeaderChain -> TestHeaderChain -> Bool # | |
data TestChainAndPoint Source #
A test generator for a chain and a points. In most cases the point is on the chain, but it also covers at least 5% of cases where the point is not on the chain.
Constructors
| TestChainAndPoint (Chain Block) (Point Block) |
Instances
| Arbitrary TestChainAndPoint Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators | |
| Show TestChainAndPoint Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods showsPrec :: Int -> TestChainAndPoint -> ShowS # show :: TestChainAndPoint -> String # showList :: [TestChainAndPoint] -> ShowS # | |
data TestChainAndRange Source #
A test generator for a chain and a range defined by a pair of points. In most cases the range is on the chain, but it also covers at least 5% of cases where the point is not on the chain.
Instances
| Arbitrary TestChainAndRange Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators | |
| Show TestChainAndRange Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods showsPrec :: Int -> TestChainAndRange -> ShowS # show :: TestChainAndRange -> String # showList :: [TestChainAndRange] -> ShowS # | |
data TestChainAndPoints Source #
A test generator for a chain and a list of points, some of which may not be on the chain. Only 50% of the blocks are selected, one fifth of selected ones are not on the chain. Points which come from the chain are given in the newest to oldest order, but the intermediate points which are not in the chain might break the order.
Constructors
| TestChainAndPoints (Chain Block) [Point Block] |
Instances
| Arbitrary TestChainAndPoints Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators | |
| Show TestChainAndPoints Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods showsPrec :: Int -> TestChainAndPoints -> ShowS # show :: TestChainAndPoints -> String # showList :: [TestChainAndPoints] -> ShowS # | |
data TestChainFork Source #
A test generator for two chains sharing a common prefix.
Instances
| Arbitrary TestChainFork Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators | |
| Show TestChainFork Source # | |
Defined in Ouroboros.Network.Mock.ChainGenerators Methods showsPrec :: Int -> TestChainFork -> ShowS # show :: TestChainFork -> String # showList :: [TestChainFork] -> ShowS # | |
data TestChainRange Source #
Constructors
| TestChainRange (Point Block) (Point Block) |
Instances
Utility functions
genNonNegative :: Gen Int Source #
The NonNegative generator produces a large proportion of 0s, so we use
this one instead for now.
genSlotGap :: Gen Int Source #
addSlotGap :: Int -> WithOrigin SlotNo -> SlotNo Source #
genChainAnchor :: Gen (Anchor Block) Source #
A starting anchor for a chain fragment: either the AnchorGenesis or
an arbitrary anchor
Tests of the generators
Orphan instances
| Arbitrary BlockNo Source # | |
| Arbitrary Block Source # | |
| Arbitrary BlockBody Source # | |
| Arbitrary BlockHeader Source # | |
| Arbitrary ConcreteHeaderHash Source # | |
| CoArbitrary BlockNo Source # | |
Methods coarbitrary :: BlockNo -> Gen b -> Gen b # | |
| CoArbitrary SlotNo Source # | |
Methods coarbitrary :: SlotNo -> Gen b -> Gen b # | |
| CoArbitrary Block Source # | |
Methods coarbitrary :: Block -> Gen b -> Gen b # | |
| CoArbitrary BlockBody Source # | |
Methods coarbitrary :: BlockBody -> Gen b -> Gen b # | |
| CoArbitrary BlockHeader Source # | |
Methods coarbitrary :: BlockHeader -> Gen b -> Gen b # | |
| CoArbitrary BodyHash Source # | |
Methods coarbitrary :: BodyHash -> Gen b -> Gen b # | |
| CoArbitrary ConcreteHeaderHash Source # | |
Methods coarbitrary :: ConcreteHeaderHash -> Gen b -> Gen b # | |
| Arbitrary (Point Block) Source # | |
| Arbitrary (Point BlockHeader) Source # | |
| CoArbitrary (ChainHash BlockHeader) Source # | |
Methods coarbitrary :: ChainHash BlockHeader -> Gen b -> Gen b # | |