@@ -9,6 +9,7 @@ import Data.Set qualified as Set
99import Data.Text qualified as Text
1010import Ledger qualified
1111import Ledger.Ada qualified as Ada
12+ import Ledger.Ada qualified as Value
1213import Ledger.Address (Address , PaymentPubKeyHash (PaymentPubKeyHash ))
1314import Ledger.Address qualified as Address
1415import Ledger.CardanoWallet qualified as Wallet
@@ -66,7 +67,7 @@ addUtxosForFees = do
6667 ownAddr = addr1
6768 ebalancedTx =
6869 fst $
69- runPABEffectPure def $
70+ runPABEffectPure def $ do
7071 Balance. balanceTxStep @ () @ '[PABEffect () ] defaultBalanceConfig utxoIndex ownAddr tx
7172
7273 case ebalancedTx of
@@ -75,7 +76,15 @@ addUtxosForFees = do
7576
7677addUtxosForNativeTokens :: Assertion
7778addUtxosForNativeTokens = do
78- let txout = TxOut addr2 (Value. singleton " 11223344" " Token" 123 ) Nothing
79+ let minimumAdaRequired = Value. adaValueOf 1
80+ {- `minimumAdaRequired` has to be added to `txout` because
81+ balancing now decoupled from adjusting minimum Ada amount in output,
82+ and adjusting happens during `adjustUnbalancedTx` Contract
83+ effect execution *before* balancing. Adding `minimumAdaRequired`
84+ to `txout` Value aims to simulate result of `adjustUnbalancedTx` call.
85+ Note that 1 Ada is test value - real amount is determined by Ledger and can vary.
86+ -}
87+ txout = TxOut addr2 (Value. singleton " 11223344" " Token" 123 <> minimumAdaRequired) Nothing
7988 tx = mempty {txOutputs = [txout]} `withFee` 500_000
8089 utxoIndex = Map. fromList [utxo1, utxo2, utxo3, utxo4]
8190 ownAddr = addr1
0 commit comments