Skip to content

Commit

Permalink
merge bitcoin#26553: Fix intermittent failure in rpc_net.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Oct 16, 2024
1 parent 5bf245b commit 1bf135b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions test/functional/rpc_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_getpeerinfo(self):
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")
Expand Down Expand Up @@ -155,7 +155,8 @@ def test_getpeerinfo(self):
"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")
Expand Down
3 changes: 2 additions & 1 deletion test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@ def num_test_p2p_connections(self):
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()

Expand Down

0 comments on commit 1bf135b

Please sign in to comment.