Skip to content

Commit 12fbb23

Browse files
rustyrussellniftynei
authored andcommitted
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 <rusty@rustcorp.com.au>
1 parent 4514d2a commit 12fbb23

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/test_closing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ def test_channel_lease_falls_behind(node_factory, bitcoind):
739739

740740
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
741741
rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount)
742-
l1.daemon.wait_for_log('disconnect')
742+
wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0)
743743
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
744744
# l1 leases a channel from l2
745745
l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,
@@ -779,7 +779,7 @@ def test_channel_lease_post_expiry(node_factory, bitcoind):
779779
# l1 leases a channel from l2
780780
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
781781
rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount)
782-
l1.daemon.wait_for_log('disconnect')
782+
wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0)
783783
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
784784
l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,
785785
feerate='{}perkw'.format(feerate),
@@ -864,7 +864,7 @@ def test_channel_lease_unilat_closes(node_factory, bitcoind):
864864

865865
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
866866
rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount)
867-
l1.daemon.wait_for_log('disconnect')
867+
wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0)
868868
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
869869
# l1 leases a channel from l2
870870
l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,
@@ -874,7 +874,7 @@ def test_channel_lease_unilat_closes(node_factory, bitcoind):
874874
# l2 leases a channel from l3
875875
l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
876876
rates = l2.rpc.dev_queryrates(l3.info['id'], amount, amount)
877-
l3.daemon.wait_for_log('disconnect')
877+
wait_for(lambda: len(l2.rpc.listpeers(l3.info['id'])['peers']) == 0)
878878
l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
879879
l2.rpc.fundchannel(l3.info['id'], amount, request_amt=amount,
880880
feerate='{}perkw'.format(feerate), minconf=0,
@@ -965,7 +965,7 @@ def test_channel_lease_lessor_cheat(node_factory, bitcoind, chainparams):
965965

966966
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
967967
rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount)
968-
l1.daemon.wait_for_log('disconnect')
968+
wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0)
969969
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
970970
# l1 leases a channel from l2
971971
l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,
@@ -1038,7 +1038,7 @@ def test_channel_lease_lessee_cheat(node_factory, bitcoind, chainparams):
10381038

10391039
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
10401040
rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount)
1041-
l1.daemon.wait_for_log('disconnect')
1041+
wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0)
10421042
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
10431043
# l1 leases a channel from l2
10441044
l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,

0 commit comments

Comments
 (0)