Skip to content

Commit 871eead

Browse files
tests: Fix test_emergencyrecover to check for ChannelReestablish
Make sure we are sending bogus channel reestablish after recovering from emergency.recover file and peer storage backup. Key Changes: - Add wait_for_log() with appropriate debug statements Sort `listclosechannels` to maintain example sequence
1 parent 6ad55e9 commit 871eead

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

tests/autogenerate-rpc-examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ def generate_list_examples(l1, l2, l3, c12, c23_2, inv_l31, inv_l32, offer_l23,
19141914
output['amount_msat'] = 201998900000 + (i * 1000) + (k * 100)
19151915
update_example(node=l1, method='listtransactions', params={}, response=listtransactions_res1)
19161916
listclosedchannels_res1 = l2.rpc.listclosedchannels()
1917-
listclosedchannels_res1 = update_list_responses(listclosedchannels_res1, list_key='closedchannels')
1917+
listclosedchannels_res1 = update_list_responses(listclosedchannels_res1, list_key='closedchannels', slice_upto=2, update_func=None, sort=True, sort_key='channel_id')
19181918
for i, closedchannel in enumerate(listclosedchannels_res1['closedchannels'], start=1):
19191919
closedchannel['last_commitment_fee_msat'] = 2894000 + (i * 1000)
19201920
closedchannel['last_commitment_txid'] = 'txidcloselastcommitment0' + (('0000' + str(i)) * 8)

tests/test_misc.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2975,6 +2975,7 @@ def test_emergencyrecoverpenaltytxn(node_factory, bitcoind):
29752975
stubs = l1.rpc.emergencyrecover()["stubs"]
29762976
assert len(stubs) == 1
29772977
assert stubs[0] == _["channel_id"]
2978+
l1.daemon.wait_for_log('Sending a bogus channel_reestablish message to make the peer unilaterally close the channel.')
29782979
l1.daemon.wait_for_log('peer_out WIRE_ERROR')
29792980

29802981
# Restarting so that L1
@@ -3022,7 +3023,10 @@ def test_emergencyrecover(node_factory, bitcoind):
30223023
listfunds = l1.rpc.listfunds()["channels"][0]
30233024
assert listfunds["short_channel_id"] == "1x1x1"
30243025

3026+
l1.daemon.wait_for_log('Sending a bogus channel_reestablish message to make the peer unilaterally close the channel.')
30253027
l1.daemon.wait_for_log('peer_out WIRE_ERROR')
3028+
3029+
l2.daemon.wait_for_log('bad reestablish commitment_number: 0')
30263030
l2.daemon.wait_for_log('State changed from CHANNELD_NORMAL to AWAITING_UNILATERAL')
30273031

30283032
bitcoind.generate_block(5, wait_for_mempool=1)
@@ -3143,7 +3147,10 @@ def test_restorefrompeer(node_factory, bitcoind):
31433147

31443148
assert l1.rpc.restorefrompeer()['stubs'][0] == _['channel_id']
31453149

3150+
l1.daemon.wait_for_log('Sending a bogus channel_reestablish message to make the peer unilaterally close the channel.')
31463151
l1.daemon.wait_for_log('peer_out WIRE_ERROR')
3152+
3153+
l2.daemon.wait_for_log('bad reestablish commitment_number: 0')
31473154
l2.daemon.wait_for_log('State changed from CHANNELD_NORMAL to AWAITING_UNILATERAL')
31483155

31493156
bitcoind.generate_block(5, wait_for_mempool=1)

0 commit comments

Comments
 (0)