From c0a40b37a7809adf868f49f33e2cece3ed7cf08d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 7 Apr 2021 06:35:35 +0930 Subject: [PATCH] pytest: fix flake in test_pay_disconnect Channel can be inactive before it disconnects, apparently. Check explicitly for the disconnected state so we get the expected error. Here's what happened: ``` # Can't pay while its offline. with pytest.raises(RpcError, match=r'failed: WIRE_TEMPORARY_CHANNEL_FAILURE \(First peer not ready\)'): > l1.rpc.sendpay(route, rhash) E Failed: DID NOT RAISE ``` And the logs show that the outgoing HTLC was sent to channeld before it realized the connection was closed. Signed-off-by: Rusty Russell --- tests/test_pay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pay.py b/tests/test_pay.py index 356b5f7aa..69f09d2b4 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -249,7 +249,7 @@ def test_pay_disconnect(node_factory, bitcoind): route = l1.rpc.getroute(l2.info['id'], 123000, 1)["route"] l2.stop() - wait_for(lambda: [c['active'] for c in l1.rpc.listchannels()['channels']] == [False, False]) + wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected'] is False) # Can't pay while its offline. with pytest.raises(RpcError, match=r'failed: WIRE_TEMPORARY_CHANNEL_FAILURE \(First peer not ready\)'):