Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
flake = false;
};
bot-plutus-interface.url =
"github:mlabs-haskell/bot-plutus-interface?ref=857ec745d50f7f0ebd5cd934110403fae301ef6f";
"github:mlabs-haskell/bot-plutus-interface?ref=5db75f0335b6c42937607006e6fe873fabbeaed8";
};

outputs =
Expand Down
12 changes: 11 additions & 1 deletion test/Spec/Integration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Plutus.Contract (
import Plutus.Contract qualified as Contract
import Spec.TestContract.AdjustTx (runAdjustTest)
import Spec.TestContract.AlwaysFail (lockThenFailToSpend)
import Spec.TestContract.LockSpendMint (lockThenSpend)
import Spec.TestContract.LockSpendMint (lockThenSpend, mintAndSendTokens)
import Spec.TestContract.SimpleContracts (
getUtxos,
getUtxosThrowsErr,
Expand Down Expand Up @@ -212,6 +212,16 @@ test =
[ shouldFail
, errorSatisfies "Fail validation with 'I always fail'" errCheck
]
, assertExecution
"Mint and send zero tokens."
(initAda [100] <> initAda [200])
(withContract $ \[pkh] -> mintAndSendTokens 0 pkh)
[shouldSucceed]
, assertExecution
"Mint and send 5 tokens."
(initAda [100] <> initAda [200])
(withContract $ \[pkh] -> mintAndSendTokens 5 pkh)
[shouldSucceed]
, -- Test `adjustUnbalancedTx`
runAdjustTest
]
Expand Down
25 changes: 23 additions & 2 deletions test/Spec/TestContract/LockSpendMint.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Spec.TestContract.LockSpendMint (lockThenSpend) where
module Spec.TestContract.LockSpendMint (lockThenSpend, mintAndSendTokens) where

import Control.Monad (void)
import Data.List.NonEmpty qualified as NonEmpty
Expand All @@ -23,14 +23,15 @@ import Ledger.Scripts qualified as Scripts
import Ledger.Typed.Scripts (TypedValidator, Validator, ValidatorTypes, mkUntypedMintingPolicy)
import Ledger.Typed.Scripts qualified as TypedScripts
import Ledger.Value (flattenValue, tokenName)
import Plutus.Contract (Contract, awaitTxConfirmed, submitTx, submitTxConstraintsWith)
import Plutus.Contract (Contract, adjustUnbalancedTx, awaitTxConfirmed, mkTxConstraints, submitTx, submitTxConstraintsWith)
import Plutus.Contract qualified as Contract
import Plutus.PAB.Effects.Contract.Builtin (EmptySchema)
import Plutus.Script.Utils.V1.Scripts qualified as ScriptUtils
import Plutus.V1.Ledger.Value qualified as Value
import PlutusTx qualified
import PlutusTx.Prelude qualified as PP
import Prelude
import Prelude qualified as Hask

lockThenSpend :: Contract () EmptySchema Text [(TxOutRef, ChainIndexTxOut)]
lockThenSpend = do
Expand Down Expand Up @@ -170,3 +171,23 @@ mintingPolicy =

currencySymbol :: CurrencySymbol
currencySymbol = ScriptUtils.scriptCurrencySymbol mintingPolicy

mintAndSendTokens :: Integer -> PaymentPubKeyHash -> Contract () EmptySchema Text ()
mintAndSendTokens n pkh = do
let token = Value.singleton currencySymbol (tokenName "ff") n

txc =
Constraints.mustMintValue token
<> Constraints.mustPayToPubKey pkh token

lkps = Constraints.plutusV1MintingPolicy mintingPolicy

utx <- mkTxConstraints @TestZeroToken lkps txc
tx <- adjustUnbalancedTx utx
Contract.submitTxConfirmed tx

data TestZeroToken

instance ValidatorTypes TestZeroToken where
type DatumType TestZeroToken = ()
type RedeemerType TestZeroToken = ()