Copyright | (c) 2023 GYELD GMBH |
---|---|
License | Apache 2.0 |
Maintainer | [email protected] |
Stability | develop |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
GeniusYield.Test.Utils
Description
Synopsis
- data Run a
- testRun ∷ String → (Wallets → Run a) → TestTree
- data Wallet = Wallet {
- walletPaymentSigningKey ∷ !GYPaymentSigningKey
- walletNetworkId ∷ !GYNetworkId
- walletName ∷ !WalletName
- data Wallets = Wallets {}
- newWallet ∷ String → GYValue → RandT StdGen Run Wallet
- runWallet ∷ Wallet → GYTxMonadRun a → Run (Maybe a)
- runWallet' ∷ Wallet → GYTxMonadRun a → Run a
- walletAddress ∷ Wallet → GYAddress
- walletPubKeyHash ∷ Wallet → GYPubKeyHash
- balance ∷ HasAddress a ⇒ a → GYTxMonadRun GYValue
- withBalance ∷ HasAddress a ⇒ String → a → GYTxMonadRun b → GYTxMonadRun (b, GYValue)
- withWalletBalancesCheck ∷ [(Wallet, GYValue)] → GYTxMonadRun a → GYTxMonadRun a
- withWalletBalancesCheckSimple ∷ [(Wallet, GYValue)] → GYTxMonadRun a → GYTxMonadRun a
- getBalance ∷ HasCallStack ⇒ Wallet → Run GYValue
- getBalances ∷ HasCallStack ⇒ [Wallet] → Run [GYValue]
- runWithWalletBalancesCheck ∷ HasCallStack ⇒ Wallets → [(Wallets → Wallet, GYValue)] → Run a → Run a
- waitUntilSlot ∷ GYSlot → GYTxMonadRun ()
- waitNSlotsGYTxMonad ∷ Integer → GYTxMonadRun ()
- findLockedUtxosInBody ∷ Num a ⇒ GYNetworkId → GYAddress → Tx → Maybe [a]
- utxosInBody ∷ GYTxQueryMonad m ⇒ Tx → GYTxId → m [Maybe GYUTxO]
- addRefScript ∷ GYAddress → GYValidator 'PlutusV2 → GYTxMonadRun (Maybe GYTxOutRef)
- expectInsufficientFunds ∷ Wallet → GYTxSkeleton v → Run ()
- addRefInput ∷ Bool → GYAddress → GYDatum → GYTxMonadRun (Maybe GYTxOutRef)
- fakeGold ∷ FromFakeCoin a ⇒ a
- fakeIron ∷ FromFakeCoin a ⇒ a
- afterAllSucceed ∷ TestTree → TestTree → TestTree
- feesFromLovelace ∷ Integer → GYValue
- withMaxQCTests ∷ Int → TestTree → TestTree
- pattern (:=) ∷ x → y → (x, y)
Documentation
State monad wrapper to run blockchain.
testRun ∷ String → (Wallets → Run a) → TestTree #
Given a test name, runs the trace for every wallet, checking there weren't errors.
Testing Wallet representation.
Constructors
Wallet | |
Fields
|
Available wallets.
Constructors
Wallets | |
newWallet ∷ String → GYValue → RandT StdGen Run Wallet #
Given a name and an initial fund, create a testing wallet.
runWallet ∷ Wallet → GYTxMonadRun a → Run (Maybe a) #
Runs a GYTxMonadRun
action using the given wallet.
runWallet' ∷ Wallet → GYTxMonadRun a → Run a #
walletAddress ∷ Wallet → GYAddress #
Gets a GYAddress of a testing wallet.
walletPubKeyHash ∷ Wallet → GYPubKeyHash #
Gets a GYPubKeyHash of a testing wallet.
balance ∷ HasAddress a ⇒ a → GYTxMonadRun GYValue #
Gets the balance from anything that HasAddress
. The usual case will be a
testing wallet.
withBalance ∷ HasAddress a ⇒ String → a → GYTxMonadRun b → GYTxMonadRun (b, GYValue) #
Computes a GYTxMonadRun
action and returns the result and how this action
changed the balance of some Address.
withWalletBalancesCheck ∷ [(Wallet, GYValue)] → GYTxMonadRun a → GYTxMonadRun a #
Computes a GYTxMonadRun
action, checking that the Wallet
balances
change according to the input list.
Notes:
* An empty list means no checks are performed.
* The GYValue
should be negative to check if the Wallet lost those funds.
withWalletBalancesCheckSimple ∷ [(Wallet, GYValue)] → GYTxMonadRun a → GYTxMonadRun a #
Computes a GYTxMonadRun
action, checking that the Wallet
balances
change according to the input list. This is a simplified version of withWalletBalancesCheck
where the input list need not consider lovelaces required for fees & to satisfy the min ada requirements as these are added automatically. It is therefore recommended to use this function over withWalletBalancesCheck
to avoid hardcoding the lovelaces required for fees & min ada constraints.
Notes:
* An empty list means no checks are performed.
* The GYValue
should be negative to check if the Wallet lost those funds.
getBalance ∷ HasCallStack ⇒ Wallet → Run GYValue #
Given a wallet returns its balance.
getBalances ∷ HasCallStack ⇒ [Wallet] → Run [GYValue] #
Given a list of wallets returns its balances.
runWithWalletBalancesCheck ∷ HasCallStack ⇒ Wallets → [(Wallets → Wallet, GYValue)] → Run a → Run a #
waitUntilSlot ∷ GYSlot → GYTxMonadRun () #
Waits until a certain GYSlot
.
Fails if the given slot is greater than the current slot.
waitNSlotsGYTxMonad ∷ Integer → GYTxMonadRun () #
Waits N slots.
findLockedUtxosInBody ∷ Num a ⇒ GYNetworkId → GYAddress → Tx → Maybe [a] #
Returns the list of outputs of the transaction for the given address. Returns Nothing if it fails to decode an address contained in the transaction outputs.
utxosInBody ∷ GYTxQueryMonad m ⇒ Tx → GYTxId → m [Maybe GYUTxO] #
Given PSM transaction and the corresponding transaction id, gives the list of UTxOs generated by that body provided they still exist. This function is usually expected to be called immediately after the transaction's submission.
addRefScript ∷ GYAddress → GYValidator 'PlutusV2 → GYTxMonadRun (Maybe GYTxOutRef) #
Adds the given script to the given address and returns the reference for it.
expectInsufficientFunds ∷ Wallet → GYTxSkeleton v → Run () #
Expect the transaction building to fail with a BalancingErrorInsufficientFunds
error
Arguments
∷ Bool | Whether to inline this datum? |
→ GYAddress | Where to place this output? |
→ GYDatum | Our datum. |
→ GYTxMonadRun (Maybe GYTxOutRef) |
Adds an input (whose datum we'll refer later) and returns the reference to it.
fakeGold ∷ FromFakeCoin a ⇒ a #
Fake "Gold" coin to use during tests.
Can represent a GYAssetClass
or a Plutus AssetClass
fakeIron ∷ FromFakeCoin a ⇒ a #
Fake "Iron" coin to use during tests
Can represent a GYAssetClass
or a Plutus AssetClass
afterAllSucceed ∷ TestTree → TestTree → TestTree #
feesFromLovelace ∷ Integer → GYValue #
Abstraction for explicitly building a Value representing the fees of a transaction.
withMaxQCTests ∷ Int → TestTree → TestTree #
Adjust the number of QuickCheck cases to generate.