From 71adeccfbf33d6e0cb0d83b0d3602ea81550a03b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 23 Jun 2023 13:21:24 +0930 Subject: [PATCH] pytest: fix reconnect flake in test_plugin_connected_hook_chaining ``` l1.rpc.reject(l3.info['id']) l2.connect(l1) l1.daemon.wait_for_logs([ f"peer_connected_logger_a {l2id}", f"{l2id} is allowed", f"peer_connected_logger_b {l2id}" ]) assert len(l1.rpc.listpeers(l2id)['peers']) == 1 > l3.connect(l1) tests/test_plugin.py:468: ... > raise RpcError(method, payload, resp['error']) E pyln.client.lightning.RpcError: RPC call failed: method: connect, payload: {'id': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'host': '127.0.0.1', 'port': 42391}, error: {'code': 402, 'message': 'disconnected during connection'} contrib/pyln-client/pyln/client/lightning.py:422: RpcError ``` Signed-off-by: Rusty Russell --- tests/test_plugin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 637f69c56..0e046a17f 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -465,7 +465,13 @@ def test_plugin_connected_hook_chaining(node_factory): ]) assert len(l1.rpc.listpeers(l2id)['peers']) == 1 - l3.connect(l1) + # If reject happens fast enough, connect fails with "disconnected + # during connection" + try: + l3.connect(l1) + except RpcError as err: + assert "disconnected during connection" in err.error + l1.daemon.wait_for_logs([ f"peer_connected_logger_a {l3id}", f"{l3id} is in reject list"