Skip to content

Commit 866349f

Browse files
committed
small fixes
1 parent eaea4e4 commit 866349f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

docs/tasty-integration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ To assert the final `Value` which `wallet` will have after contract execution sp
126126
* `initAdaAssertValue [100] 133` - initialize `wallet` with single UTxO with 100 Ada and check that after contract execution final `Value` of all `wallet`'s UTxOs is equal to 133 Ada.
127127
* `initAndAssertLovelaceWith [1_000_000] VGt 2_000_000` - initialize `wallet` with single UTxO with 1000000 Lovelace and check that after contract execution final `Value` of all `wallet`'s UTxOs is *greater than* 2000000 Lovelace.
128128

129-
***One important note*** is that Plutip creates dedicated UTxO to be used *only* as collateral under the hood. This UTxO would normally be created by spending wallets funds, and the transaction fee and Ada amount used for collateral UTxO would mess up balance assertions. So when using assertions for `Value` it is advised to wrap `wallets` initialization with `withCollateral` function. This simply adds a small UTxO to the `wallets`'s balance during network setup that is then picked up for collateral instead avoiding the problem. Use it like so:
129+
***One important note*** is that Plutip creates dedicated UTxO to be used *only* as collateral under the hood. This UTxO would normally be created by spending wallets funds, and the transaction fee and Ada amount used for collateral UTxO would mess up balance assertions. So when using any kind of assertions for `Value` it is advised to wrap `wallets` initialization with `withCollateral` function. This simply adds a small UTxO to the `wallets`'s balance during network setup that is then picked up for collateral instead avoiding the problem. Use it like so:
130130

131131
```haskell
132132
( withCollateral $

src/Test/Plutip/Contract.hs

+8-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,13 @@ import BotPlutusInterface.Types (
141141
)
142142

143143
import Control.Arrow (left)
144-
import Control.Monad.Reader (MonadIO (liftIO), MonadReader (ask), ReaderT, runReaderT)
144+
import Control.Monad.Reader (
145+
MonadIO (liftIO),
146+
MonadReader (ask),
147+
ReaderT,
148+
runReaderT,
149+
withReaderT,
150+
)
145151
import Data.Bool (bool)
146152
import Data.Kind (Type)
147153
import Data.List.NonEmpty (NonEmpty)
@@ -329,7 +335,7 @@ withContractAs walletIdx toContract = do
329335
execRes <- liftIO $ runContract cEnv ownWallet (toContract otherWalletsPkhs)
330336

331337
-- get all the values present at the test wallets after the user given contracts has been executed.
332-
values <- liftIO $ runReaderT collectValues cEnv
338+
values <- withReaderT fst collectValues
333339

334340
case values of
335341
Left e -> fail $ "Failed to get values. Error: " ++ show e

0 commit comments

Comments
 (0)