hydra-node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.CBORSpec

Description

Tests for the ToCBOR / FromCBOR codecs of hydra-node types.

Three layers of protection:

  • Unit tests for genericToCBOR / genericFromCBOR pinning down the constructor-name-tagged format they produce (including that newtypes and single-constructor records carry the tag).
  • Roundtrip properties keeping encoder/decoder pairs in sync: adding a constructor without a matching codec (or with fields decoded in the wrong order) fails here.
  • Golden tests locking the concrete byte-level formats, one sample per constructor. These catch changes that roundtrip properties cannot see, e.g. reordering fields in a data declaration of a generically derived codec, or symmetric encoder+decoder drift. If one fails, the change breaks decoding of persisted data (hydra.db) or the API wire format; only delete and regenerate a golden file as a deliberate, documented format change.
Synopsis

ToADTArbitrary instances for per-constructor golden samples

Test types for the generic codec

data GenericCBORSum Source #

Constructors

GenNullary 
GenPositional Int Text 
GenRecord 

Fields

Instances

Instances details
Generic GenericCBORSum Source # 
Instance details

Defined in Hydra.CBORSpec

Associated Types

type Rep GenericCBORSum :: Type -> Type Source #

Show GenericCBORSum Source # 
Instance details

Defined in Hydra.CBORSpec

FromCBOR GenericCBORSum Source # 
Instance details

Defined in Hydra.CBORSpec

Methods

fromCBOR :: Decoder s GenericCBORSum

label :: Proxy GenericCBORSum -> Text

ToCBOR GenericCBORSum Source # 
Instance details

Defined in Hydra.CBORSpec

Methods

toCBOR :: GenericCBORSum -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy GenericCBORSum -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [GenericCBORSum] -> Size

Eq GenericCBORSum Source # 
Instance details

Defined in Hydra.CBORSpec

type Rep GenericCBORSum Source # 
Instance details

Defined in Hydra.CBORSpec

newtype GenericCBORNewtype Source #

Constructors

GenericCBORNewtype Int 

Instances

Instances details
Generic GenericCBORNewtype Source # 
Instance details

Defined in Hydra.CBORSpec

Associated Types

type Rep GenericCBORNewtype :: Type -> Type Source #

Show GenericCBORNewtype Source # 
Instance details

Defined in Hydra.CBORSpec

FromCBOR GenericCBORNewtype Source # 
Instance details

Defined in Hydra.CBORSpec

ToCBOR GenericCBORNewtype Source # 
Instance details

Defined in Hydra.CBORSpec

Methods

toCBOR :: GenericCBORNewtype -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy GenericCBORNewtype -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [GenericCBORNewtype] -> Size

Eq GenericCBORNewtype Source # 
Instance details

Defined in Hydra.CBORSpec

type Rep GenericCBORNewtype Source # 
Instance details

Defined in Hydra.CBORSpec

type Rep GenericCBORNewtype = D1 ('MetaData "GenericCBORNewtype" "Hydra.CBORSpec" "hydra-node-2.3.0-596NbrkErqDLitHifYtGoA-tests" 'True) (C1 ('MetaCons "GenericCBORNewtype" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

spec :: Spec Source #

genGoldenNetworkIds :: Gen [NetworkId] Source #

One sample per NetworkId constructor.

genGoldenChainPoints :: Gen [ChainPoint] Source #

One sample per ChainPoint constructor.

genGoldenStateEvents :: Gen [StateEvent Tx] Source #

One StateEvent per StateChanged constructor, in declaration order: ToADTArbitrary enumerates the constructors generically, so coverage of every constructor holds by construction and new constructors are included automatically. Samples are generated small (resized): the golden file locks tags and field order, which small values exercise just as well.

Orphan instances

ToADTArbitrary FanoutProgressMode Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy FanoutProgressMode -> Gen (ADTArbitrarySingleton FanoutProgressMode)

toADTArbitrary :: Proxy FanoutProgressMode -> Gen (ADTArbitrary FanoutProgressMode)

ToADTArbitrary HeadStatus Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy HeadStatus -> Gen (ADTArbitrarySingleton HeadStatus)

toADTArbitrary :: Proxy HeadStatus -> Gen (ADTArbitrary HeadStatus)

ToADTArbitrary InvalidInput Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy InvalidInput -> Gen (ADTArbitrarySingleton InvalidInput)

toADTArbitrary :: Proxy InvalidInput -> Gen (ADTArbitrary InvalidInput)

ToADTArbitrary NetworkInfo Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy NetworkInfo -> Gen (ADTArbitrarySingleton NetworkInfo)

toADTArbitrary :: Proxy NetworkInfo -> Gen (ADTArbitrary NetworkInfo)

ToADTArbitrary Connectivity Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy Connectivity -> Gen (ADTArbitrarySingleton Connectivity)

toADTArbitrary :: Proxy Connectivity -> Gen (ADTArbitrary Connectivity)

ToADTArbitrary WhichEtcd Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy WhichEtcd -> Gen (ADTArbitrarySingleton WhichEtcd)

toADTArbitrary :: Proxy WhichEtcd -> Gen (ADTArbitrary WhichEtcd)

ToADTArbitrary DepositStatus Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy DepositStatus -> Gen (ADTArbitrarySingleton DepositStatus)

toADTArbitrary :: Proxy DepositStatus -> Gen (ADTArbitrary DepositStatus)

ToADTArbitrary SyncedStatus Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy SyncedStatus -> Gen (ADTArbitrarySingleton SyncedStatus)

toADTArbitrary :: Proxy SyncedStatus -> Gen (ADTArbitrary SyncedStatus)

ToADTArbitrary (ClientMessage Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (ClientMessage Tx) -> Gen (ADTArbitrarySingleton (ClientMessage Tx))

toADTArbitrary :: Proxy (ClientMessage Tx) -> Gen (ADTArbitrary (ClientMessage Tx))

ToADTArbitrary (DecommitInvalidReason Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (DecommitInvalidReason Tx) -> Gen (ADTArbitrarySingleton (DecommitInvalidReason Tx))

toADTArbitrary :: Proxy (DecommitInvalidReason Tx) -> Gen (ADTArbitrary (DecommitInvalidReason Tx))

ToADTArbitrary (TimedServerOutput Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (TimedServerOutput Tx) -> Gen (ADTArbitrarySingleton (TimedServerOutput Tx))

toADTArbitrary :: Proxy (TimedServerOutput Tx) -> Gen (ADTArbitrary (TimedServerOutput Tx))

ToADTArbitrary (ChainEvent Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (ChainEvent Tx) -> Gen (ADTArbitrarySingleton (ChainEvent Tx))

toADTArbitrary :: Proxy (ChainEvent Tx) -> Gen (ADTArbitrary (ChainEvent Tx))

ToADTArbitrary (OnChainTx Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (OnChainTx Tx) -> Gen (ADTArbitrarySingleton (OnChainTx Tx))

toADTArbitrary :: Proxy (OnChainTx Tx) -> Gen (ADTArbitrary (OnChainTx Tx))

ToADTArbitrary (PostChainTx Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (PostChainTx Tx) -> Gen (ADTArbitrarySingleton (PostChainTx Tx))

toADTArbitrary :: Proxy (PostChainTx Tx) -> Gen (ADTArbitrary (PostChainTx Tx))

ToADTArbitrary (PostTxError Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (PostTxError Tx) -> Gen (ADTArbitrarySingleton (PostTxError Tx))

toADTArbitrary :: Proxy (PostTxError Tx) -> Gen (ADTArbitrary (PostTxError Tx))

ToADTArbitrary (RequirementFailure Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (RequirementFailure Tx) -> Gen (ADTArbitrarySingleton (RequirementFailure Tx))

toADTArbitrary :: Proxy (RequirementFailure Tx) -> Gen (ADTArbitrary (RequirementFailure Tx))

ToADTArbitrary (SideLoadRequirementFailure Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (SideLoadRequirementFailure Tx) -> Gen (ADTArbitrarySingleton (SideLoadRequirementFailure Tx))

toADTArbitrary :: Proxy (SideLoadRequirementFailure Tx) -> Gen (ADTArbitrary (SideLoadRequirementFailure Tx))

ToADTArbitrary (FanoutMode Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (FanoutMode Tx) -> Gen (ADTArbitrarySingleton (FanoutMode Tx))

toADTArbitrary :: Proxy (FanoutMode Tx) -> Gen (ADTArbitrary (FanoutMode Tx))

ToADTArbitrary (HeadState Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (HeadState Tx) -> Gen (ADTArbitrarySingleton (HeadState Tx))

toADTArbitrary :: Proxy (HeadState Tx) -> Gen (ADTArbitrary (HeadState Tx))

ToADTArbitrary (SeenSnapshot Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (SeenSnapshot Tx) -> Gen (ADTArbitrarySingleton (SeenSnapshot Tx))

toADTArbitrary :: Proxy (SeenSnapshot Tx) -> Gen (ADTArbitrary (SeenSnapshot Tx))

ToADTArbitrary (Deposit Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (Deposit Tx) -> Gen (ADTArbitrarySingleton (Deposit Tx))

toADTArbitrary :: Proxy (Deposit Tx) -> Gen (ADTArbitrary (Deposit Tx))

ToADTArbitrary (NodeState Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (NodeState Tx) -> Gen (ADTArbitrarySingleton (NodeState Tx))

toADTArbitrary :: Proxy (NodeState Tx) -> Gen (ADTArbitrary (NodeState Tx))

ToADTArbitrary (ConfirmedSnapshot Tx) Source # 
Instance details

Methods

toADTArbitrarySingleton :: Proxy (ConfirmedSnapshot Tx) -> Gen (ADTArbitrarySingleton (ConfirmedSnapshot Tx))

toADTArbitrary :: Proxy (ConfirmedSnapshot Tx) -> Gen (ADTArbitrary (ConfirmedSnapshot Tx))