ouroboros-network-protocols:testlib
Safe HaskellNone
LanguageHaskell2010

Test.ChainGenerators

Description

Arbitrary generators for chains, headers and blocks

Synopsis

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

Instances details
Arbitrary TestAddBlock Source # 
Instance details

Defined in Test.ChainGenerators

Show TestAddBlock Source # 
Instance details

Defined in Test.ChainGenerators

newtype TestBlockChain Source #

A test generator for a valid chain of blocks.

newtype TestHeaderChain Source #

A test generator for a valid chain of block headers.

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.

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.

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.

data TestChainFork Source #

A test generator for two chains sharing a common prefix.

Instances

Instances details
Arbitrary TestChainFork Source # 
Instance details

Defined in Test.ChainGenerators

Show TestChainFork Source # 
Instance details

Defined in Test.ChainGenerators

Utility functions

genNonNegative :: Gen Int Source #

The NonNegative generator produces a large proportion of 0s, so we use this one instead for now.

https://github.com/nick8325/quickcheck/issues/229

addSlotGap :: Int -> WithOrigin SlotNo -> SlotNo Source #

Special case: adding a 0-sized gap to Origin results in SlotNo 0, not Origin. We do this because we use the result of this function to create a block, and blocks must have a slot number.

genChainAnchor :: Gen (Anchor Block) Source #

A starting anchor for a chain fragment: either the AnchorGenesis or an arbitrary anchor

mkRollbackPoint :: HasHeader block => Chain block -> Int -> Point block Source #

Tests of the generators

Orphan instances

Arbitrary BlockNo Source # 
Instance details

Arbitrary Block Source # 
Instance details

Methods

arbitrary :: Gen Block #

shrink :: Block -> [Block] #

Arbitrary BlockBody Source # 
Instance details

Arbitrary BlockHeader Source # 
Instance details

Arbitrary ConcreteHeaderHash Source # 
Instance details

CoArbitrary BlockNo Source # 
Instance details

Methods

coarbitrary :: BlockNo -> Gen b -> Gen b #

CoArbitrary SlotNo Source # 
Instance details

Methods

coarbitrary :: SlotNo -> Gen b -> Gen b #

CoArbitrary Block Source # 
Instance details

Methods

coarbitrary :: Block -> Gen b -> Gen b #

CoArbitrary BlockBody Source # 
Instance details

Methods

coarbitrary :: BlockBody -> Gen b -> Gen b #

CoArbitrary BlockHeader Source # 
Instance details

Methods

coarbitrary :: BlockHeader -> Gen b -> Gen b #

CoArbitrary BodyHash Source # 
Instance details

Methods

coarbitrary :: BodyHash -> Gen b -> Gen b #

CoArbitrary ConcreteHeaderHash Source # 
Instance details

Methods

coarbitrary :: ConcreteHeaderHash -> Gen b -> Gen b #

Arbitrary (ChainRange (Point Block)) Source # 
Instance details

Arbitrary (Point Block) Source # 
Instance details

Arbitrary (Point BlockHeader) Source # 
Instance details

CoArbitrary (ChainHash BlockHeader) Source # 
Instance details