cardano-ledger-shelley-test-1.10.0.0: Test helpers from cardano-ledger-shelley exposed to other packages
Safe HaskellNone
LanguageHaskell2010

Test.Cardano.Ledger.Shelley.Generator.EraGen

Description

Infrastructure for generating STS Traces over any Era

Synopsis

Documentation

genUtxo0 ∷ EraGen era ⇒ GenEnv c era → Gen (UTxO era) Source #

genesisId ∷ TxId Source #

We share this dummy TxId as genesis transaction id across eras

class (EraBlockBody era, ShelleyEraTxBody era, Split (Value era), ScriptClass era, EraPParams era, MinGenTxout era, Default (StashedAVVMAddresses era), EraCertState era) ⇒ EraGen era where Source #

Methods

genGenesisValue ∷ GenEnv c era → Gen (Value era) Source #

Generate a genesis value for the Era

genEraTwoPhase3Arg ∷ [TwoPhase3ArgInfo era] Source #

A list of three-phase scripts that can be chosen for payment when building a transaction

genEraTwoPhase2Arg ∷ [TwoPhase2ArgInfo era] Source #

A list of two-phase scripts that can be chosen for Delegating, Minting, or Rewarding when building a transaction

genEraTxBody ∷ GenEnv c era → UTxO era → PParams era → SlotNo → Set TxIn → StrictSeq (TxOut era) → StrictSeq (TxCert era) → Withdrawals → Coin → StrictMaybe (Update era) → StrictMaybe TxAuxDataHash → Gen (TxBody 'TopTx era, [Script era]) Source #

Given some pre-generated data, generate an era-specific TxBody, and a list of additional scripts for eras that sometimes require additional script witnessing.

genEraAuxiliaryData ∷ Constants → Gen (StrictMaybe (TxAuxData era)) Source #

Generate era-specific auxiliary data

updateEraTxBody Source #

Arguments

∷ UTxO era 
→ PParams era 
→ TxWits era 
→ TxBody 'TopTx era 
→ Coin 
→ Set TxIn

This overrides the existing TxFee

→ TxOut era

This is to be Unioned with the existing TxIn

→ TxBody 'TopTx era

This is to be Appended to the end of the existing TxOut

Update an era-specific TxBody

addInputs ∷ TxBody 'TopTx era → Set TxIn → TxBody 'TopTx era Source #

Union the TxIn with the existing TxIn in the TxBody

genEraPParamsUpdate ∷ Constants → PParams era → Gen (PParamsUpdate era) Source #

genEraPParams ∷ Constants → Gen (PParams era) Source #

genEraTxWits ∷ (UTxO era, TxBody 'TopTx era, ScriptInfo era) → Set (WitVKey 'Witness) → Map ScriptHash (Script era) → TxWits era Source #

genEraGoodTxOut ∷ TxOut era → Bool Source #

constructTx ∷ TxBody 'TopTx era → TxWits era → StrictMaybe (TxAuxData era) → Tx 'TopTx era Source #

Construct a transaction given its constituent parts.

genEraScriptCost ∷ PParams era → Script era → Coin Source #

compute the delta cost of an additional script on per Era basis.

genEraDone ∷ UTxO era → PParams era → Tx 'TopTx era → Gen (Tx 'TopTx era) Source #

A final opportunity to tweak things when the generator is done. Possible uses 1) Add tracing when debugging on a per Era basis

genEraTweakBlock ∷ PParams era → Seq (Tx 'TopTx era) → Gen (Seq (Tx 'TopTx era)) Source #

A final opportunity to tweak things at the block level. Possible uses 2) Run a test that might decide to discard the test, because we got unlucky, and a rare unfixible condition has occurred.

hasFailedScripts ∷ Tx 'TopTx era → Bool Source #

feeOrCollateral ∷ Tx 'TopTx era → UTxO era → Coin Source #

Instances

Instances details
EraGen ShelleyEra Source # 
Instance details

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

Methods

genGenesisValue ∷ GenEnv c ShelleyEra → Gen (Value ShelleyEra) Source #

genEraTwoPhase3Arg ∷ [TwoPhase3ArgInfo ShelleyEra] Source #

genEraTwoPhase2Arg ∷ [TwoPhase2ArgInfo ShelleyEra] Source #

genEraTxBody ∷ GenEnv c ShelleyEra → UTxO ShelleyEra → PParams ShelleyEra → SlotNo → Set TxIn → StrictSeq (TxOut ShelleyEra) → StrictSeq (TxCert ShelleyEra) → Withdrawals → Coin → StrictMaybe (Update ShelleyEra) → StrictMaybe TxAuxDataHash → Gen (TxBody 'TopTx ShelleyEra, [Script ShelleyEra]) Source #

genEraAuxiliaryData ∷ Constants → Gen (StrictMaybe (TxAuxData ShelleyEra)) Source #

updateEraTxBody ∷ UTxO ShelleyEra → PParams ShelleyEra → TxWits ShelleyEra → TxBody 'TopTx ShelleyEra → Coin → Set TxIn → TxOut ShelleyEra → TxBody 'TopTx ShelleyEra Source #

addInputs ∷ TxBody 'TopTx ShelleyEra → Set TxIn → TxBody 'TopTx ShelleyEra Source #

genEraPParamsUpdate ∷ Constants → PParams ShelleyEra → Gen (PParamsUpdate ShelleyEra) Source #

genEraPParams ∷ Constants → Gen (PParams ShelleyEra) Source #

genEraTxWits ∷ (UTxO ShelleyEra, TxBody 'TopTx ShelleyEra, ScriptInfo ShelleyEra) → Set (WitVKey 'Witness) → Map ScriptHash (Script ShelleyEra) → TxWits ShelleyEra Source #

genEraGoodTxOut ∷ TxOut ShelleyEra → Bool Source #

constructTx ∷ TxBody 'TopTx ShelleyEra → TxWits ShelleyEra → StrictMaybe (TxAuxData ShelleyEra) → Tx 'TopTx ShelleyEra Source #

genEraScriptCost ∷ PParams ShelleyEra → Script ShelleyEra → Coin Source #

genEraDone ∷ UTxO ShelleyEra → PParams ShelleyEra → Tx 'TopTx ShelleyEra → Gen (Tx 'TopTx ShelleyEra) Source #

genEraTweakBlock ∷ PParams ShelleyEra → Seq (Tx 'TopTx ShelleyEra) → Gen (Seq (Tx 'TopTx ShelleyEra)) Source #

hasFailedScripts ∷ Tx 'TopTx ShelleyEra → Bool Source #

feeOrCollateral ∷ Tx 'TopTx ShelleyEra → UTxO ShelleyEra → Coin Source #

type MinLEDGER_STS era = (Environment (EraRule "LEDGERS" era) ~ ShelleyLedgersEnv era, BaseM (EraRule "LEDGER" era) ~ ShelleyBase, Signal (EraRule "LEDGER" era) ~ StAnnTx 'TopTx era, State (EraRule "LEDGER" era) ~ LedgerState era, Environment (EraRule "LEDGER" era) ~ LedgerEnv era, BaseM (EraRule "LEDGERS" era) ~ ShelleyBase, State (EraRule "LEDGERS" era) ~ LedgerState era, Signal (EraRule "LEDGERS" era) ~ Seq (Tx 'TopTx era), STS (EraRule "LEDGER" era)) Source #

Minimal requirements on the LEDGER and LEDGERS instances

type MinCHAIN_STS era = (STS (CHAIN era), BaseM (CHAIN era) ~ ShelleyBase, Environment (CHAIN era) ~ (), State (CHAIN era) ~ ChainState era, Signal (CHAIN era) ~ Block (BHeader MockCrypto) era) Source #

Minimal requirements on the CHAIN instances

type MinUTXO_STS era = (STS (EraRule "UTXOW" era), BaseM (EraRule "UTXOW" era) ~ ShelleyBase, State (EraRule "UTXOW" era) ~ UTxOState era, Environment (EraRule "UTXOW" era) ~ UtxoEnv era, Signal (EraRule "UTXOW" era) ~ StAnnTx 'TopTx era, State (EraRule "UTXO" era) ~ UTxOState era, Environment (EraRule "UTXO" era) ~ UtxoEnv era, Signal (EraRule "UTXO" era) ~ StAnnTx 'TopTx era) Source #

Minimal requirements on the UTxO instances

data Label t where Source #

Constructors

Body' ∷ ∀ era. Label (TxBody 'TopTx era) 
Wits' ∷ ∀ era. Label (TxWits era) 

class Sets (x ∷ Label t) y where Source #

Methods

set ∷ Label t → y → y Source #

someKeyPairs ∷ Constants → (Int, Int) → Gen KeyPairs Source #

Select between _lower_ and _upper_ keys from keyPairs

allScripts ∷ EraGen era ⇒ Constants → [(Script era, Script era)] Source #

A list of all possible kinds of scripts in the current Era. Might include Keylocked scripts, Start-Finish Timelock scripts, Quantified scripts (All, Any, MofN), Plutus Scripts Note that genEraTwoPhase3Arg and genEraTwoPhase2Arg may be the empty list ([]) in some Eras.

mkDummyHash ∷ (HashAlgorithm h, EncCBOR a) ⇒ a → Hash h b Source #

It is possible to use a hash of a binary representation of any type as a source of randomness, since hash value by its definiteion is uniformly distributed.