From 1bf135bbc91d24d5f3cf947148caa37980d6c9e5 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Tue, 15 Oct 2024 07:11:47 +0000 Subject: [PATCH] merge bitcoin#26553: Fix intermittent failure in rpc_net.py --- test/functional/rpc_net.py | 5 +++-- test/functional/test_framework/test_node.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py index e8d2607763..d7d7d5d0c4 100755 --- a/test/functional/rpc_net.py +++ b/test/functional/rpc_net.py @@ -114,7 +114,7 @@ class NetTest(DashTestFramework): no_version_peer_id = 3 no_version_peer_conntime = self.mocktime with self.nodes[0].assert_debug_log([f"Added connection peer={no_version_peer_id}"]): - self.nodes[0].add_p2p_connection(P2PInterface(), send_version=False, wait_for_verack=False) + no_version_peer = self.nodes[0].add_p2p_connection(P2PInterface(), send_version=False, wait_for_verack=False) peer_info = self.nodes[0].getpeerinfo()[no_version_peer_id] peer_info.pop("addr") peer_info.pop("addrbind") @@ -155,7 +155,8 @@ class NetTest(DashTestFramework): "version": 0, }, ) - self.nodes[0].disconnect_p2ps() + no_version_peer.peer_disconnect() + self.wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 3) def test_getnettotals(self): self.log.info("Test getnettotals") diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 12f05b6ec4..fb59e6c206 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -682,7 +682,8 @@ class TestNode(): return len([peer for peer in self.getpeerinfo() if P2P_SUBVERSION % "" in peer['subver']]) def disconnect_p2ps(self): - """Close all p2p connections to the node.""" + """Close all p2p connections to the node. + Use only after each p2p has sent a version message to ensure the wait works.""" for p in self.p2ps: p.peer_disconnect()