Add tests coverage for the transaction balancing with withdrawal#1186
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds regression coverage around fee balancing for withdrawal-funded transactions, and hardens the experimental auto-balance path to avoid an unrecoverable ledger TxOut construction failure on negative balances.
Changes:
- Add two new
calcMinFeeRecursiveHedgehog properties for withdrawal-funded balancing success/failure cases. - Add generators for withdrawal-funded transactions (including a tiny-input variant).
- Add an early non-negative balance guard in
makeTransactionBodyAutoBalancebefore constructing the initial changeTxOut.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental/Fee.hs |
Adds new generators + properties to cover withdrawal-funded balancing scenarios. |
cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs |
Adds a pre-mkBasicTxOut balance check to avoid an irrecoverable crash on negative values. |
4c33c46 to
f283dd6
Compare
f283dd6 to
6636b2e
Compare
palas
approved these changes
Apr 23, 2026
Contributor
palas
left a comment
There was a problem hiding this comment.
It all looks correct and I've verified that:
- "withdrawal-funded transaction (output > input) succeeds" fails without withdrawal
- "underfunded transaction fails with TxBodyErrorBalanceNegative" fails without the patch in
cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs
Maybe worth adding the new tests to the change-log too?
Jimbo4350
approved these changes
Apr 23, 2026
6636b2e to
3b06c0c
Compare
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
makeTransactionBodyAutoBalancenow returnsTxBodyErrorBalanceNegativewhen the transaction balance is negative, instead of crashing with anIllegal Value in TxOutruntime error fromtoCompacton a negativeCoin.Checklist
.changes/