From 12fbb23322110d49deaac00c8d8402c1a7b84282 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 18 Aug 2021 10:56:31 +0930 Subject: [PATCH] pytest: fix flake in test_channel_lease_unilat_closes We actually were waiting for l3 to disconnect, not l2. But in general we should be looking for status rather than grovelling in the logs where possible, so I changed all those. ``` 2021-08-17T04:40:34.9015538Z # l2 leases a channel from l3 2021-08-17T04:40:34.9016520Z l2.rpc.connect(l3.info['id'], 'localhost', l3.port) 2021-08-17T04:40:34.9017570Z rates = l2.rpc.dev_queryrates(l3.info['id'], amount, amount) 2021-08-17T04:40:34.9018724Z l3.daemon.wait_for_log('disconnect') 2021-08-17T04:40:34.9019851Z l2.rpc.connect(l3.info['id'], 'localhost', l3.port) 2021-08-17T04:40:34.9021467Z l2.rpc.fundchannel(l3.info['id'], amount, request_amt=amount, 2021-08-17T04:40:34.9022865Z feerate='{}perkw'.format(feerate), minconf=0, 2021-08-17T04:40:34.9024000Z > compact_lease=rates['compact_lease']) ... 2021-08-17T04:40:34.9103422Z > raise RpcError(method, payload, resp['error']) 2021-08-17T04:40:34.9106829Z E pyln.client.lightning.RpcError: RPC call failed: method: fundchannel, payload: {'id': '035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d', 'amount': 500000, 'feerate': '2000perkw', 'announce': True, 'minconf': 0, 'request_amt': 500000, 'compact_lease': '029a00640064000000644c4b40'}, error: {'code': 400, 'message': 'Unable to connect, no address known for peer', 'data': {'id': '035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d', 'method': 'connect'}} ``` Signed-off-by: Rusty Russell --- tests/test_closing.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_closing.py b/tests/test_closing.py index ffdb35c4d..18b5a5e06 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -739,7 +739,7 @@ def test_channel_lease_falls_behind(node_factory, bitcoind): l1.rpc.connect(l2.info['id'], 'localhost', l2.port) rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount) - l1.daemon.wait_for_log('disconnect') + wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) # l1 leases a channel from l2 l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount, @@ -779,7 +779,7 @@ def test_channel_lease_post_expiry(node_factory, bitcoind): # l1 leases a channel from l2 l1.rpc.connect(l2.info['id'], 'localhost', l2.port) rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount) - l1.daemon.wait_for_log('disconnect') + wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount, feerate='{}perkw'.format(feerate), @@ -864,7 +864,7 @@ def test_channel_lease_unilat_closes(node_factory, bitcoind): l1.rpc.connect(l2.info['id'], 'localhost', l2.port) rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount) - l1.daemon.wait_for_log('disconnect') + wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) # l1 leases a channel from l2 l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount, @@ -874,7 +874,7 @@ def test_channel_lease_unilat_closes(node_factory, bitcoind): # l2 leases a channel from l3 l2.rpc.connect(l3.info['id'], 'localhost', l3.port) rates = l2.rpc.dev_queryrates(l3.info['id'], amount, amount) - l3.daemon.wait_for_log('disconnect') + wait_for(lambda: len(l2.rpc.listpeers(l3.info['id'])['peers']) == 0) l2.rpc.connect(l3.info['id'], 'localhost', l3.port) l2.rpc.fundchannel(l3.info['id'], amount, request_amt=amount, feerate='{}perkw'.format(feerate), minconf=0, @@ -965,7 +965,7 @@ def test_channel_lease_lessor_cheat(node_factory, bitcoind, chainparams): l1.rpc.connect(l2.info['id'], 'localhost', l2.port) rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount) - l1.daemon.wait_for_log('disconnect') + wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) # l1 leases a channel from l2 l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount, @@ -1038,7 +1038,7 @@ def test_channel_lease_lessee_cheat(node_factory, bitcoind, chainparams): l1.rpc.connect(l2.info['id'], 'localhost', l2.port) rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount) - l1.daemon.wait_for_log('disconnect') + wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) # l1 leases a channel from l2 l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,