ouroboros-network-mock-0.1.1.1: Ouroboros Network Chain for testing purposes
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Network.Mock.ConcreteBlock

Description

Concrete block

The network library should not export a concrete block type at all, except that it might need one in its tests (but not exported). Right now this module serves to isolate this in a specific module so we can identify easily where it is used; eventually it should be simplified and then moved to the network layer tests; the more sophiscated block abstraction (abstracted over an Ouroboros protocol) will live in the consensus layer.

Synopsis

Documentation

data Block Source #

Our highly-simplified version of a block. It retains the separation between a block header and body, which is a detail needed for the protocols.

Constructors

Block 

Instances

Instances details
Generic Block Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Associated Types

type Rep BlockTypeType #

Methods

fromBlockRep Block x #

toRep Block x → Block #

Show Block Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Methods

showsPrecIntBlockShowS #

showBlockString #

showList ∷ [Block] → ShowS #

Eq Block Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Methods

(==)BlockBlockBool #

(/=)BlockBlockBool #

HasFullHeader Block Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

HasHeader Block Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Serialise Block Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

StandardHash Block Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

ShowProxy Block Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

type Rep Block Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

type Rep Block = D1 ('MetaData "Block" "Ouroboros.Network.Mock.ConcreteBlock" "ouroboros-network-mock-0.1.1.1-inplace" 'False) (C1 ('MetaCons "Block" 'PrefixI 'True) (S1 ('MetaSel ('Just "blockHeader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BlockHeader) :*: S1 ('MetaSel ('Just "blockBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BlockBody)))
type HeaderHash Block Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

data BlockHeader Source #

A block header. It retains simplified versions of all the essential elements.

Constructors

BlockHeader 

Fields

Instances

Instances details
Generic BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Associated Types

type Rep BlockHeaderTypeType #

Show BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Eq BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

HasFullHeader BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

HasHeader BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Serialise BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

StandardHash BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

ShowProxy BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

type Rep BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

type Rep BlockHeader = D1 ('MetaData "BlockHeader" "Ouroboros.Network.Mock.ConcreteBlock" "ouroboros-network-mock-0.1.1.1-inplace" 'False) (C1 ('MetaCons "BlockHeader" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headerHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (HeaderHash BlockHeader)) :*: S1 ('MetaSel ('Just "headerPrevHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainHash BlockHeader))) :*: (S1 ('MetaSel ('Just "headerSlot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo) :*: (S1 ('MetaSel ('Just "headerBlockNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BlockNo) :*: S1 ('MetaSel ('Just "headerBodyHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BodyHash)))))
type HeaderHash BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

newtype BlockBody Source #

Constructors

BlockBody ByteString 

Instances

Instances details
IsString BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Methods

fromStringStringBlockBody #

Generic BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Associated Types

type Rep BlockBodyTypeType #

Methods

fromBlockBodyRep BlockBody x #

toRep BlockBody x → BlockBody #

Show BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Methods

showsPrecIntBlockBodyShowS #

showBlockBodyString #

showList ∷ [BlockBody] → ShowS #

Eq BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Methods

(==)BlockBodyBlockBodyBool #

(/=)BlockBodyBlockBodyBool #

Ord BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Hashable BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Serialise BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

type Rep BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

type Rep BlockBody = D1 ('MetaData "BlockBody" "Ouroboros.Network.Mock.ConcreteBlock" "ouroboros-network-mock-0.1.1.1-inplace" 'True) (C1 ('MetaCons "BlockBody" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

newtype BodyHash Source #

The hash of all the information in a BlockBody.

Constructors

BodyHash Int 

Instances

Instances details
Generic BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Associated Types

type Rep BodyHashTypeType #

Methods

fromBodyHashRep BodyHash x #

toRep BodyHash x → BodyHash #

Show BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Methods

showsPrecIntBodyHashShowS #

showBodyHashString #

showList ∷ [BodyHash] → ShowS #

Eq BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Methods

(==)BodyHashBodyHashBool #

(/=)BodyHashBodyHashBool #

Ord BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Hashable BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Serialise BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

type Rep BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

type Rep BodyHash = D1 ('MetaData "BodyHash" "Ouroboros.Network.Mock.ConcreteBlock" "ouroboros-network-mock-0.1.1.1-inplace" 'True) (C1 ('MetaCons "BodyHash" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

newtype ConcreteHeaderHash Source #

The hash of all the information in a BlockHeader.

Constructors

HeaderHash Int 

Instances

Instances details
Generic ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Associated Types

type Rep ConcreteHeaderHashTypeType #

Show ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Eq ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Ord ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Hashable ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

NoThunks ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

Serialise ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

type Rep ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Mock.ConcreteBlock

type Rep ConcreteHeaderHash = D1 ('MetaData "ConcreteHeaderHash" "Ouroboros.Network.Mock.ConcreteBlock" "ouroboros-network-mock-0.1.1.1-inplace" 'True) (C1 ('MetaCons "HeaderHash" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

hashBodyHashable body ⇒ body → BodyHash Source #

Converting slots to times

convertSlotToTimeForTestsAssumingNoHardForkSlotNoUTCTime Source #

Arbitrarily but consistently converts slots UTCTimes.

It is only intended for use in tests. Notably it assumes a fixed system start time, slot length, and the absence of a hard fork (ie no HardForkCombinator). This is how it's available as a pure function.

Creating sample chains

mkChain ∷ [(SlotNo, BlockBody)] → Chain Block Source #

This takes the blocks in order from oldest to newest.

Generator utilities

fixupBlockHeaderHash block ~ HeaderHash BlockHeaderAnchor block → BlockBlock Source #

Fix up a block so that it fits on top of the given anchor. Only the block number, the previous hash and the block hash are updated; the slot number and the signers are kept intact.

fixupBlockHeaderHeaderHash block ~ HeaderHash BlockHeaderAnchor block → BlockHeaderBlockHeader Source #

Fixup block header to fit it on top of a chain. Only block number and previous hash are updated; the slot and signer are kept unchanged.

fixupBlockAfterBlockBlockBlockBlock Source #

Fixup a block so to fit it on top of a given previous block.

fixupChainHasFullHeader b ⇒ (Anchor b → b → b) → [b] → Chain b Source #

Fix up the block number and hashes of a Chain. This also fixes up the first block to chain-on from genesis, since by construction the Chain type starts from genesis.

fixupAnchoredFragmentFromHasFullHeader b ⇒ Anchor b → (Anchor b → b → b) → [b] → AnchoredFragment b Source #

Orphan instances

Hashable BlockNo Source # 
Instance details

Methods

hashWithSaltIntBlockNoInt Source #

hashBlockNoInt Source #

Hashable SlotNo Source # 
Instance details

Methods

hashWithSaltIntSlotNoInt Source #

hashSlotNoInt Source #

(StandardHash b, Hashable (HeaderHash b)) ⇒ Hashable (ChainHash b) Source #

Hashable instance for Hash

We don't insist that Hashable in StandardHash because Hashable is only used in the network layer tests.

This requires UndecidableInstances because Hashable (HeaderHash b) is no smaller than Hashable (ChainHash b).

Instance details

Methods

hashWithSaltIntChainHash b → Int Source #

hashChainHash b → Int Source #