Skip to content

Commit

Permalink
fixup test races due to feature negotiation, change output cost
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed May 31, 2023
1 parent 1c203aa commit 50b913b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/test_bookkeeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,13 @@ def _check_events(node, channel_id, exp_events):

# l1 events
exp_events = [('channel_open', open_amt * 1000 + lease_fee, 0),
('onchain_fee', 1224000, 0),
('onchain_fee', 1320000, 0),
('lease_fee', 0, lease_fee),
('journal_entry', 0, invoice_msat)]
_check_events(l1, channel_id, exp_events)

exp_events = [('channel_open', open_amt * 1000, 0),
('onchain_fee', 796000, 0),
('onchain_fee', 892000, 0),
('lease_fee', lease_fee, 0),
('journal_entry', invoice_msat, 0)]
_check_events(l2, channel_id, exp_events)
Expand Down
8 changes: 7 additions & 1 deletion tests/test_closing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
scriptpubkey_addr, calc_lease_fee,
check_utxos_channel, anchor_expected, check_coin_moves,
check_balance_snaps, mine_funding_to_announce, check_inspect_channel,
first_scid
first_scid, expected_peer_features
)

import os
Expand Down Expand Up @@ -1070,6 +1070,9 @@ def test_channel_lease_lessor_cheat(node_factory, bitcoind, chainparams):
# start l2 and force close channel with l1 while l1 is still offline
l2.start()
sync_blockheight(bitcoind, [l2])
# wait for reconnect, otherwise anysegwit feature bits won't be known
wait_for(lambda: len(l2.rpc.listpeers()['peers']) == 1)
wait_for(lambda: l2.rpc.listpeers()['peers'][0].get('features', "") == expected_peer_features())
l2.rpc.close(l1.info['id'], 1, force_lease_closed=True)
bitcoind.generate_block(1, wait_for_mempool=1)

Expand Down Expand Up @@ -1147,6 +1150,9 @@ def test_channel_lease_lessee_cheat(node_factory, bitcoind, chainparams):
# start l1 and force close channel with l2 while l2 is still offline
l1.start()
sync_blockheight(bitcoind, [l1])
# wait for reconnect, otherwise anysegwit feature bits won't be known
wait_for(lambda: len(l1.rpc.listpeers()['peers']) == 1)
wait_for(lambda: l1.rpc.listpeers()['peers'][0].get('features', "") expected_peer_features())
l1.rpc.close(l2.info['id'], 1, force_lease_closed=True)
bitcoind.generate_block(1, wait_for_mempool=1)

Expand Down
4 changes: 4 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,10 @@ def test_reconnect_no_update(node_factory, executor, bitcoind):

# For closingd reconnection
l1.daemon.start()
# wait for reconnect, otherwise anysegwit feature bits won't be known
wait_for(lambda: len(l1.rpc.listpeers()['peers']) == 1)
wait_for(lambda: l1.rpc.listpeers()['peers'][0].get('features', "") == expected_peer_features())

# Close will trigger the -WIRE_SHUTDOWN and we then wait for the
# automatic reconnection to trigger the retransmission.
l1.rpc.close(l2.info['id'], 0)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,8 @@ def test_v2_replay_bookkeeping(node_factory, bitcoind):
ev_tags = [e['tag'] for e in l1.rpc.bkpr_listaccountevents(chan_id)['events']]
assert 'lease_fee' in ev_tags

wait_for(lambda: len(l1.rpc.listpeers()['peers']) == 1)
wait_for(lambda: l1.rpc.listpeers()['peers'][0].get('features', "") == expected_peer_features())
l1.rpc.close(l2.info['id'], 1)
bitcoind.generate_block(6, wait_for_mempool=1)

Expand Down
3 changes: 3 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,9 @@ def test_coin_movement_notices(node_factory, bitcoind, chainparams):
chanid_1 = first_channel_id(l2, l1)
chanid_3 = first_channel_id(l2, l3)

# Wait until we have the expected features loaded before sending to taproot address
wait_for(lambda: len(l2.rpc.listpeers()['peers']) == 2)
wait_for(lambda: [x.get("features", None) for x in l2.rpc.listpeers()['peers']] == [expected_peer_features()] * 2)
l2.rpc.close(chan1)
l2.daemon.wait_for_logs([
' to CLOSINGD_COMPLETE',
Expand Down

0 comments on commit 50b913b

Please sign in to comment.