consensus-test
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Consensus.GSM.Model

Description

The definition of the GSM QSM model and its auxiliaries

Synopsis

Documentation

data Command r Source #

TODO restarts (or maybe just killing the GSM thread)

Constructors

Disconnect UpstreamPeer

INVARIANT must be an existing peer

Mocks the necessary ChainSync client behavior.

ExtendSelection S

INVARIANT selectionIsBehind

NOTE Harmless to assume it only advances by B 1 at a time.

ModifyCandidate UpstreamPeer B

INVARIANT existing peer

Mocks the necessary ChainSync client behavior.

NewCandidate UpstreamPeer B

INVARIANT new peer

Mocks the necessary ChainSync client behavior.

ReadGsmState 
ReadMarker 
StartIdling UpstreamPeer

INVARIANT existing peer, not idling

TimePasses Int

tenths of a second

INVARIANT positive

INVARIANT does not end exactly on an interesting time point; see boringDur.

NOTE The generator does not yield consecutive TimePasses commands, though shrinking might.

Instances

Instances details
Foldable Command Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

foldMapMonoid m ⇒ (∀ (x ∷ k). p x → m) → Command p → m Source #

Functor Command Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

fmap ∷ (∀ (x ∷ k). p x → q x) → Command p → Command q Source #

Traversable Command Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

traverseApplicative f ⇒ (∀ (a ∷ k). p a → f (q a)) → Command p → f (Command q) Source #

Read (Command r) Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Show (Command r) Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

showsPrecIntCommand r → ShowS #

showCommand r → String #

showList ∷ [Command r] → ShowS #

Generic1 Command Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep1 Command ∷ k → Type #

Methods

from1 ∷ ∀ (a ∷ k). Command a → Rep1 Command a #

to1 ∷ ∀ (a ∷ k). Rep1 Command a → Command a #

CommandNames Command Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

cmdName ∷ ∀ (r ∷ k). Command r → String Source #

cmdNames ∷ ∀ (r ∷ k). Proxy (Command r) → [String] Source #

type Rep1 Command Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep1 Command = D1 ('MetaData "Command" "Test.Consensus.GSM.Model" "ouroboros-consensus-diffusion-0.18.0.0-inplace-consensus-test" 'False) (((C1 ('MetaCons "Disconnect" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UpstreamPeer)) :+: C1 ('MetaCons "ExtendSelection" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 S))) :+: (C1 ('MetaCons "ModifyCandidate" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UpstreamPeer) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 B)) :+: C1 ('MetaCons "NewCandidate" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UpstreamPeer) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 B)))) :+: ((C1 ('MetaCons "ReadGsmState" 'PrefixI 'False) (U1 ∷ (TypeType) → Type) :+: C1 ('MetaCons "ReadMarker" 'PrefixI 'False) (U1 ∷ (TypeType) → Type)) :+: (C1 ('MetaCons "StartIdling" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UpstreamPeer)) :+: C1 ('MetaCons "TimePasses" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))))

newtype S Source #

A slot count

Constructors

S Int 

Instances

Instances details
Enum S Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

succSS #

predSS #

toEnumIntS #

fromEnumSInt #

enumFromS → [S] #

enumFromThenSS → [S] #

enumFromToSS → [S] #

enumFromThenToSSS → [S] #

Generic S Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep STypeType #

Methods

fromSRep S x #

toRep S x → S #

Num S Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

(+)SSS #

(-)SSS #

(*)SSS #

negateSS #

absSS #

signumSS #

fromIntegerIntegerS #

Read S Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Show S Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

showsPrecIntSShowS #

showSString #

showList ∷ [S] → ShowS #

Eq S Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

(==)SSBool #

(/=)SSBool #

Ord S Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

compareSSOrdering #

(<)SSBool #

(<=)SSBool #

(>)SSBool #

(>=)SSBool #

maxSSS #

minSSS #

ToExpr S Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

toExprSExpr Source #

listToExpr ∷ [S] → Expr Source #

type Rep S Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep S = D1 ('MetaData "S" "Test.Consensus.GSM.Model" "ouroboros-consensus-diffusion-0.18.0.0-inplace-consensus-test" 'True) (C1 ('MetaCons "S" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

newtype B Source #

A block count

Constructors

B Int 

Instances

Instances details
Enum B Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

succBB #

predBB #

toEnumIntB #

fromEnumBInt #

enumFromB → [B] #

enumFromThenBB → [B] #

enumFromToBB → [B] #

enumFromThenToBBB → [B] #

Generic B Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep BTypeType #

Methods

fromBRep B x #

toRep B x → B #

Num B Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

(+)BBB #

(-)BBB #

(*)BBB #

negateBB #

absBB #

signumBB #

fromIntegerIntegerB #

Read B Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Show B Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

showsPrecIntBShowS #

showBString #

showList ∷ [B] → ShowS #

Eq B Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

(==)BBBool #

(/=)BBBool #

Ord B Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

compareBBOrdering #

(<)BBBool #

(<=)BBBool #

(>)BBBool #

(>=)BBBool #

maxBBB #

minBBB #

ToExpr B Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

toExprBExpr Source #

listToExpr ∷ [B] → Expr Source #

type Rep B Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep B = D1 ('MetaData "B" "Test.Consensus.GSM.Model" "ouroboros-consensus-diffusion-0.18.0.0-inplace-consensus-test" 'True) (C1 ('MetaCons "B" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

data Model r Source #

Instances

Instances details
Generic (Model r) Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep (Model r) ∷ TypeType #

Methods

fromModel r → Rep (Model r) x #

toRep (Model r) x → Model r #

Show (Model r) Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

showsPrecIntModel r → ShowS #

showModel r → String #

showList ∷ [Model r] → ShowS #

ToExpr (Model r) Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

toExprModel r → Expr Source #

listToExpr ∷ [Model r] → Expr Source #

type Rep (Model r) Source # 
Instance details

Defined in Test.Consensus.GSM.Model

data Response r Source #

Instances

Instances details
Foldable Response Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

foldMapMonoid m ⇒ (∀ (x ∷ k). p x → m) → Response p → m Source #

Functor Response Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

fmap ∷ (∀ (x ∷ k). p x → q x) → Response p → Response q Source #

Traversable Response Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

traverseApplicative f ⇒ (∀ (a ∷ k). p a → f (q a)) → Response p → f (Response q) Source #

Read (Response r) Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Show (Response r) Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

showsPrecIntResponse r → ShowS #

showResponse r → String #

showList ∷ [Response r] → ShowS #

Generic1 Response Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep1 Response ∷ k → Type #

Methods

from1 ∷ ∀ (a ∷ k). Response a → Rep1 Response a #

to1 ∷ ∀ (a ∷ k). Rep1 Response a → Response a #

type Rep1 Response Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep1 Response = D1 ('MetaData "Response" "Test.Consensus.GSM.Model" "ouroboros-consensus-diffusion-0.18.0.0-inplace-consensus-test" 'False) (C1 ('MetaCons "ReadThisGsmState" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 GsmState)) :+: (C1 ('MetaCons "ReadThisMarker" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MarkerState)) :+: C1 ('MetaCons "Unit" 'PrefixI 'False) (U1 ∷ (TypeType) → Type)))

data UpstreamPeer Source #

Constructors

Amara 
Bao 
Cait 
Dhani 
Eric 

Instances

Instances details
CoArbitrary UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

coarbitraryUpstreamPeerGen b → Gen b Source #

Function UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

function ∷ (UpstreamPeer → b) → UpstreamPeer :-> b Source #

Bounded UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Enum UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Generic UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep UpstreamPeerTypeType #

Read UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Show UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Eq UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Ord UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

ToExpr UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep UpstreamPeer Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep UpstreamPeer = D1 ('MetaData "UpstreamPeer" "Test.Consensus.GSM.Model" "ouroboros-consensus-diffusion-0.18.0.0-inplace-consensus-test" 'False) ((C1 ('MetaCons "Amara" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "Bao" 'PrefixI 'False) (U1TypeType)) :+: (C1 ('MetaCons "Cait" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "Dhani" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "Eric" 'PrefixI 'False) (U1TypeType))))

data MarkerState Source #

Constructors

Present 
Absent 

Instances

Instances details
Arbitrary MarkerState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Generic MarkerState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep MarkerStateTypeType #

Read MarkerState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Show MarkerState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Eq MarkerState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Ord MarkerState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

ToExpr MarkerState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep MarkerState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep MarkerState = D1 ('MetaData "MarkerState" "Test.Consensus.GSM.Model" "ouroboros-consensus-diffusion-0.18.0.0-inplace-consensus-test" 'False) (C1 ('MetaCons "Present" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "Absent" 'PrefixI 'False) (U1TypeType))

newtype Candidate Source #

The age of the candidate is irrelevant, only its length matters

Constructors

Candidate B 

Instances

Instances details
Generic Candidate Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep CandidateTypeType #

Methods

fromCandidateRep Candidate x #

toRep Candidate x → Candidate #

Show Candidate Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

showsPrecIntCandidateShowS #

showCandidateString #

showList ∷ [Candidate] → ShowS #

Eq Candidate Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

(==)CandidateCandidateBool #

(/=)CandidateCandidateBool #

Ord Candidate Source # 
Instance details

Defined in Test.Consensus.GSM.Model

ToExpr Candidate Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep Candidate Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep Candidate = D1 ('MetaData "Candidate" "Test.Consensus.GSM.Model" "ouroboros-consensus-diffusion-0.18.0.0-inplace-consensus-test" 'True) (C1 ('MetaCons "Candidate" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 B)))

data Notable Source #

Interesting events to record within the model

TODO some less superficial ones (eg even just combinations of these)

Constructors

BigDurN

there was a "big" TimesPasses command

CaughtUpN

the node transitioned from Syncing to CaughtUp

FellBehindN

the node transitioned from CaughtUp to PreSyncing

SyncingToPreSyncingN

the node transition from Syncing to PreSyncing

PreSyncingToSyncingN

the node transition from PreSyncing to Syncing

FlickerN

the node transitioned from CaughtUp to PreSyncing to Syncing and back to CaughtUp "instantly"

NotThrashingN

the anti-thrashing would have allowed FellBehindN, but the selection wasn't old enough

TooOldN

the selection was old enough for FellBehindN, but the anti-thrashing prevented it

Instances

Instances details
Show Notable Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

showsPrecIntNotableShowS #

showNotableString #

showList ∷ [Notable] → ShowS #

Eq Notable Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

(==)NotableNotableBool #

(/=)NotableNotableBool #

Ord Notable Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

compareNotableNotableOrdering #

(<)NotableNotableBool #

(<=)NotableNotableBool #

(>)NotableNotableBool #

(>=)NotableNotableBool #

maxNotableNotableNotable #

minNotableNotableNotable #

ToExpr Notable Source # 
Instance details

Defined in Test.Consensus.GSM.Model

newtype WhetherPrevTimePasses Source #

Instances

Instances details
Generic WhetherPrevTimePasses Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep WhetherPrevTimePassesTypeType #

Show WhetherPrevTimePasses Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Eq WhetherPrevTimePasses Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Ord WhetherPrevTimePasses Source # 
Instance details

Defined in Test.Consensus.GSM.Model

ToExpr WhetherPrevTimePasses Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep WhetherPrevTimePasses Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep WhetherPrevTimePasses = D1 ('MetaData "WhetherPrevTimePasses" "Test.Consensus.GSM.Model" "ouroboros-consensus-diffusion-0.18.0.0-inplace-consensus-test" 'True) (C1 ('MetaCons "WhetherPrevTimePasses" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

data Selection Source #

The cumulative growth relative to whatever length the initial selection was and the slot relative to the start of the test (which is assumed to be the exact onset of some slot)

Constructors

Selection !B !S 

Instances

Instances details
Generic Selection Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep SelectionTypeType #

Methods

fromSelectionRep Selection x #

toRep Selection x → Selection #

Show Selection Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

showsPrecIntSelectionShowS #

showSelectionString #

showList ∷ [Selection] → ShowS #

Eq Selection Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

(==)SelectionSelectionBool #

(/=)SelectionSelectionBool #

Ord Selection Source # 
Instance details

Defined in Test.Consensus.GSM.Model

ToExpr Selection Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep Selection Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep Selection = D1 ('MetaData "Selection" "Test.Consensus.GSM.Model" "ouroboros-consensus-diffusion-0.18.0.0-inplace-consensus-test" 'False) (C1 ('MetaCons "Selection" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 B) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 S)))

data ModelState Source #

Constructors

ModelPreSyncing 
ModelSyncing 
ModelCaughtUp !Time

when the model most recently transitioned to CaughtUp.

Instances

Instances details
Generic ModelState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Associated Types

type Rep ModelStateTypeType #

Show ModelState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Eq ModelState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

Methods

(==)ModelStateModelStateBool #

(/=)ModelStateModelStateBool #

Ord ModelState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

ToExpr ModelState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep ModelState Source # 
Instance details

Defined in Test.Consensus.GSM.Model

type Rep ModelState = D1 ('MetaData "ModelState" "Test.Consensus.GSM.Model" "ouroboros-consensus-diffusion-0.18.0.0-inplace-consensus-test" 'False) (C1 ('MetaCons "ModelPreSyncing" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "ModelSyncing" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "ModelCaughtUp" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Time))))

transitionContextModel r → Command r → Response r → Model r Source #

mockModel r → Command r → Response r Source #

boringDurModel r → IntLogic Source #

Checks that a TimePasses command does not end exactly when a timeout could fire and that a ExtendSelection does not incur a timeout that would fire immediately

This insulates the test from race conditions that are innocuous in the real world.

fixupModelStateContextCommand r → Model r → Model r Source #

Update the mState, assuming that's the only stale field in the given Model

ageLimitNum a ⇒ a Source #

thrashLimitNum a ⇒ a Source #

Orphan instances