Safe Haskell | None |
---|---|
Language | Haskell2010 |
Test.Util.Orphans.Arbitrary
Contents
Synopsis
- newtype SmallDiffTime = SmallDiffTime NominalDiffTime
- genLimitedEpochSize ∷ Gen EpochSize
- genLimitedSlotNo ∷ Gen SlotNo
- genSmallEpochNo ∷ Gen EpochNo
- genSmallSlotNo ∷ Gen SlotNo
- genNominalDiffTime50Years ∷ Gen NominalDiffTime
- genUTCTime50Years ∷ Gen UTCTime
Documentation
newtype SmallDiffTime Source #
Wrapper around NominalDiffTime with custom Arbitrary
instance
The default Arbitrary
instance for NominalDiffTime
isn't very useful:
- It tends to pick huge values
- It tends not to pick integer values
- It does not shrink
Our custom instance
- Picks values between 0 and (1000 * 20 * 10) seconds:
- Maximum segment length: 1000
- Maximum slot length: 20 seconds
- Maximum number of segments: 10
- With a 0.1 second precision
- Shrinks
Constructors
SmallDiffTime NominalDiffTime |
Instances
Show SmallDiffTime Source # | |
Defined in Test.Util.Orphans.Arbitrary | |
Arbitrary SmallDiffTime Source # | |
Defined in Test.Util.Orphans.Arbitrary |
genLimitedEpochSize ∷ Gen EpochSize Source #
The tests for CumulEpochSizes
requires that the sum of a list of these
values does not overflow.
An epoch size must be > 0.
genLimitedSlotNo ∷ Gen SlotNo Source #
The functions slotAtTime
and timeUntilNextSlot
suffer from arithmetic
overflow for very large values, so generate values that avoid overflow when
used in these two functions. The largest value generated is still sufficently
large to allow for 5e12 years worth of slots at a slot interval of 20
seconds.
genSmallEpochNo ∷ Gen EpochNo Source #
genSmallSlotNo ∷ Gen SlotNo Source #
Generate a small SlotNo for the state machine tests. The runtime of the StateMachine prop_sequential tests is proportional the the upper bound.
Time
genNominalDiffTime50Years ∷ Gen NominalDiffTime Source #
Picks time span between 0 seconds and (roughly) 50 years
Note - Arbitrary instance for NominalDiffTime
comes from quickcheck-instances
and
it uses a much wider timespan.
genUTCTime50Years ∷ Gen UTCTime Source #
Picks moment between dawnOfTime
and (roughly) 50 years later
Note - Arbitrary instance for UTCTime
comes from quickcheck-instances
and it uses
a much wider timespan.
Orphan instances
Arbitrary ClockSkew Source # | |
Arbitrary Bound Source # | |
Arbitrary ChunkSlot Source # | |
Arbitrary NumCoreNodes Source # | |
Arbitrary ChunkSize Source # | Picks a |
Arbitrary ChunkNo Source # | This picks an We don't pick larger values because we're not interested in testing overflow due to huge epoch numbers and even huger slot numbers. |
Arbitrary RelativeSlot Source # | |
Arbitrary QueryVersion Source # | |
Arbitrary SlotLength Source # | Length between 0.001 and 20 seconds, millisecond granularity |
(IsNonEmpty xs, SListI xs, All (Compose Arbitrary WrapChainDepState) xs) ⇒ Arbitrary (HardForkChainDepState xs) Source # | |
Methods arbitrary ∷ Gen (HardForkChainDepState xs) shrink ∷ HardForkChainDepState xs → [HardForkChainDepState xs] | |
(All SingleEraBlock (x ': xs), IsNonEmpty xs) ⇒ Arbitrary (MismatchEraInfo (x ': xs)) Source # | |
Methods arbitrary ∷ Gen (MismatchEraInfo (x ': xs)) shrink ∷ MismatchEraInfo (x ': xs) → [MismatchEraInfo (x ': xs)] | |
Arbitrary (ApplyTxErr blk) ⇒ Arbitrary (WrapApplyTxErr blk) Source # | Forwarding |
Arbitrary (HeaderHash blk) ⇒ Arbitrary (WrapHeaderHash blk) Source # | Forwarding |
Arbitrary (TipInfo blk) ⇒ Arbitrary (WrapTipInfo blk) Source # | Forwarding |
Arbitrary (ChainDepState (BlockProtocol blk)) ⇒ Arbitrary (WrapChainDepState blk) Source # | Forwarding |
Methods arbitrary ∷ Gen (WrapChainDepState blk) shrink ∷ WrapChainDepState blk → [WrapChainDepState blk] | |
(IsNonEmpty xs, SListI xs, All (Compose Arbitrary LedgerState) xs) ⇒ Arbitrary (LedgerState (HardForkBlock xs)) Source # | |
Methods arbitrary ∷ Gen (LedgerState (HardForkBlock xs)) shrink ∷ LedgerState (HardForkBlock xs) → [LedgerState (HardForkBlock xs)] | |
SingleEraBlock blk ⇒ Arbitrary (SingleEraInfo blk) Source # | |
SingleEraBlock blk ⇒ Arbitrary (LedgerEraInfo blk) Source # | |
Arbitrary a ⇒ Arbitrary (I a) Source # | Forwarding |
Arbitrary (f blk) ⇒ Arbitrary (Current f blk) Source # | |
Arbitrary (SomeSecond BlockQuery blk) ⇒ Arbitrary (SomeSecond Query blk) Source # | |
(All (Compose Arbitrary f) xs, IsNonEmpty xs) ⇒ Arbitrary (NS f xs) Source # | |
Arbitrary (K Past blk) Source # | |
(IsNonEmpty xs, All (Compose Arbitrary f) (x ': xs), All (Compose Arbitrary g) (x ': xs)) ⇒ Arbitrary (Mismatch f g (x ': xs)) Source # | |
(IsNonEmpty xs, All (Compose Arbitrary f) xs, All (Compose Arbitrary g) xs) ⇒ Arbitrary (Telescope g f xs) Source # | |