pytest: fix test_feerate_stress race

```
2024-06-24T05:14:14.9939033Z >       l1.rpc.call('dev-feerate', [l2.info['id'], rate - 5])
2024-06-24T05:14:14.9939354Z 
2024-06-24T05:14:14.9939466Z tests/test_connection.py:3439: 
...
2024-06-24T05:14:14.9967617Z >           raise RpcError(method, payload, resp['error'])
2024-06-24T05:14:14.9968833Z E           pyln.client.lightning.RpcError: RPC call failed: method: dev-feerate, payload: ['022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 2290], error: {'code': -1, 'message': 'Peer bad state'}
```

The disconnect can actually take a while: wait for both sides to
believe they're reconnected.  Also wait a little to make sure the
feerate change doesn't create a bad signature.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2024-06-24 16:15:15 +09:30
parent bb64fc8ddc
commit f642e4e551

View File

@@ -3429,8 +3429,7 @@ def test_feerate_stress(node_factory, executor):
assert not l1.daemon.is_in_log('Bad.*signature', start=prev_log)
prev_log = len(l1.daemon.logs)
# Make sure it's reconnected, and wait for last payment.
wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'])
# Wait for last payment
# We can get TEMPORARY_CHANNEL_FAILURE due to disconnect, too.
if l1done != 0:
with pytest.raises(RpcError, match='WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS|WIRE_TEMPORARY_CHANNEL_FAILURE'):
@@ -3438,7 +3437,13 @@ def test_feerate_stress(node_factory, executor):
if l2done != 0:
with pytest.raises(RpcError, match='WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS|WIRE_TEMPORARY_CHANNEL_FAILURE'):
l2.rpc.waitsendpay("{:064x}".format(l2done - 1), timeout=TIMEOUT)
# Make sure it's reconnected, then try adjusting feerates
wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'] and l2.rpc.getpeer(l1.info['id'])['connected'])
l1.rpc.call('dev-feerate', [l2.info['id'], rate - 5])
time.sleep(1)
assert not l1.daemon.is_in_log('Bad.*signature')
assert not l2.daemon.is_in_log('Bad.*signature')