cardano-sl-0.4.3: Cardano SL main implementation

Pos.Block.Arbitrary

Contents

Synopsis

# Documentation

This type is used to generate a valid blockheader and associated header verification params. With regards to the block header function verifyHeader, the blockheaders that may be part of the verification parameters are guaranteed to be valid, as are the slot leaders and the current slot.

Constructors

Instances

 Ssc ssc => Eq (HeaderAndParams ssc) Source # Methods(==) :: HeaderAndParams ssc -> HeaderAndParams ssc -> Bool #(/=) :: HeaderAndParams ssc -> HeaderAndParams ssc -> Bool # Ssc ssc => Show (HeaderAndParams ssc) Source # MethodsshowsPrec :: Int -> HeaderAndParams ssc -> ShowS #show :: HeaderAndParams ssc -> String #showList :: [HeaderAndParams ssc] -> ShowS # (Arbitrary (SscPayload ssc), SscHelpersClass ssc) => Arbitrary (HeaderAndParams ssc) Source # A lot of the work to generate a valid sequence of blockheaders has already been done in the Arbitrary instance of the BlockHeaderList type, so it is used here and at most 3 blocks are taken from the generated list. Methodsarbitrary :: Gen (HeaderAndParams ssc) #shrink :: HeaderAndParams ssc -> [HeaderAndParams ssc] #

Constructors

Instances

 Ssc ssc => Eq (BlockHeaderList ssc) Source # Methods(==) :: BlockHeaderList ssc -> BlockHeaderList ssc -> Bool #(/=) :: BlockHeaderList ssc -> BlockHeaderList ssc -> Bool # BiSsc ssc => Show (BlockHeaderList ssc) Source # MethodsshowsPrec :: Int -> BlockHeaderList ssc -> ShowS #show :: BlockHeaderList ssc -> String #showList :: [BlockHeaderList ssc] -> ShowS # (Arbitrary (SscPayload ssc), SscHelpersClass ssc) => Arbitrary (BlockHeaderList ssc) Source # This type is used to generate a blockchain, as well a list of leaders for every slot with which the chain will be paired. The leaders are in reverse order to the chain - the list goes from first to last leader. This is used in a verifyHeader test.Note that every non-empty blockchain has at least one epoch, which may be complete or incomplete. To simulate this behavior, two random numbers are generated: one that stands for the number of complete epochs we have, and the other for the number of incomplete slots of the last epoch, which, in this instance, must exist.A blockchain with only complete epochs is a subset of some blockchain with one incomplete epoch, so if the former is desired, a simple list takeWhile of the list this instance generates will be enough.Note that a leader is generated for each slot. (Not exactly a leader - see previous comment) Methodsarbitrary :: Gen (BlockHeaderList ssc) #shrink :: BlockHeaderList ssc -> [BlockHeaderList ssc] #