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 <class 'pyln.client.lightning.RpcError'>
```

And the logs show that the outgoing HTLC was sent to channeld before it
realized the connection was closed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-04-07 06:35:35 +09:30
committed by Christian Decker
parent e684f87ef7
commit c0a40b37a7

View File

@@ -249,7 +249,7 @@ def test_pay_disconnect(node_factory, bitcoind):
route = l1.rpc.getroute(l2.info['id'], 123000, 1)["route"] route = l1.rpc.getroute(l2.info['id'], 123000, 1)["route"]
l2.stop() 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. # Can't pay while its offline.
with pytest.raises(RpcError, match=r'failed: WIRE_TEMPORARY_CHANNEL_FAILURE \(First peer not ready\)'): with pytest.raises(RpcError, match=r'failed: WIRE_TEMPORARY_CHANNEL_FAILURE \(First peer not ready\)'):