Safe Haskell | None |
---|---|
Language | Haskell2010 |
Test.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)
- 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 Test.ChainGenerators | |
Show TestAddBlock Source # | |
Defined in Test.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 Test.ChainGenerators Methods arbitrary :: Gen TestBlockChainAndUpdates # shrink :: TestBlockChainAndUpdates -> [TestBlockChainAndUpdates] # | |
Show TestBlockChainAndUpdates Source # | |
Defined in Test.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 Test.ChainGenerators | |
Show TestBlockChain Source # | |
Defined in Test.ChainGenerators Methods showsPrec :: Int -> TestBlockChain -> ShowS # show :: TestBlockChain -> String # showList :: [TestBlockChain] -> ShowS # | |
Eq TestBlockChain Source # | |
Defined in Test.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 Test.ChainGenerators | |
Show TestHeaderChain Source # | |
Defined in Test.ChainGenerators Methods showsPrec :: Int -> TestHeaderChain -> ShowS # show :: TestHeaderChain -> String # showList :: [TestHeaderChain] -> ShowS # | |
Eq TestHeaderChain Source # | |
Defined in Test.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 Test.ChainGenerators | |
Show TestChainAndPoint Source # | |
Defined in Test.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 Test.ChainGenerators | |
Show TestChainAndRange Source # | |
Defined in Test.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 Test.ChainGenerators | |
Show TestChainAndPoints Source # | |
Defined in Test.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 Test.ChainGenerators | |
Show TestChainFork Source # | |
Defined in Test.ChainGenerators Methods 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 #