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

Test.Cardano.Ledger.Shelley.Generator.Core

Synopsis

Documentation

data AllIssuerKeys c (r ∷ KeyRole) Source #

Instances

Instances details
(Show (SignKeyVRF (VRF c)), Show (VerKeyVRF (VRF c)), Show (VerKeyKES (KES c))) ⇒ Show (AllIssuerKeys c r) 
Instance details

Defined in Test.Cardano.Protocol.TPraos.Create

Methods

showsPrecIntAllIssuerKeys c r → ShowS #

showAllIssuerKeys c r → String #

showList ∷ [AllIssuerKeys c r] → ShowS #

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

Methods

showsPrecIntVRFKeyPair c → ShowS #

showVRFKeyPair c → String #

showList ∷ [VRFKeyPair c] → ShowS #

data KESKeyPair c Source #

Constructors

KESKeyPair 

Instances

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

Defined in Test.Cardano.Protocol.Crypto.KES

Methods

showsPrecIntKESKeyPair c → ShowS #

showKESKeyPair c → String #

showList ∷ [KESKeyPair c] → ShowS #

data GenEnv era Source #

Generator environment.

Constructors

GenEnv 

Instances

Instances details
(EraGen era, EraGov era, EraUTxO 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, 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, 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 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

Methods

showsPrecIntScriptSpace era → ShowS #

showScriptSpace era → String #

showList ∷ [ScriptSpace era] → ShowS #

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 #

showKeySpace era → String #

showList ∷ [KeySpace era] → ShowS #

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 

findPayKeyPairAddrAddrMap (KeyHash 'Payment) (KeyPair 'Payment) → KeyPair 'Payment 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 ∷ ∀ kr. Credential kr → Map (KeyHash kr) (KeyPair kr) → KeyPair kr 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 'WitnessMap ScriptHash (Script era, Script era) → (Script era, Script era) Source #

Find matching multisig scripts for a credential.

findStakeScriptFromCredCredential 'WitnessMap ScriptHash (Script era, Script era) → (Script era, Script era) Source #

Find first matching script for a credential.

findPayScriptFromAddr ∷ ∀ era. AddrMap ScriptHash (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] → 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 → [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%).

pickStakeKeyKeyPairsGen (VKey 'Staking) Source #

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

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

mkBlock Source #

Arguments

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

Hash of previous block

AllIssuerKeys c 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 c

Operational certificate

Block (BHeader c) era 

mkBlockFakeVRF Source #

Arguments

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

Hash of previous block

AllIssuerKeys c 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 c

Operational certificate

Block (BHeader c) era 

Create a block with a faked VRF result.

mkOCert ∷ ∀ c (r ∷ KeyRole). Crypto 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

Methods

showsPrecIntRawSeedShowS #

showRawSeedString #

showList ∷ [RawSeed] → ShowS #

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 #

(/=)RawSeedRawSeedBool #

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

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

mkGenKeyRawSeed → (SignKeyDSIGN DSIGN, VKey kd) 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.

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

Find the preallocated Script from its Hash.