cardano-ledger-shelley-test-1.4.0.1: Test helpers from cardano-ledger-shelley exposed to other packages
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Cardano.Ledger.Shelley.Generator.Core

Synopsis

Documentation

data AllIssuerKeys v (r ∷ KeyRole) Source #

Constructors

AllIssuerKeys 

Instances

Instances details
Crypto v ⇒ Show (AllIssuerKeys v r) 
Instance details

Defined in Test.Cardano.Protocol.TPraos.Create

data VRFKeyPair c Source #

Constructors

VRFKeyPair 

Fields

Instances

Instances details
(Show (SignKeyVRF (VRF c)), Show (VerKeyVRF (VRF c))) ⇒ Show (VRFKeyPair c) 
Instance details

Defined in Test.Cardano.Protocol.Crypto.VRF

data KESKeyPair c Source #

Constructors

KESKeyPair 

Fields

Instances

Instances details
(Show (SignKeyKES (KES c)), Show (VerKeyKES (KES c))) ⇒ Show (KESKeyPair c) 
Instance details

Defined in Test.Cardano.Protocol.Crypto.KES

data GenEnv era Source #

Generator environment.

Constructors

GenEnv 

Instances

Instances details
(EraGen era, EraGov era, EraUTxO era, Mock (EraCrypto era), MinLEDGER_STS era, Embed (EraRule "DELPL" era) (CERTS era), Environment (EraRule "DELPL" era) ~ DelplEnv era, State (EraRule "DELPL" era) ~ CertState era, Signal (EraRule "DELPL" era) ~ TxCert era, PredicateFailure (EraRule "DELPL" era) ~ ShelleyDelplPredFailure era, Embed (EraRule "DELEGS" era) (ShelleyLEDGER era), Embed (EraRule "UTXOW" era) (ShelleyLEDGER era), Environment (EraRule "UTXOW" era) ~ UtxoEnv era, State (EraRule "UTXOW" era) ~ UTxOState era, Signal (EraRule "UTXOW" era) ~ Tx era, Environment (EraRule "DELEGS" era) ~ DelegsEnv era, State (EraRule "DELEGS" era) ~ CertState era, Signal (EraRule "DELEGS" era) ~ Seq (TxCert era), ProtVerAtMost era 8) ⇒ HasTrace (ShelleyLEDGER era) (GenEnv era) Source # 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Generator.Trace.Ledger

Associated Types

type BaseEnv (ShelleyLEDGER era) Source #

(EraGen era, EraGov era, EraUTxO era, Mock (EraCrypto era), MinLEDGER_STS era, Embed (EraRule "DELPL" era) (CERTS era), Environment (EraRule "DELPL" era) ~ DelplEnv era, State (EraRule "DELPL" era) ~ CertState era, Signal (EraRule "DELPL" era) ~ TxCert era, PredicateFailure (EraRule "DELPL" era) ~ ShelleyDelplPredFailure era, Embed (EraRule "DELEG" era) (ShelleyDELPL era), Embed (EraRule "LEDGER" era) (ShelleyLEDGERS era), ProtVerAtMost era 8) ⇒ HasTrace (ShelleyLEDGERS era) (GenEnv era) Source # 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Generator.Trace.Ledger

Associated Types

type BaseEnv (ShelleyLEDGERS era) Source #

(EraGen era, Embed (EraRule "DELPL" era) (CERTS era), Environment (EraRule "DELPL" era) ~ DelplEnv era, State (EraRule "DELPL" era) ~ CertState era, Signal (EraRule "DELPL" era) ~ TxCert era, ProtVerAtMost era 8) ⇒ HasTrace (CERTS era) (GenEnv era) Source # 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Generator.Trace.TxCert

Associated Types

type BaseEnv (CERTS era) Source #

Methods

interpretSTSHasCallStackBaseEnv (CERTS era) → BaseM (CERTS era) a → a Source #

envGenGenEnv era → Gen (Environment (CERTS era)) Source #

sigGenGenEnv era → Environment (CERTS era) → State (CERTS era) → Gen (Signal (CERTS era)) Source #

shrinkSignalSignal (CERTS era) → [Signal (CERTS era)] Source #

(EraGen era, EraSegWits era, Mock (EraCrypto era), ApplyBlock era, GetLedgerView era, MinLEDGER_STS era, MinCHAIN_STS era, Embed (EraRule "BBODY" era) (CHAIN era), Environment (EraRule "BBODY" era) ~ BbodyEnv era, State (EraRule "BBODY" era) ~ ShelleyBbodyState era, Signal (EraRule "BBODY" era) ~ Block (BHeaderView (EraCrypto era)) era, Embed (EraRule "TICKN" era) (CHAIN era), Environment (EraRule "TICKN" era) ~ TicknEnv, State (EraRule "TICKN" era) ~ TicknState, Signal (EraRule "TICKN" era) ~ Bool, Embed (EraRule "TICK" era) (CHAIN era), Environment (EraRule "TICK" era) ~ (), State (EraRule "TICK" era) ~ NewEpochState era, Signal (EraRule "TICK" era) ~ SlotNo, HasTrace (EraRule "LEDGERS" era) (GenEnv era)) ⇒ HasTrace (CHAIN era) (GenEnv era) Source # 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Generator.Trace.Chain

Associated Types

type BaseEnv (CHAIN era) Source #

Methods

interpretSTSHasCallStackBaseEnv (CHAIN era) → BaseM (CHAIN era) a → a Source #

envGenGenEnv era → Gen (Environment (CHAIN era)) Source #

sigGenGenEnv era → Environment (CHAIN era) → State (CHAIN era) → Gen (Signal (CHAIN era)) Source #

shrinkSignalSignal (CHAIN era) → [Signal (CHAIN era)] Source #

data ScriptSpace era Source #

Constructors

ScriptSpace 

Fields

Instances

Instances details
Show (Script era) ⇒ Show (ScriptSpace era) Source # 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Generator.Core

data TwoPhase3ArgInfo era Source #

Constructors

TwoPhase3ArgInfo 

Fields

Instances

Instances details
Show (Script era) ⇒ Show (TwoPhase3ArgInfo era) Source # 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Generator.Core

data TwoPhase2ArgInfo era Source #

Constructors

TwoPhase2ArgInfo 

Fields

Instances

Instances details
Show (Script era) ⇒ Show (TwoPhase2ArgInfo era) Source # 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Generator.Core

data KeySpace era Source #

Collection of all keys which are required to generate a trace.

These are the _only_ keys which should be involved in the trace.

Constructors

KeySpace_ 

Fields

Instances

Instances details
(Era era, Show (Script era)) ⇒ Show (KeySpace era) Source # 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Generator.Core

Methods

showsPrecIntKeySpace era → ShowS Source #

showKeySpace era → String Source #

showList ∷ [KeySpace era] → ShowS Source #

newtype NatNonce Source #

We provide our own nonces to mkBlock, which we then wish to recover as the output of the VRF functions. In general, however, we just derive them from a natural. Since the nonce is a hash, we do not want to recover it to find a preimage. In testing, therefore, we just wrap the raw natural, which we then encode into the fake VRF implementation.

Constructors

NatNonce Natural 

findPayKeyPairAddr ∷ ∀ era. Addr (EraCrypto era) → Map (KeyHash 'Payment (EraCrypto era)) (KeyPair 'Payment (EraCrypto era)) → KeyPair 'Payment (EraCrypto era) Source #

Find first matching key pair for address. Returns the matching key pair where the first element of the pair matched the hash in addr.

findPayKeyPairCred ∷ ∀ era kr. Credential kr (EraCrypto era) → Map (KeyHash kr (EraCrypto era)) (KeyPair kr (EraCrypto era)) → KeyPair kr (EraCrypto era) Source #

Find first matching key pair for a credential. Returns the matching key pair where the first element of the pair matched the hash in addr.

findPayScriptFromCred ∷ ∀ era. Credential 'Witness (EraCrypto era) → Map (ScriptHash (EraCrypto era)) (Script era, Script era) → (Script era, Script era) Source #

Find matching multisig scripts for a credential.

findStakeScriptFromCredCredential 'Witness (EraCrypto era) → Map (ScriptHash (EraCrypto era)) (Script era, Script era) → (Script era, Script era) Source #

Find first matching script for a credential.

findPayScriptFromAddr ∷ ∀ era. Addr (EraCrypto era) → Map (ScriptHash (EraCrypto era)) (Script era, Script era) → (Script era, Script era) Source #

Find first matching multisig script for an address.

genCoinListIntegerIntegerIntGen [Coin] Source #

Generates a list of Coin values of length between lower and upper and with values between minCoin and maxCoin.

genNaturalNaturalNaturalGen Natural Source #

Generator for a natural number between lower and upper

genWord64Word64Word64Gen Word64 Source #

Generator for a Word64 between lower and upper

genTxOut ∷ ∀ era. EraTxOut era ⇒ Gen (Value era) → [Addr (EraCrypto era)] → Gen [TxOut era] Source #

Generates a list of coins for the given Addr and produced a TxOut for each Addr

Note: we need to keep the initial utxo coin sizes large enough so that when we simulate sequences of transactions, we have enough funds available to include certificates that require deposits.

genesisCoinsTxId (EraCrypto era) → [TxOut era] → UTxO era Source #

Creates the UTxO for a new ledger with the specified genesis TxId and transaction outputs.

increasingProbabilityAtGen a → (a, a) → Gen a Source #

Generate values the given distribution in 90% of the cases, and values at the bounds of the range in 10% of the cases.

This can be used to generate enough extreme values. The exponential and linear distributions provided by hedgehog will generate a small percentage of these (0-1%).

pickStakeKeyKeyPairs c → Gen (VKey 'Staking c) Source #

Select one random verification staking key from list of pairs of KeyPair.

mkCred ∷ ∀ c (kr ∷ KeyRole). Crypto c ⇒ KeyPair kr c → Credential kr c Source #

unitIntervalToNaturalUnitIntervalNatural Source #

Deprecated: This function has been made private in cardano-protocol-tpraos:testlib. Open an issue if you need it

Try to map the unit interval to a natural number. We don't care whether this is surjective. But it should be right inverse to fromNatural - that is, one should be able to recover the UnitInterval value used here.

mkBlock Source #

Arguments

∷ ∀ era (r ∷ KeyRole). (EraSegWits era, Signable (VRF (EraCrypto era)) Seed, Signable (KES (EraCrypto era)) (BHBody (EraCrypto era))) 
HashHeader (EraCrypto era)

Hash of previous block

AllIssuerKeys (EraCrypto era) r

All keys in the stake pool

→ [Tx era]

Transactions to record

SlotNo

Current slot

BlockNo

Block numberchain lengthchain "difficulty"

Nonce

EpochNo nonce

Word

Period of KES (key evolving signature scheme)

Word

KES period of key registration

OCert (EraCrypto era)

Operational certificate

Block (BHeader (EraCrypto era)) era 

mkBlockHeader Source #

Arguments

Mock c 
ProtVer 
HashHeader c

Hash of previous block

AllIssuerKeys c r

All keys in the stake pool

SlotNo

Current slot

BlockNo

Block numberchain lengthchain "difficulty"

Nonce

EpochNo nonce

Word

Period of KES (key evolving signature scheme)

Word

KES period of key registration

OCert c

Operational certificate

Word32

Block size

Hash c EraIndependentBlockBody

Block body hash

BHeader c 

Deprecated: In favor of mkBHeader and mkBHBody

mkBlockFakeVRF Source #

Arguments

∷ ∀ era (r ∷ KeyRole). (EraSegWits era, Signable (VRF (EraCrypto era)) (WithResult Seed), Signable (KES (EraCrypto era)) (BHBody (EraCrypto era))) 
HashHeader (EraCrypto era)

Hash of previous block

AllIssuerKeys (EraCrypto era) r

All keys in the stake pool

→ [Tx era]

Transactions to record

SlotNo

Current slot

BlockNo

Block number/chain length/chain "difficulty"

Nonce

EpochNo nonce

NatNonce

Block nonce

UnitInterval

Praos leader value

Word

Period of KES (key evolving signature scheme)

Word

KES period of key registration

OCert (EraCrypto era)

Operational certificate

Block (BHeader (EraCrypto era)) era 

Create a block with a faked VRF result.

mkOCert ∷ ∀ c (r ∷ KeyRole). (Crypto c, Signable (DSIGN c) (OCertSignable c)) ⇒ AllIssuerKeys c r → Word64KESPeriodOCert c Source #

getKESPeriodRenewalNoAllIssuerKeys h r → KESPeriodInteger Source #

Takes a sequence of KES hot keys and checks to see whether there is one whose range contains the current KES period. If so, return its index in the list of hot keys.

tooLateInEpochSlotNoBool Source #

True if the given slot is within the last `2 * stabilityWindow` slots of the current epoch.

data RawSeed Source #

Instances

Instances details
Arbitrary RawSeed 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Arbitrary

Show RawSeed 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Arbitrary

EncCBOR RawSeed Source # 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Utils

Methods

encCBORRawSeedEncoding Source #

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

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

Eq RawSeed 
Instance details

Defined in Test.Cardano.Ledger.Shelley.Arbitrary

Methods

(==)RawSeedRawSeedBool Source #

(/=)RawSeedRawSeedBool Source #

mkKeyPair ∷ ∀ c kd. DSIGNAlgorithm (DSIGN c) ⇒ RawSeed → (SignKeyDSIGN (DSIGN c), VKey kd c) Source #

For testing purposes, generate a deterministic key pair given a seed.

mkGenKeyDSIGNAlgorithm (DSIGN c) ⇒ RawSeed → (SignKeyDSIGN (DSIGN c), VKey kd c) Source #

For testing purposes, generate a deterministic genesis key pair given a seed.

genesisAccountStateAccountState Source #

Account with empty treasury

type PreAlonzo era = TxWits era ~ ShelleyTxWits era Source #

For use in the Serialisation and Example Tests, which assume Shelley, Allegra, or Mary Eras.

hashData ∷ ∀ era. Era era ⇒ Data → DataHash (EraCrypto era) Source #

findPlutus ∷ ∀ era. Era era ⇒ GenEnv era → ScriptHash (EraCrypto era) → (Script era, StrictMaybe (DataHash (EraCrypto era))) Source #

Find the preallocated Script from its Hash.