ouroboros-consensus:unstable-consensus-testlib
Safe HaskellNone
LanguageHaskell2010

Test.Util.Peras.Common

Description

Common test utilities for Peras tests.

Synopsis

Documentation

genListWithUniqueIds ∷ Ord idTy ⇒ (a → idTy) → Gen a → Gen (ListWithUniqueIds a) Source #

genNonEmptyListWithUniqueIds ∷ Ord idTy ⇒ (a → idTy) → Gen a → Gen (NonEmptyListWithUniqueIds a) Source #

mockSystemTime ∷ ∀ (m ∷ Type → Type). Applicative m ⇒ SystemTime m Source #

A static SystemTime returning a constant time. The canonical mock system time lives in mockSystemTime, but it is a field of LogicalClock which requires a ResourceRegistry and a background tick thread — too heavyweight for simple property tests that don't need time progression.

mkBucket ∷ Int → Int → String → String Source #

divisorClosestToTarget ∷ Integral a ⇒ a → Double → a Source #

Find the whole divisor of num that is the closest to target.

divisorClosestToQuotient ∷ Integral a ⇒ a → a → a Source #

Find the whole divisor of a that is the closest to 'a/b'.

If there are multiple divisors with the same distance, the smallest one is returned.

>>> divisorClosestToQuotient 10 3
2
>>> divisorClosestToQuotient 10 5
2
>>> divisorClosestToQuotient 6 10
1