cardano-ledger-test-9.9.9.9: Testing harness, tests and benchmarks for Shelley style cardano ledgers
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Cardano.Ledger.Generic.GenState

Description

Strategy for Generic Tests Make the GenState include a Mode of the NewEpochState, modify the ModelNewEpochState to reflect what we generated.

Synopsis

Documentation

data GenEnv era Source #

Constructors

GenEnv 

Fields

type GenRS era = RWST (GenEnv era) () (GenState era) Gen Source #

data GenSize Source #

Constants that determine how big a GenState is generated.

Instances

Instances details
Show GenSize Source # 
Instance details

Defined in Test.Cardano.Ledger.Generic.GenState

Default GenSize Source # 
Instance details

Defined in Test.Cardano.Ledger.Generic.GenState

Methods

defGenSize Source #

data PlutusPurposeTag Source #

Instances

Instances details
Bounded PlutusPurposeTag Source # 
Instance details

Defined in Test.Cardano.Ledger.Generic.GenState

Enum PlutusPurposeTag Source # 
Instance details

Defined in Test.Cardano.Ledger.Generic.GenState

Show PlutusPurposeTag Source # 
Instance details

Defined in Test.Cardano.Ledger.Generic.GenState

Eq PlutusPurposeTag Source # 
Instance details

Defined in Test.Cardano.Ledger.Generic.GenState

Ord PlutusPurposeTag Source # 
Instance details

Defined in Test.Cardano.Ledger.Generic.GenState

mkRedeemers ∷ ∀ era. Proof era → [(PlutusPurpose AsIx era, (Data era, ExUnits))] → Redeemers era Source #

mkRedeemersFromTags ∷ ∀ era. Proof era → [((PlutusPurposeTag, Word32), (Data era, ExUnits))] → Redeemers era Source #

elementsT ∷ (Monad (t Gen), MonadTrans t) ⇒ [t Gen b] → t Gen b Source #

frequencyT ∷ (Monad (t Gen), MonadTrans t) ⇒ [(Int, t Gen b)] → t Gen b Source #

positiveSingleDigitIntGen Int Source #

Gen a positive single digit Int, on a skewed distribution that favors 2,3,4,5 but occasionally gets others

nonNegativeSingleDigitIntGen Int Source #

Gen a non-negative single digit Int, on a skewed distribution that favors 2,3,4,5 but occasionally gets others

genSetElemSet a → Gen (Maybe a) Source #

genMapElemMap k a → Gen (Maybe (k, a)) Source #

genMapElemWhereMap k a → Int → (k → a → Bool) → Gen (Maybe (k, a)) Source #

Use up to tries attempts to choose a random (k,a) pair from m, that meets predicate p

genRewardValVal v ⇒ Gen v Source #

Generate a value (which is occaisionally 0) useful in generating Rewards, where we need a few 0's, because we cannot generate a DeReg certificates, without a 0 Reg value. Also used when generating the CollReturn, where an occasional 0 would be nice

genPositiveValVal v ⇒ Gen v Source #

Generate a non-zero value

genGenStateReflect era ⇒ Proof era → GenSizeGen (GenState era) Source #

genGenEnvEraPParams era ⇒ Proof era → GenSizeGen (GenEnv era) Source #

Generate a random, well-formed, GenEnv

genValidityIntervalSlotNoGen ValidityInterval Source #

Generate a transaction body validity interval which is close in proximity (less than a stability window) from the current slot.

getUtxoElemReflect era ⇒ GenRS era (Maybe (TxIn, TxOut era)) Source #

Pick a UTxO element where we can use it in a new Tx. Most of the time we generate new elements for each Tx, but once in a while we choose an existing one. We must be carefull that that the Pay credential of the TxOut can run in the curent ValidityInterval A crude but simple way is to insist Pay credential is either Key locked, or locked with Plutus or MultiSig scripts, and return False for any Timelock scripts.

getNewPoolTestGenRS era (KeyHash 'StakePoolBool) Source #

To compute deposits we need a function that tells if the KeyHash is a new Pool Compute this function before we do any generation, since such generation may actually add to the mPoolParams, and then the added thing won't appear new.

viewGenStateReflect era ⇒ Proof era → GenSizeBoolIO () Source #

Helper function for development and debugging in ghci

initialLedgerState ∷ ∀ era. Reflect era ⇒ GenState era → LedgerState era Source #

runGenRSReflect era ⇒ Proof era → GenSizeGenRS era a → Gen (a, GenState era) Source #

ioGenRSReflect era ⇒ Proof era → GenSizeGenRS era ans → IO (ans, GenState era) Source #

Should not be used in tests, this is a helper function to be used in ghci only!

genDatumWithHashEra era ⇒ GenRS era (DataHash, Data era) Source #

genCredential ∷ ∀ era kr. Reflect era ⇒ PlutusPurposeTagGenRS era (Credential kr) Source #

Generate a credential that can be used for supplied purpose (in case of plutus scripts), while occasionally picking out randomly from previously generated set. Returns the credential Adds to both gsKeys and gsScripts and gsPlutusScript via genKeyHash and genScript

genFreshCredential ∷ ∀ era kr. Reflect era ⇒ IntPlutusPurposeTagSet (Credential kr) → GenRS era (Credential kr) Source #

genPool ∷ ∀ era. Reflect era ⇒ GenRS era (KeyHash 'StakePool, PoolParams) Source #

genNewPool ∷ ∀ era. Reflect era ⇒ GenRS era (KeyHash 'StakePool, PoolParams, IndividualPoolStake) Source #

Use this function to get a new pool that should not be used in the future transactions

initStableFields ∷ ∀ era. Reflect era ⇒ GenRS era () Source #

Initialize (or overwrite if they are not empty) the Stable fields. It is intended that this be called just once at the beginning of a trace generation.

modifyGenStateInitialUtxo ∷ (Map TxIn (TxOut era) → Map TxIn (TxOut era)) → GenRS era () Source #

modifyModelCount ∷ (IntInt) → GenRS era () Source #

modifyModelUTxO ∷ (Map TxIn (TxOut era) → Map TxIn (TxOut era)) → GenRS era () Source #

modifyModelMutFee ∷ (Map TxIn (TxOut era) → Map TxIn (TxOut era)) → GenRS era () Source #