Merge bitcoin/bitcoin#32092: test: Fix intermittent issue in p2p_orphan_handling.py

fa310cc6f499e3e3dd58dc382e04e9db3f02bc3b test: Fix intermittent issue in p2p_orphan_handling.py (MarcoFalke)

Pull request description:

  The test may fail intermittently when the `net` thread is lagging while calling `DeleteNode`. This may result in a split `getdata`, meaning that `peer2.wait_for_parent_requests([int(parent_peekaboo_AB["txid"], 16), int(parent_missing["txid"], 16)])` fails.

  Fix it by adding a sync on the `net` thread.

  Fixes #31700

ACKs for top commit:
  mzumsande:
    Code Review ACK fa310cc6f499e3e3dd58dc382e04e9db3f02bc3b

Tree-SHA512: e4a58093ab5b9e280c479b845fecb5d228e65519ea3dc2111b393202225fd0feded423e8812452454b6b9348cb37a9c1b01b9d1b1802e9f4aa76b9e56b4b54ef
This commit is contained in:
merge-script 2025-03-21 13:46:11 +08:00
commit 85feb094d4
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1
2 changed files with 3 additions and 1 deletions

View File

@ -789,6 +789,7 @@ class OrphanHandlingTest(BitcoinTestFramework):
# Disconnect peer1. peer2 should become the new candidate for orphan resolution.
peer1.peer_disconnect()
self.wait_until(lambda: node.num_test_p2p_connections() == 1)
peer2.sync_with_ping() # Sync with the 'net' thread which completes the disconnection fully
node.bumpmocktime(TXREQUEST_TIME_SKIP)
self.wait_until(lambda: len(node.getorphantxs(verbosity=2)[0]["from"]) == 1)
# Both parents should be requested, now that they are both missing.

View File

@ -826,7 +826,8 @@ class TestNode():
def disconnect_p2ps(self):
"""Close all p2p connections to the node.
Use only after each p2p has sent a version message to ensure the wait works."""
The state of the peers (such as txrequests) may not be fully cleared
yet, even after this method returns."""
for p in self.p2ps:
p.peer_disconnect()
del self.p2ps[:]