Skip to content

Commit 702a88d

Browse files
committed
pytest: fix flake in test_coinmoves_unilateral_htlc_fulfill / test_coinmoves_unilateral_htlc_timeout
DER sigs! Normally, the commitment weight is: ``` Anchorspend for local commit tx fee 9751sat (w=722), commit_tx fee 4866sat (w=1284): package feerate 7286 perkw Creating anchor spend for local commit tx 6a0816ca60d499edc70bfb786ebd164fb7a55d234c84d926102f5bd35087fd45: we're paying fee 9751sat ``` But if we're "lucky" the commitment tx is shorter: ``` Anchorspend for local commit tx fee 9744sat (w=722), commit_tx fee 4866sat (w=1283): package feerate 7286 perkw Creating anchor spend for local commit tx acf78532a9448dd62a4e6319a3d2712189a88b6e59abc637260067d60df70782: we're paying fee 9744sat ``` The resulting failure: ``` 2025-08-21T02:30:34.1906751Z > assert moves == expected ... ... 2025-08-21T02:30:34.1965346Z E { 2025-08-21T02:30:34.1965529Z E 'account_id': 'wallet', 2025-08-21T02:30:34.1965767Z E 'blockheight': 104, 2025-08-21T02:30:34.1965997Z E 'created_index': 6, 2025-08-21T02:30:34.1966229Z E - 'credit_msat': 15579000, 2025-08-21T02:30:34.1966467Z E ? ^^ 2025-08-21T02:30:34.1966698Z E + 'credit_msat': 15586000, 2025-08-21T02:30:34.1966927Z E ? ^^ 2025-08-21T02:30:34.1967150Z E 'debit_msat': 0, 2025-08-21T02:30:34.1967376Z E 'extra_tags': [], 2025-08-21T02:30:34.1967599Z E - 'output_msat': 15579000, 2025-08-21T02:30:34.1967832Z E ? ^^ 2025-08-21T02:30:34.1968061Z E + 'output_msat': 15586000, 2025-08-21T02:30:34.1968294Z E ? ^^ 2025-08-21T02:30:34.1968540Z E 'primary_tag': 'deposit', 2025-08-21T02:30:34.1968908Z E 'utxo': 'acf78532a9448dd62a4e6319a3d2712189a88b6e59abc637260067d60df70782:0', 2025-08-21T02:30:34.1969366Z E }, ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent f5fe10c commit 702a88d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/test_coinmoves.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,11 @@ def test_coinmoves_unilateral_htlc_timeout(node_factory, bitcoind):
727727
line = l1.daemon.is_in_log('Tracking output.*/OUR_HTLC')
728728
htlc = int(re.search(r'output [0-9a-f]{64}:([0-9]):', line).group(1))
729729

730+
# commitment tx weight can vary (DER sigs, FML) and so even though the feerate target
731+
# is fixed, the amount of the child tx we create will vary, hence the change varies.
732+
# So it's usually 15579000, but one in 128 it will be 15586000...
733+
anchor_change_msats = bitcoind.rpc.gettxout(anchor_spend_txid, 0)['value'] * 100_000_000_000
734+
730735
expected_chain1 += [{'account_id': 'wallet', # Anchor spend from fundchannel change
731736
'blockheight': 104,
732737
'credit_msat': 0,
@@ -738,10 +743,10 @@ def test_coinmoves_unilateral_htlc_timeout(node_factory, bitcoind):
738743
'utxo': f"{fundchannel['txid']}:{fundchannel['outnum'] ^ 1}"},
739744
{'account_id': 'wallet', # change from anchor spend
740745
'blockheight': 104,
741-
'credit_msat': 15579000,
746+
'credit_msat': anchor_change_msats,
742747
'debit_msat': 0,
743748
'extra_tags': [],
744-
'output_msat': 15579000,
749+
'output_msat': anchor_change_msats,
745750
'primary_tag': 'deposit',
746751
'utxo': f"{anchor_spend_txid}:0"},
747752
{'account_id': fundchannel['channel_id'],
@@ -1221,6 +1226,11 @@ def test_coinmoves_unilateral_htlc_fulfill(node_factory, bitcoind):
12211226
line = l1.daemon.is_in_log('Tracking output.*/OUR_HTLC')
12221227
htlc = int(re.search(r'output [0-9a-f]{64}:([0-9]):', line).group(1))
12231228

1229+
# commitment tx weight can vary (DER sigs, FML) and so even though the feerate target
1230+
# is fixed, the amount of the child tx we create will vary, hence the change varies.
1231+
# So it's usually 15579000, but one in 128 it will be 15586000...
1232+
anchor_change_msats = bitcoind.rpc.gettxout(anchor_spend_txid, 0)['value'] * 100_000_000_000
1233+
12241234
expected_chain1 += [{'account_id': 'wallet', # Anchor spend from fundchannel change
12251235
'blockheight': 104,
12261236
'credit_msat': 0,
@@ -1232,10 +1242,10 @@ def test_coinmoves_unilateral_htlc_fulfill(node_factory, bitcoind):
12321242
'utxo': f"{fundchannel['txid']}:{fundchannel['outnum'] ^ 1}"},
12331243
{'account_id': 'wallet', # Change from anchor spend
12341244
'blockheight': 104,
1235-
'credit_msat': 15579000,
1245+
'credit_msat': anchor_change_msats,
12361246
'debit_msat': 0,
12371247
'extra_tags': [],
1238-
'output_msat': 15579000,
1248+
'output_msat': anchor_change_msats,
12391249
'primary_tag': 'deposit',
12401250
'utxo': f"{anchor_spend_txid}:0"},
12411251
{'account_id': fundchannel['channel_id'],

0 commit comments

Comments
 (0)