tests
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Control.State.Transition.Examples.CommitReveal

Synopsis

Documentation

data CR hashAlgo (hashToDataMap ∷ TypeTypeType) commitData Source #

Commit-reveal transition system, where data hashes are committed and then revealed.

The first type parameter denotes the type of hash algorithm used.

The second parameter denotes the structure used to associate a commit to its hash. See CRSt

The third parameter is the data that will be associated to the Commit signal.

Instances

Instances details
(HashAlgorithm hashAlgo, Typeable hashToDataMap, Typeable commitData, MapLike hashToDataMap (Hash hashAlgo Data) commitData, Monoid (hashToDataMap (Hash hashAlgo Data) commitData)) ⇒ STS (CR hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Associated Types

type State (CR hashAlgo hashToDataMap commitData) Source #

type Signal (CR hashAlgo hashToDataMap commitData) Source #

type Environment (CR hashAlgo hashToDataMap commitData) Source #

type BaseM (CR hashAlgo hashToDataMap commitData) ∷ TypeType Source #

type Event (CR hashAlgo hashToDataMap commitData) Source #

type PredicateFailure (CR hashAlgo hashToDataMap commitData) Source #

Methods

initialRules ∷ [InitialRule (CR hashAlgo hashToDataMap commitData)] Source #

transitionRules ∷ [TransitionRule (CR hashAlgo hashToDataMap commitData)] Source #

assertions ∷ [Assertion (CR hashAlgo hashToDataMap commitData)] Source #

renderAssertionViolationAssertionViolation (CR hashAlgo hashToDataMap commitData) → String Source #

HashAlgorithm hashAlgo ⇒ HasTrace (CR hashAlgo Map Data) () Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Associated Types

type BaseEnv (CR hashAlgo Map Data) Source #

Methods

interpretSTSHasCallStackBaseEnv (CR hashAlgo Map Data) → BaseM (CR hashAlgo Map Data) a → a Source #

envGen ∷ () → Gen (Environment (CR hashAlgo Map Data)) Source #

sigGen ∷ () → Environment (CR hashAlgo Map Data) → State (CR hashAlgo Map Data) → Gen (Signal (CR hashAlgo Map Data)) Source #

shrinkSignalSignal (CR hashAlgo Map Data) → [Signal (CR hashAlgo Map Data)] Source #

type BaseM (CR hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

type BaseM (CR hashAlgo hashToDataMap commitData) = Identity
type Environment (CR hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

type Environment (CR hashAlgo hashToDataMap commitData) = ()
type Event (CR hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

type Event (CR hashAlgo hashToDataMap commitData) = Void
type PredicateFailure (CR hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

type PredicateFailure (CR hashAlgo hashToDataMap commitData) = CRPredicateFailure hashAlgo hashToDataMap commitData
type Signal (CR hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

type Signal (CR hashAlgo hashToDataMap commitData) = CRSignal hashAlgo commitData
type State (CR hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

type State (CR hashAlgo hashToDataMap commitData) = CRSt hashAlgo hashToDataMap commitData
type BaseEnv (CR hashAlgo Map Data) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

type BaseEnv (CR hashAlgo Map Data) = ()

data CRSt hashAlgo hashToDataMap commitData Source #

Commit-reveal transition system state.

Constructors

CRSt 

Fields

  • hashToData ∷ !(hashToDataMap (Hash hashAlgo Data) commitData)

    Part of the state used to associate data to the hash that was committed.

    This is used only by the generators, so hashToDataMap will be instantiated to a Map in the generators, for testing purposes; and it will be instantiated to NoOpMap in an eventual implementation.

    Here hashToData is an example of a phantom variable, which wouldn't be present in the formal specification, but it is needed in the executable spec to be able to generate traces.

  • committedHashes ∷ !(Set (Hash hashAlgo Data))
     

Instances

Instances details
Show (hashToDataMap (Hash hashAlgo Data) commitData) ⇒ Show (CRSt hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

showsPrecIntCRSt hashAlgo hashToDataMap commitData → ShowS Source #

showCRSt hashAlgo hashToDataMap commitData → String Source #

showList ∷ [CRSt hashAlgo hashToDataMap commitData] → ShowS Source #

Eq (hashToDataMap (Hash hashAlgo Data) commitData) ⇒ Eq (CRSt hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

(==)CRSt hashAlgo hashToDataMap commitData → CRSt hashAlgo hashToDataMap commitData → Bool Source #

(/=)CRSt hashAlgo hashToDataMap commitData → CRSt hashAlgo hashToDataMap commitData → Bool Source #

class MapLike m k v where Source #

Methods

insert ∷ k → v → m k v → m k v Source #

delete ∷ k → m k v → m k v Source #

Instances

Instances details
Ord k ⇒ MapLike Map k v Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

insert ∷ k → v → Map k v → Map k v Source #

delete ∷ k → Map k v → Map k v Source #

MapLike NoOpMap a b Source #

This is the MapLike instance one would use if the executable spec would be used in an implementation (where no generators are needed).

Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

insert ∷ a → b → NoOpMap a b → NoOpMap a b Source #

delete ∷ a → NoOpMap a b → NoOpMap a b Source #

data NoOpMap a b Source #

Constructors

NoOpMap 

Instances

Instances details
MapLike NoOpMap a b Source #

This is the MapLike instance one would use if the executable spec would be used in an implementation (where no generators are needed).

Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

insert ∷ a → b → NoOpMap a b → NoOpMap a b Source #

delete ∷ a → NoOpMap a b → NoOpMap a b Source #

data CRSignal hashAlgo commitData Source #

Constructors

Commit (Hash hashAlgo Data) commitData 
Reveal Data 

Instances

Instances details
Show commitData ⇒ Show (CRSignal hashAlgo commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

showsPrecIntCRSignal hashAlgo commitData → ShowS Source #

showCRSignal hashAlgo commitData → String Source #

showList ∷ [CRSignal hashAlgo commitData] → ShowS Source #

Eq commitData ⇒ Eq (CRSignal hashAlgo commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

(==)CRSignal hashAlgo commitData → CRSignal hashAlgo commitData → Bool Source #

(/=)CRSignal hashAlgo commitData → CRSignal hashAlgo commitData → Bool Source #

Ord commitData ⇒ Ord (CRSignal hashAlgo commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

compareCRSignal hashAlgo commitData → CRSignal hashAlgo commitData → Ordering Source #

(<)CRSignal hashAlgo commitData → CRSignal hashAlgo commitData → Bool Source #

(<=)CRSignal hashAlgo commitData → CRSignal hashAlgo commitData → Bool Source #

(>)CRSignal hashAlgo commitData → CRSignal hashAlgo commitData → Bool Source #

(>=)CRSignal hashAlgo commitData → CRSignal hashAlgo commitData → Bool Source #

maxCRSignal hashAlgo commitData → CRSignal hashAlgo commitData → CRSignal hashAlgo commitData Source #

minCRSignal hashAlgo commitData → CRSignal hashAlgo commitData → CRSignal hashAlgo commitData Source #

isCommitCRSignal hashAlgo commitData → Bool Source #

newtype Data Source #

Constructors

Data 

Fields

Instances

Instances details
Arbitrary Data Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Show Data Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

showsPrecIntDataShowS Source #

showDataString Source #

showList ∷ [Data] → ShowS Source #

EncCBOR Data Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

encCBORDataEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy DataSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Data] → Size Source #

Eq Data Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

(==)DataDataBool Source #

(/=)DataDataBool Source #

Ord Data Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

compareDataDataOrdering Source #

(<)DataDataBool Source #

(<=)DataDataBool Source #

(>)DataDataBool Source #

(>=)DataDataBool Source #

maxDataDataData Source #

minDataDataData Source #

HashAlgorithm hashAlgo ⇒ HasTrace (CR hashAlgo Map Data) () Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Associated Types

type BaseEnv (CR hashAlgo Map Data) Source #

Methods

interpretSTSHasCallStackBaseEnv (CR hashAlgo Map Data) → BaseM (CR hashAlgo Map Data) a → a Source #

envGen ∷ () → Gen (Environment (CR hashAlgo Map Data)) Source #

sigGen ∷ () → Environment (CR hashAlgo Map Data) → State (CR hashAlgo Map Data) → Gen (Signal (CR hashAlgo Map Data)) Source #

shrinkSignalSignal (CR hashAlgo Map Data) → [Signal (CR hashAlgo Map Data)] Source #

type BaseEnv (CR hashAlgo Map Data) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

type BaseEnv (CR hashAlgo Map Data) = ()

newtype Id Source #

Constructors

Id 

Fields

Instances

Instances details
Arbitrary Id Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

arbitraryGen Id Source #

shrinkId → [Id] Source #

Show Id Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

showsPrecIntIdShowS Source #

showIdString Source #

showList ∷ [Id] → ShowS Source #

EncCBOR Id Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

encCBORIdEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy IdSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Id] → Size Source #

Eq Id Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

(==)IdIdBool Source #

(/=)IdIdBool Source #

Ord Id Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

compareIdIdOrdering Source #

(<)IdIdBool Source #

(<=)IdIdBool Source #

(>)IdIdBool Source #

(>=)IdIdBool Source #

maxIdIdId Source #

minIdIdId Source #

data CRPredicateFailure hashAlgo (hashToDataMap ∷ TypeTypeType) commitData Source #

Constructors

InvalidReveal Data 
AlreadyComitted (Hash hashAlgo Data) 

Instances

Instances details
Show (CRPredicateFailure hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

showsPrecIntCRPredicateFailure hashAlgo hashToDataMap commitData → ShowS Source #

showCRPredicateFailure hashAlgo hashToDataMap commitData → String Source #

showList ∷ [CRPredicateFailure hashAlgo hashToDataMap commitData] → ShowS Source #

Eq (CRPredicateFailure hashAlgo hashToDataMap commitData) Source # 
Instance details

Defined in Test.Control.State.Transition.Examples.CommitReveal

Methods

(==)CRPredicateFailure hashAlgo hashToDataMap commitData → CRPredicateFailure hashAlgo hashToDataMap commitData → Bool Source #

(/=)CRPredicateFailure hashAlgo hashToDataMap commitData → CRPredicateFailure hashAlgo hashToDataMap commitData → Bool Source #

prop_qc_UniqueDataProperty Source #

Check that unique data is generated. This is supposed to fail, since there's nothing in the STS that prevents two commits of the same data. The resulting minimal counterexample should be a trace of the form:

commit (hash d0) -> reveal d0 -> commit (hash d0)

where it shouldn't be possible to shrink d0 any further.

prop_qc_OnlyValidSignalsProperty Source #

Check that only valid signals are generated.

This property should fail since the generators don't check that the generated commits are unique. The resulting minimal counterexample should be a trace of the form:

commit (hash d0) -> commit (hash d0)

where it shouldn't be possible to shrink d0 any further.