test: melt with real routing fees on regtest - #1103
Open
orangeshyguy21 wants to merge 6 commits into
Open
Conversation
Add melt tests that pay invoices from nodes the mint has no direct channel to, so payments route through lnd-1 and incur a real routing fee. The routed destination differs per backend: lnd-2 for LND-backed mints, cln-1 for CLN-backed. The invoice helper waits for gossip to propagate first, since CLN nodes take up to a minute after boot to learn non-adjacent nodes. Existing zero-fee tests are unchanged.
Replace the callable-based gossip wait with a command-and-key helper, drop the multi-line docstrings and wrapped comments, and use the existing .copy()/.extend() idiom and SLEEP_TIME constant. Assertion messages now match the short Title-case style used elsewhere in the suite. No behavior change.
Add melt tests that pay invoices from nodes the mint has no direct channel to, so payments route through lnd-1 and incur a real routing fee. The routed destination differs per backend: lnd-2 for LND-backed mints, cln-1 for CLN-backed. A 1000 sat melt costs 1001 msat, which also covers the mint rounding sub-sat fees up to the next sat. The invoice helper waits for gossip to propagate first, since CLN nodes take up to a minute after boot to learn non-adjacent nodes. Existing zero-fee tests are unchanged.
The wallet-level routed melt test now also checks the melt response state and payment preimage instead of only the balance, matching what the mint-level test asserts.
Assert fee bounds on the db-persisted fee_paid instead of a value derived from the change, so the fee-reserve limit check can actually fail, and verify the change compensates exactly for the unspent reserve. Drop a tautological balance assert from the wallet-side test, which has no independent fee signal to bound against.
❌ 1 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Wait until the mint's node can compute a route (queryroutes/getroute) instead of only seeing the destination's node announcement, which races channel-policy gossip on fresh CI environments and caused NO_ROUTE failures. Skip the exact fee-rounding test on CLN backends, whose randomized pathfinding may pick a costlier route than the assertion assumes.
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.
Testing
Real routing fees
New melt tests pay invoices the mint can only reach through lnd-1, so every payment carries a real routing fee. Covered at both the mint API and wallet level; existing zero-fee tests are unchanged.
Sub-sat fee rounding
A 1000 sat melt costs 1001 msat. Asserts the mint rounds up to 2 sat and returns 18 sat change from the 20 sat reserve.
Fee accounting
Fee bounds are checked against the db
fee_paid, and the change must equal the unspent reserve exactly.Routed-invoice helper
get_real_invoice_routedpicks the destination per backend (lnd-2 for LND mints, cln-1 for CLN) and waits for gossip to propagate before quoting. Replaces the unusedget_unconnected_node_uri.No changes to the regtest environment are needed. In the existing
cashu-regtest-enviromenttopology, every mint node already peers directly with lnd-1, and the routed destinations sit one hop behind it.Note
The exact-fee assertions assume the environment's default lnd forwarding policy (1000 msat base + 1 ppm).