merge bitcoin#26553: Fix intermittent failure in rpc_net.py

This commit is contained in:
Kittywhiskers Van Gogh 2024-10-15 07:11:47 +00:00
parent 5bf245b4a0
commit 1bf135bbc9
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
2 changed files with 5 additions and 3 deletions

View File

@ -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")

View File

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