Copyright | (c) 2023 GYELD GMBH |
---|---|
License | Apache 2.0 |
Maintainer | support@geniusyield.co |
Stability | develop |
Safe Haskell | None |
Language | Haskell2010 |
GeniusYield.Test.Utils
Description
Synopsis
- data Run a
- testRun ∷ String → (Wallets → Run a) → TestTree
- data Wallet = Wallet {}
- data Wallets = Wallets {}
- newWallet ∷ String → GYValue → RandT StdGen Run Wallet
- runWallet ∷ Wallet → GYTxMonadRun a → Run (Maybe 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
- waitUntilSlot ∷ GYSlot → GYTxMonadRun ()
- findLockedUtxosInBody ∷ Num a ⇒ GYNetworkId → GYAddress → Tx → Maybe [a]
- 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
- withMaxQCTests ∷ Int → TestTree → TestTree
- pattern (:=) ∷ x → y → (x, y)
Documentation
Instances
Monad Run | |
Functor Run | |
MonadFail Run | |
Defined in Plutus.Model.Mock | |
Applicative Run | |
MonadState Mock Run | |
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 | |
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.
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 usal 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.
waitUntilSlot ∷ GYSlot → GYTxMonadRun () #
Waits until a certain GYSlot
.
Fails if the given slot is greater than the current slot.
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.
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 #
Runs the second TestTree
after all tests in the first TestTree
succeed
withMaxQCTests ∷ Int → TestTree → TestTree #
Adjust the number of QuickCheck cases to generate.