@@ -10,7 +10,7 @@ import BotPlutusInterface.Types (
1010 ContractEnvironment (cePABConfig ),
1111 PABConfig (pcOwnPubKeyHash , pcProtocolParams ),
1212 )
13- import Control.Lens ((&) , (.~) , (^.) )
13+ import Control.Lens ((&) , (.~) , (<>~) , ( ^.) )
1414import Data.Default (Default (def ))
1515import Data.Map qualified as Map
1616import Data.Set qualified as Set
@@ -22,6 +22,7 @@ import Ledger.Address (Address, PaymentPubKeyHash (PaymentPubKeyHash))
2222import Ledger.Address qualified as Address
2323import Ledger.CardanoWallet qualified as Wallet
2424import Ledger.Constraints qualified as Constraints
25+ import Ledger.Constraints.OffChain qualified as OffChain
2526import Ledger.Crypto (PubKeyHash )
2627import Ledger.Scripts qualified as Scripts
2728import Ledger.Tx (
@@ -173,7 +174,7 @@ dontAddChangeToDatum = do
173174 usrTxOut' =
174175 PublicKeyChainIndexTxOut
175176 pkhAddr3
176- (Ada. lovelaceValueOf 5_000_000 )
177+ (Ada. lovelaceValueOf 1_001_000 )
177178 usrTxOut = Ledger. toTxOut usrTxOut'
178179 -- initState :: MockContractState ()
179180 initState =
@@ -189,7 +190,9 @@ dontAddChangeToDatum = do
189190 <> Constraints. ownPaymentPubKeyHash paymentPkh3
190191 txConsts =
191192 -- Pay the same datum to the script, but with more ada.
192- Constraints. mustPayToOtherScript valHash scrDatum (scrValue <> Ada. lovelaceValueOf 1_000_000 )
193+ Constraints. mustPayToOtherScript valHash scrDatum (scrValue <> Ada. lovelaceValueOf 500 )
194+ -- <> Constraints.mustPayToOtherScript valHash scrDatum (Ada.lovelaceValueOf 1_000_000)
195+ <> Constraints. mustPayToPubKey paymentPkh3 (Ada. lovelaceValueOf 1_000_000 )
193196 <> Constraints. mustSpendScriptOutput txOutRef6 Ledger. unitRedeemer
194197 <> Constraints. mustSpendPubKeyOutput txOutRef7
195198 eunbalancedTx = Constraints. mkTx @ Void scrLkups txConsts
@@ -202,12 +205,15 @@ dontAddChangeToDatum = do
202205 (Left txt) -> assertFailure (" PAB effect error: " <> Text. unpack txt)
203206 (Right (Left txt)) -> assertFailure $ " Balancing error: " <> Text. unpack txt -- <> "\n(Tx: " <> show unbalancedTx <> ")"
204207 (Right (Right trx)) -> do
205- -- TODO: Write the actual test.
208+ let scrTxOut'' = scrTxOut' & Ledger. ciTxOutValue <>~ Ada. lovelaceValueOf 500
209+ scrTxOutNew = Ledger. toTxOut scrTxOut''
206210 assertBool
207211 ( " Original UTxO not in output Tx."
208212 <> " \n Original UTxO: "
209213 <> show scrTxOut
210214 <> " \n New UTxOs: "
211215 <> show (txOutputs trx)
216+ <> " \n Unbalanced UTxOs: "
217+ <> show (txOutputs (unbalancedTx ^. OffChain. tx))
212218 )
213- (scrTxOut `elem` txOutputs trx)
219+ (scrTxOutNew `elem` txOutputs trx)
0 commit comments