Skip to content

Commit ef44e3c

Browse files
committed
pytest: fix flake in test_coinmoves_unilateral_htlc_fulfill
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 <[email protected]>
1 parent dea44ef commit ef44e3c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/test_coinmoves.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,11 @@ def test_coinmoves_unilateral_htlc_fulfill(node_factory, bitcoind):
12211221
line = l1.daemon.is_in_log('Tracking output.*/OUR_HTLC')
12221222
htlc = int(re.search(r'output [0-9a-f]{64}:([0-9]):', line).group(1))
12231223

1224+
# commitment tx weight can vary (DER sigs, FML) and so even though the feerate target
1225+
# is fixed, the amount of the child tx we create will vary, hence the change varies.
1226+
# So it's usually 15579000, but one in 128 it will be 15586000...
1227+
anchor_change_msats = bitcoind.rpc.gettxout(anchor_spend_txid, 0)['value'] * 100_000_000_000
1228+
12241229
expected_chain1 += [{'account_id': 'wallet', # Anchor spend from fundchannel change
12251230
'blockheight': 104,
12261231
'credit_msat': 0,
@@ -1232,10 +1237,10 @@ def test_coinmoves_unilateral_htlc_fulfill(node_factory, bitcoind):
12321237
'utxo': f"{fundchannel['txid']}:{fundchannel['outnum'] ^ 1}"},
12331238
{'account_id': 'wallet', # Change from anchor spend
12341239
'blockheight': 104,
1235-
'credit_msat': 15579000,
1240+
'credit_msat': anchor_change_msats,
12361241
'debit_msat': 0,
12371242
'extra_tags': [],
1238-
'output_msat': 15579000,
1243+
'output_msat': anchor_change_msats,
12391244
'primary_tag': 'deposit',
12401245
'utxo': f"{anchor_spend_txid}:0"},
12411246
{'account_id': fundchannel['channel_id'],

0 commit comments

Comments
 (0)