Skip to content

Make maxIterations injectable to test FeeCalculationDidNotConverge#1119

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/sub-pr-1106
Draft

Make maxIterations injectable to test FeeCalculationDidNotConverge#1119
Copilot wants to merge 2 commits intomasterfrom
copilot/sub-pr-1106

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

The FeeCalculationDidNotConverge error path in calcMinFeeRecursive was untestable without a transaction that genuinely fails to converge in 50 iterations (practically impossible with realistic protocol parameters).

Changes

  • Fee.hs: Extracted the implementation into calcMinFeeRecursiveWith :: Int -> ... where the Int is the iteration limit. calcMinFeeRecursive becomes a one-liner delegating to calcMinFeeRecursiveWith 50. Exported calcMinFeeRecursiveWith under -- Internal.

  • Test/Cardano/Api/Experimental.hs: Added prop_calcMinFeeRecursive_did_not_converge — calls calcMinFeeRecursiveWith 1 on a well-funded zero-fee transaction. The single iteration advances the fee (Case 3) and the counter hits 0 on the recursive call, deterministically returning FeeCalculationDidNotConverge.

prop_calcMinFeeRecursive_did_not_converge :: Property
prop_calcMinFeeRecursive_did_not_converge = H.property $ do
  (unsignedTx, utxo, changeAddr) <- H.forAll $ genFundedSimpleTx Exp.ConwayEra
  let result = calcMinFeeRecursiveWith 1 changeAddr unsignedTx utxo
                 exampleProtocolParams mempty mempty mempty 0
  case result of
    Left Exp.FeeCalculationDidNotConverge -> H.success
    other -> H.annotateShow other >> H.failure

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…vergence failure test

Co-authored-by: carbolymer <228866+carbolymer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 6, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • chap.intersectmbo.org
    • Triggering command: /usr/bin/curl /usr/bin/curl REDACTED --output /tmp/transportAdapterGet4042-7 --location --write-out %{http_code} --user-agent cabal-install/3.16.1.0 (linux; x86_64) --silent --show-error --dump-header /tmp/curl-headers4042-8.txt (dns block)
    • Triggering command: /usr/bin/curl /usr/bin/curl REDACTED --output /tmp/transportAdapterGet4385-3 --location --write-out %{http_code} --user-agent cabal-install/3.16.1.0 (linux; x86_64) --silent --show-error --dump-header /tmp/curl-headers4385-4.txt (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update recursive minimum fee calculation implementation Make maxIterations injectable to test FeeCalculationDidNotConverge Mar 6, 2026
Base automatically changed from jordan/introduce-calculate-min-fee-recursive to master March 9, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants