Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Strategy for Generic Tests Make the GenState include a Mode of the NewEpochState, modify the ModelNewEpochState to reflect what we generated.
Synopsis
- data GenEnv era = GenEnv {}
- type GenRS era = RWST (GenEnv era) () (GenState era) Gen
- data GenState era = GenState {
- gsValidityInterval ∷ !ValidityInterval
- gsKeys ∷ !(Map (KeyHash 'Witness) (KeyPair 'Witness))
- gsScripts ∷ !(Map ScriptHash (Script era))
- gsPlutusScripts ∷ !(Map (ScriptHash, PlutusPurposeTag) (IsValid, Script era))
- gsDatums ∷ !(Map DataHash (Data era))
- gsVI ∷ !(Map ValidityInterval (Set ScriptHash))
- gsModel ∷ !(ModelNewEpochState era)
- gsInitialUtxo ∷ !(Map TxIn (TxOut era))
- gsInitialRewards ∷ !(Map (Credential 'Staking) Coin)
- gsInitialDelegations ∷ !(Map (Credential 'Staking) (KeyHash 'StakePool))
- gsInitialPoolParams ∷ !(Map (KeyHash 'StakePool) PoolParams)
- gsInitialPoolDistr ∷ !(Map (KeyHash 'StakePool) IndividualPoolStake)
- gsStablePools ∷ !(Set (KeyHash 'StakePool))
- gsStableDelegators ∷ !(Set StakeCredential)
- gsAvoidCred ∷ !(Set (Credential 'Staking))
- gsAvoidKey ∷ !(Set (KeyHash 'StakePool))
- gsProof ∷ !(Proof era)
- gsGenEnv ∷ !(GenEnv era)
- gsSeedIdx ∷ !Int
- data GenSize = GenSize {
- treasury ∷ !Integer
- reserves ∷ !Integer
- startSlot ∷ !Word64
- slotDelta ∷ !(Word64, Word64)
- blocksizeMax ∷ !Integer
- collInputsMax ∷ !Natural
- spendInputsMax ∷ !Int
- refInputsMax ∷ !Int
- utxoChoicesMax ∷ !Int
- certificateMax ∷ !Int
- withdrawalMax ∷ !Int
- oldUtxoPercent ∷ !Int
- maxStablePools ∷ !Int
- invalidScriptFreq ∷ !Int
- regCertFreq ∷ !Int
- delegCertFreq ∷ !Int
- data PlutusPurposeTag
- plutusPurposeTags ∷ Proof era → [PlutusPurposeTag]
- mkRedeemers ∷ ∀ era. Proof era → [(PlutusPurpose AsIx era, (Data era, ExUnits))] → Redeemers era
- mkRedeemersFromTags ∷ ∀ era. Proof era → [((PlutusPurposeTag, Word32), (Data era, ExUnits))] → Redeemers era
- mkPlutusPurposePointer ∷ Proof era → PlutusPurposeTag → Word32 → PlutusPurpose AsIx era
- mkAlonzoPlutusPurposePointer ∷ ∀ era. Era era ⇒ PlutusPurposeTag → Word32 → AlonzoPlutusPurpose AsIx era
- mkConwayPlutusPurposePointer ∷ PlutusPurposeTag → Word32 → ConwayPlutusPurpose AsIx era
- elementsT ∷ (Monad (t Gen), MonadTrans t) ⇒ [t Gen b] → t Gen b
- frequencyT ∷ (Monad (t Gen), MonadTrans t) ⇒ [(Int, t Gen b)] → t Gen b
- positiveSingleDigitInt ∷ Gen Int
- nonNegativeSingleDigitInt ∷ Gen Int
- genSetElem ∷ Set a → Gen (Maybe a)
- genMapElem ∷ Map k a → Gen (Maybe (k, a))
- genMapElemWhere ∷ Map k a → Int → (k → a → Bool) → Gen (Maybe (k, a))
- genRewardVal ∷ Val v ⇒ Gen v
- genPositiveVal ∷ Val v ⇒ Gen v
- genGenState ∷ Reflect era ⇒ Proof era → GenSize → Gen (GenState era)
- genGenEnv ∷ EraPParams era ⇒ Proof era → GenSize → Gen (GenEnv era)
- genValidityInterval ∷ SlotNo → Gen ValidityInterval
- getBlocksizeMax ∷ GenState era → Integer
- getCertificateMax ∷ GenState era → Int
- getOldUtxoPercent ∷ GenState era → Int
- getRefInputsMax ∷ GenState era → Int
- getReserves ∷ GenState era → Coin
- getSlot ∷ GenState era → SlotNo
- getSlotDelta ∷ GenState era → (Word64, Word64)
- getSpendInputsMax ∷ GenState era → Int
- getTreasury ∷ GenState era → Coin
- getUtxoChoicesMax ∷ GenState era → Int
- getUtxoElem ∷ Reflect era ⇒ GenRS era (Maybe (TxIn, TxOut era))
- getUtxoTest ∷ GenRS era (TxIn → Bool)
- getCollInputsMax ∷ GenState era → Natural
- getNewPoolTest ∷ GenRS era (KeyHash 'StakePool → Bool)
- viewGenState ∷ Reflect era ⇒ Proof era → GenSize → Bool → IO ()
- initialLedgerState ∷ ∀ era. Reflect era ⇒ GenState era → LedgerState era
- modifyModel ∷ (ModelNewEpochState era → ModelNewEpochState era) → GenRS era ()
- runGenRS ∷ Reflect era ⇒ Proof era → GenSize → GenRS era a → Gen (a, GenState era)
- ioGenRS ∷ Reflect era ⇒ Proof era → GenSize → GenRS era ans → IO (ans, GenState era)
- small ∷ GenSize
- genDatumWithHash ∷ Era era ⇒ GenRS era (DataHash, Data era)
- genKeyHash ∷ GenRS era (KeyHash kr)
- genScript ∷ Reflect era ⇒ Proof era → PlutusPurposeTag → GenRS era ScriptHash
- genFreshKeyHash ∷ GenRS era (KeyHash kr)
- genCredential ∷ ∀ era kr. Reflect era ⇒ PlutusPurposeTag → GenRS era (Credential kr)
- genFreshCredential ∷ ∀ era kr. Reflect era ⇒ Int → PlutusPurposeTag → Set (Credential kr) → GenRS era (Credential kr)
- genFreshRegCred ∷ Reflect era ⇒ PlutusPurposeTag → GenRS era (Credential 'Staking)
- genPool ∷ ∀ era. Reflect era ⇒ GenRS era (KeyHash 'StakePool, PoolParams)
- genPoolParams ∷ Reflect era ⇒ KeyHash 'StakePool → GenRS era PoolParams
- genRewards ∷ Reflect era ⇒ GenRS era RewardAccounts
- genNewPool ∷ ∀ era. Reflect era ⇒ GenRS era (KeyHash 'StakePool, PoolParams, IndividualPoolStake)
- genRetirementHash ∷ ∀ era. Reflect era ⇒ GenRS era (KeyHash 'StakePool)
- initStableFields ∷ ∀ era. Reflect era ⇒ GenRS era ()
- modifyGenStateInitialUtxo ∷ (Map TxIn (TxOut era) → Map TxIn (TxOut era)) → GenRS era ()
- modifyGenStateInitialRewards ∷ (Map (Credential 'Staking) Coin → Map (Credential 'Staking) Coin) → GenRS era ()
- modifyModelCount ∷ (Int → Int) → GenRS era ()
- modifyModelIndex ∷ (Map Int TxId → Map Int TxId) → GenRS era ()
- modifyModelUTxO ∷ (Map TxIn (TxOut era) → Map TxIn (TxOut era)) → GenRS era ()
- modifyModelMutFee ∷ (Map TxIn (TxOut era) → Map TxIn (TxOut era)) → GenRS era ()
Documentation
GenState | |
|
Constants that determine how big a GenState is generated.
GenSize | |
|
data PlutusPurposeTag Source #
Instances
plutusPurposeTags ∷ Proof era → [PlutusPurposeTag] Source #
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 #
mkPlutusPurposePointer ∷ Proof era → PlutusPurposeTag → Word32 → PlutusPurpose AsIx era Source #
mkAlonzoPlutusPurposePointer ∷ ∀ era. Era era ⇒ PlutusPurposeTag → Word32 → AlonzoPlutusPurpose AsIx era Source #
frequencyT ∷ (Monad (t Gen), MonadTrans t) ⇒ [(Int, t Gen b)] → t Gen b Source #
positiveSingleDigitInt ∷ Gen Int Source #
Gen a positive single digit Int, on a skewed distribution that favors 2,3,4,5 but occasionally gets others
nonNegativeSingleDigitInt ∷ Gen Int Source #
Gen a non-negative single digit Int, on a skewed distribution that favors 2,3,4,5 but occasionally gets others
genMapElemWhere ∷ Map 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
genRewardVal ∷ Val 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
genPositiveVal ∷ Val v ⇒ Gen v Source #
Generate a non-zero value
genGenEnv ∷ EraPParams era ⇒ Proof era → GenSize → Gen (GenEnv era) Source #
Generate a random, well-formed, GenEnv
genValidityInterval ∷ SlotNo → Gen ValidityInterval Source #
Generate a transaction body validity interval which is close in proximity (less than a stability window) from the current slot.
getBlocksizeMax ∷ GenState era → Integer Source #
getCertificateMax ∷ GenState era → Int Source #
getOldUtxoPercent ∷ GenState era → Int Source #
getRefInputsMax ∷ GenState era → Int Source #
getReserves ∷ GenState era → Coin Source #
getSpendInputsMax ∷ GenState era → Int Source #
getTreasury ∷ GenState era → Coin Source #
getUtxoChoicesMax ∷ GenState era → Int Source #
getUtxoElem ∷ Reflect 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.
getCollInputsMax ∷ GenState era → Natural Source #
getNewPoolTest ∷ GenRS era (KeyHash 'StakePool → Bool) 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.
viewGenState ∷ Reflect era ⇒ Proof era → GenSize → Bool → IO () Source #
Helper function for development and debugging in ghci
initialLedgerState ∷ ∀ era. Reflect era ⇒ GenState era → LedgerState era Source #
modifyModel ∷ (ModelNewEpochState era → ModelNewEpochState era) → GenRS era () Source #
ioGenRS ∷ Reflect era ⇒ Proof era → GenSize → GenRS era ans → IO (ans, GenState era) Source #
Should not be used in tests, this is a helper function to be used in ghci only!
genKeyHash ∷ GenRS era (KeyHash kr) Source #
genScript ∷ Reflect era ⇒ Proof era → PlutusPurposeTag → GenRS era ScriptHash Source #
genFreshKeyHash ∷ GenRS era (KeyHash kr) Source #
genCredential ∷ ∀ era kr. Reflect era ⇒ PlutusPurposeTag → GenRS 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 ⇒ Int → PlutusPurposeTag → Set (Credential kr) → GenRS era (Credential kr) Source #
genFreshRegCred ∷ Reflect era ⇒ PlutusPurposeTag → GenRS era (Credential 'Staking) Source #
genPoolParams ∷ Reflect era ⇒ KeyHash 'StakePool → GenRS era PoolParams Source #
genRewards ∷ Reflect era ⇒ GenRS era RewardAccounts 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.
modifyGenStateInitialRewards ∷ (Map (Credential 'Staking) Coin → Map (Credential 'Staking) Coin) → GenRS era () Source #