Skip to content

Commit 862bee6

Browse files
committed
Assert well-funded test result is fully balanced
1 parent 8eb1dc6 commit 862bee6

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ genUnderfundedTx era = do
647647
return (Exp.makeUnsignedTx era txBodyContent, utxo, changeAddr)
648648

649649
-- | A well-funded transaction (UTxO >> output + fee) always produces a
650-
-- successful positive fee calculation.
650+
-- successful, fully balanced result with a positive fee.
651651
prop_calcMinFeeRecursive_well_funded_succeeds :: Property
652652
prop_calcMinFeeRecursive_well_funded_succeeds = H.property $ do
653653
(unsignedTx, utxo, changeAddr) <- H.forAll $ genFundedSimpleTx Exp.ConwayEra
@@ -656,6 +656,16 @@ prop_calcMinFeeRecursive_well_funded_succeeds = H.property $ do
656656
Right (Exp.UnsignedTx resultLedgerTx) -> do
657657
let resultFee = resultLedgerTx ^. L.bodyTxL . L.feeTxBodyL
658658
H.assert $ resultFee > L.Coin 0
659+
-- The resulting transaction must be fully balanced (zero balance).
660+
let balance =
661+
UnexportedLedger.evalBalanceTxBody
662+
exampleProtocolParams
663+
(const Nothing)
664+
(const Nothing)
665+
(const False)
666+
utxo
667+
(resultLedgerTx ^. L.bodyTxL)
668+
balance H.=== mempty
659669

660670
-- | 'calcMinFeeRecursive' is idempotent: applying it to its own result
661671
-- yields the same 'UnsignedTx'. This confirms the fee has reached a

0 commit comments

Comments
 (0)