Safe Haskell | None |
---|---|
Language | Haskell2010 |
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)
- 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.
Instances
Arbitrary TestAddBlock Source # | |
Defined in Test.ChainGenerators arbitrary :: Gen TestAddBlock # shrink :: TestAddBlock -> [TestAddBlock] # | |
Show TestAddBlock Source # | |
Defined in Test.ChainGenerators 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.
Instances
Arbitrary TestBlockChainAndUpdates Source # | |
Defined in Test.ChainGenerators | |
Show TestBlockChainAndUpdates Source # | |
Defined in Test.ChainGenerators showsPrec :: Int -> TestBlockChainAndUpdates -> ShowS # show :: TestBlockChainAndUpdates -> String # showList :: [TestBlockChainAndUpdates] -> ShowS # |
newtype TestBlockChain Source #
A test generator for a valid chain of blocks.
Instances
Arbitrary TestBlockChain Source # | |
Defined in Test.ChainGenerators arbitrary :: Gen TestBlockChain # shrink :: TestBlockChain -> [TestBlockChain] # | |
Show TestBlockChain Source # | |
Defined in Test.ChainGenerators showsPrec :: Int -> TestBlockChain -> ShowS # show :: TestBlockChain -> String # showList :: [TestBlockChain] -> ShowS # | |
Eq TestBlockChain Source # | |
Defined in Test.ChainGenerators (==) :: TestBlockChain -> TestBlockChain -> Bool # (/=) :: TestBlockChain -> TestBlockChain -> Bool # |
newtype TestHeaderChain Source #
A test generator for a valid chain of block headers.
Instances
Arbitrary TestHeaderChain Source # | |
Defined in Test.ChainGenerators arbitrary :: Gen TestHeaderChain # shrink :: TestHeaderChain -> [TestHeaderChain] # | |
Show TestHeaderChain Source # | |
Defined in Test.ChainGenerators showsPrec :: Int -> TestHeaderChain -> ShowS # show :: TestHeaderChain -> String # showList :: [TestHeaderChain] -> ShowS # | |
Eq TestHeaderChain Source # | |
Defined in Test.ChainGenerators (==) :: 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.
Instances
Arbitrary TestChainAndPoint Source # | |
Defined in Test.ChainGenerators | |
Show TestChainAndPoint Source # | |
Defined in Test.ChainGenerators 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 Test.ChainGenerators | |
Show TestChainAndRange Source # | |
Defined in Test.ChainGenerators 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.
Instances
Arbitrary TestChainAndPoints Source # | |
Defined in Test.ChainGenerators | |
Show TestChainAndPoints Source # | |
Defined in Test.ChainGenerators 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 Test.ChainGenerators arbitrary :: Gen TestChainFork # shrink :: TestChainFork -> [TestChainFork] # | |
Show TestChainFork Source # | |
Defined in Test.ChainGenerators showsPrec :: Int -> TestChainFork -> ShowS # show :: TestChainFork -> String # showList :: [TestChainFork] -> ShowS # |
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
mkPartialBlock :: SlotNo -> BlockBody -> Block #