cardano-ledger-canonical-state-9.9.9.9: Instances for working with canonical ledger state representation
Safe HaskellNone
LanguageHaskell2010

Test.Cardano.Ledger.CanonicalState.Testlib

Description

Test suite utilities for the implementor

Synopsis

Documentation

testAllNS ∷ (ConstrNS "blocks/v0", ConstrNS "utxo/v0", ConstrNS "entities/accounts/v0", ConstrNS "entities/committee/v0", ConstrNS "entities/dreps/v0", ConstrNS "entities/stake_pools/v0", ConstrNS "entities/stake_pools/vrf_key_hashes/v0", ConstrNS "gov/committee/v0", ConstrNS "gov/constitution/v0", ConstrNS "gov/pparams/v0", ConstrNS "gov/proposals/v0", ConstrNS "gov/proposals/roots/v0") ⇒ Spec Source #

Test all supported NS for conformance with SCLS.

Hspec helpers

validateType ∷ ∀ (ns ∷ Symbol) a. (KnownSymbol ns, ToCanonicalCBOR ns a, Arbitrary a, Show a, Typeable a) ⇒ TextSpec Source #

Validate concrete type against its definition in CDDL

properties

propNamespaceEntryConformsToSpec ∷ ∀ (ns ∷ Symbol). (KnownSymbol ns, KnownNamespace ns) ⇒ NamespaceEntry ns → Bool Source #

Each value from the known namespace conforms to its spec

propTypeIsCanonical ∷ ∀ (ns ∷ Symbol) a. ToCanonicalCBOR ns a ⇒ a → IO () Source #

propNamespaceEntryRoundTrip ∷ ∀ (ns ∷ Symbol). (KnownNamespace ns, Eq (NamespaceEntry ns), Show (NamespaceEntry ns)) ⇒ NamespaceEntry ns → IO () Source #

Namespace entry are not contradictory and can roundtrip: `decode.encode.decode.encode = decode.encode`

We do not require `decode.encode=id` because we do not require input type to be in canonical form.

I.e. if we have types:

``` data V a = NoHash a | WithHash a (Maybe Hash) ```

And it's ok to decode `WithHash a Nothing` to `NoHash a`, `decode.encode=id` property will fail, because decoding will put the value in it's canonical form.

propTypeConformsToSpec ∷ ∀ (ns ∷ Symbol) a. (KnownSymbol ns, ToCanonicalCBOR ns a) ⇒ Text → a → Bool Source #

Debug tools

debugEncodeType ∷ ∀ (ns ∷ Symbol) a. ToCanonicalCBOR ns a ⇒ a → ByteString Source #

Serialize value to CBOR (for usage in debug tools)