Skip to content

Commit

Permalink
test: fix intermittent error in rpc_net.py (bitcoin#29030)
Browse files Browse the repository at this point in the history
Asserting for the debug log message "Added connection peer=" is
insufficient for ensuring that this new connection will show up in a
following getpeerinfo() call, as the debug message is written in the
CNode ctor, which means it hasn't necessarily been added to
CConnman.m_nodes at this point.

Solve this by using the recently introduced `wait_for_new_peer`
helper, which is more robust.

Fixes bitcoin#29030.
  • Loading branch information
theStack committed Dec 9, 2023
1 parent 3e69125 commit ea00f98
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/functional/rpc_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_getpeerinfo(self):
no_version_peer_id = 2
no_version_peer_conntime = int(time.time())
self.nodes[0].setmocktime(no_version_peer_conntime)
with self.nodes[0].assert_debug_log([f"Added connection peer={no_version_peer_id}"]):
with self.nodes[0].wait_for_new_peer():
no_version_peer = self.nodes[0].add_p2p_connection(P2PInterface(), send_version=False, wait_for_verack=False)
self.nodes[0].setmocktime(0)
peer_info = self.nodes[0].getpeerinfo()[no_version_peer_id]
Expand Down

0 comments on commit ea00f98

Please sign in to comment.