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()