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 (EraCrypto era)) (KeyPair 'Witness (EraCrypto era)))
- gsScripts ∷ !(Map (ScriptHash (EraCrypto era)) (Script era))
- gsPlutusScripts ∷ !(Map (ScriptHash (EraCrypto era), PlutusPurposeTag) (IsValid, Script era))
- gsDatums ∷ !(Map (DataHash (EraCrypto era)) (Data era))
- gsVI ∷ !(Map ValidityInterval (Set (ScriptHash (EraCrypto era))))
- gsModel ∷ !(ModelNewEpochState era)
- gsInitialUtxo ∷ !(Map (TxIn (EraCrypto era)) (TxOut era))
- gsInitialRewards ∷ !(Map (Credential 'Staking (EraCrypto era)) Coin)
- gsInitialDelegations ∷ !(Map (Credential 'Staking (EraCrypto era)) (KeyHash 'StakePool (EraCrypto era)))
- gsInitialPoolParams ∷ !(Map (KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era)))
- gsInitialPoolDistr ∷ !(Map (KeyHash 'StakePool (EraCrypto era)) (IndividualPoolStake (EraCrypto era)))
- gsStablePools ∷ !(Set (KeyHash 'StakePool (EraCrypto era)))
- gsStableDelegators ∷ !(Set (StakeCredential (EraCrypto era)))
- gsAvoidCred ∷ !(Set (Credential 'Staking (EraCrypto era)))
- gsAvoidKey ∷ !(Set (KeyHash 'StakePool (EraCrypto era)))
- 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 (EraCrypto era), TxOut era))
- getUtxoTest ∷ GenRS era (TxIn (EraCrypto era) → Bool)
- getCollInputsMax ∷ GenState era → Natural
- getNewPoolTest ∷ GenRS era (KeyHash 'StakePool (EraCrypto era) → 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 (EraCrypto era), Data era)
- genKeyHash ∷ Reflect era ⇒ GenRS era (KeyHash kr (EraCrypto era))
- genScript ∷ Reflect era ⇒ Proof era → PlutusPurposeTag → GenRS era (ScriptHash (EraCrypto era))
- genFreshKeyHash ∷ Reflect era ⇒ GenRS era (KeyHash kr (EraCrypto era))
- genCredential ∷ ∀ era kr. Reflect era ⇒ PlutusPurposeTag → GenRS era (Credential kr (EraCrypto era))
- genFreshCredential ∷ ∀ era kr. Reflect era ⇒ Int → PlutusPurposeTag → Set (Credential kr (EraCrypto era)) → GenRS era (Credential kr (EraCrypto era))
- genFreshRegCred ∷ Reflect era ⇒ PlutusPurposeTag → GenRS era (Credential 'Staking (EraCrypto era))
- genPool ∷ ∀ era. Reflect era ⇒ GenRS era (KeyHash 'StakePool (EraCrypto era), PoolParams (EraCrypto era))
- genPoolParams ∷ Reflect era ⇒ KeyHash 'StakePool (EraCrypto era) → GenRS era (PoolParams (EraCrypto era))
- genRewards ∷ Reflect era ⇒ GenRS era (RewardAccounts (EraCrypto era))
- genNewPool ∷ ∀ era. Reflect era ⇒ GenRS era (KeyHash 'StakePool (EraCrypto era), PoolParams (EraCrypto era), IndividualPoolStake (EraCrypto era))
- genRetirementHash ∷ ∀ era. Reflect era ⇒ GenRS era (KeyHash 'StakePool (EraCrypto era))
- initStableFields ∷ ∀ era. Reflect era ⇒ GenRS era ()
- modifyGenStateInitialUtxo ∷ (Map (TxIn (EraCrypto era)) (TxOut era) → Map (TxIn (EraCrypto era)) (TxOut era)) → GenRS era ()
- modifyGenStateInitialRewards ∷ (Map (Credential 'Staking (EraCrypto era)) Coin → Map (Credential 'Staking (EraCrypto era)) Coin) → GenRS era ()
- modifyModelCount ∷ (Int → Int) → GenRS era ()
- modifyModelIndex ∷ (Map Int (TxId (EraCrypto era)) → Map Int (TxId (EraCrypto era))) → GenRS era ()
- modifyModelUTxO ∷ (Map (TxIn (EraCrypto era)) (TxOut era) → Map (TxIn (EraCrypto era)) (TxOut era)) → GenRS era ()
- modifyModelMutFee ∷ (Map (TxIn (EraCrypto era)) (TxOut era) → Map (TxIn (EraCrypto era)) (TxOut era)) → GenRS era ()
Documentation
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 (EraCrypto era), 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 (EraCrypto era) → 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!
genScript ∷ Reflect era ⇒ Proof era → PlutusPurposeTag → GenRS era (ScriptHash (EraCrypto era)) Source #
genCredential ∷ ∀ era kr. Reflect era ⇒ PlutusPurposeTag → GenRS era (Credential kr (EraCrypto era)) 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 (EraCrypto era)) → GenRS era (Credential kr (EraCrypto era)) Source #
genFreshRegCred ∷ Reflect era ⇒ PlutusPurposeTag → GenRS era (Credential 'Staking (EraCrypto era)) Source #
genPool ∷ ∀ era. Reflect era ⇒ GenRS era (KeyHash 'StakePool (EraCrypto era), PoolParams (EraCrypto era)) Source #
genPoolParams ∷ Reflect era ⇒ KeyHash 'StakePool (EraCrypto era) → GenRS era (PoolParams (EraCrypto era)) Source #
genRewards ∷ Reflect era ⇒ GenRS era (RewardAccounts (EraCrypto era)) Source #
genNewPool ∷ ∀ era. Reflect era ⇒ GenRS era (KeyHash 'StakePool (EraCrypto era), PoolParams (EraCrypto era), IndividualPoolStake (EraCrypto era)) 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 (EraCrypto era)) (TxOut era) → Map (TxIn (EraCrypto era)) (TxOut era)) → GenRS era () Source #
modifyGenStateInitialRewards ∷ (Map (Credential 'Staking (EraCrypto era)) Coin → Map (Credential 'Staking (EraCrypto era)) Coin) → GenRS era () Source #
modifyModelIndex ∷ (Map Int (TxId (EraCrypto era)) → Map Int (TxId (EraCrypto era))) → GenRS era () Source #