Skip to content

Commit ae9eaa0

Browse files
committed
Merge bitcoin#31760: test: make sure we are on sync with a peer before checking if they have sent a message
3f4b104 test: make sure we are on sync with a peer before checking if they have sent a message (Sergi Delgado Segura) Pull request description: p2p_orphan_handling checks whether a message has not been requested slightly too soon, making the check always succeed. This passes unnoticed since the expected result is for the message to not have been received, but it will make the test not catch a relevant change that should make it fail. An easy way to check this is the case is to modify one of the test cases to force a request within the expected time, and check how the request is not seen. After the change, the test would crash as expected: ```diff index 963d92485c..30ab5f2035 100755 --- a/test/functional/p2p_orphan_handling.py +++ b/test/functional/p2p_orphan_handling.py @@ -186,9 +185,12 @@ class OrphanHandlingTest(BitcoinTestFramework): parent_inv = CInv(t=MSG_WTX, h=int(tx_parent_arrives["tx"].getwtxid(), 16)) assert_equal(len(peer_spy.get_invs()), 0) peer_spy.assert_no_immediate_response(msg_getdata([parent_inv])) + txid = 0xdeadbeef + peer_spy.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=txid)])) # Request would be scheduled with this delay because it is not a preferred relay peer. self.nodes[0].bumpmocktime(NONPREF_PEER_TX_DELAY) + peer_spy.assert_never_requested(int(txid)) peer_spy.assert_never_requested(int(tx_parent_arrives["txid"], 16)) peer_spy.assert_never_requested(int(tx_parent_doesnt_arrive["txid"], 16)) # Request would be scheduled with this delay because it is by txid. ``` It is worth noting that this is not seen in the cases where the message is expected to be received, because in such cases `assert_never_requested` is always after a `wait_....` method, which is already waiting for the node to sync on their end. ACKs for top commit: i-am-yuvi: ACK 3f4b104 instagibbs: ACK 3f4b104 glozow: ACK 3f4b104 Tree-SHA512: 321a6605d630bed2217b6374e999dbb84da14138263dd8adf65fe3a6cd7981a50c873beced9cf05cb6d747a912e91017c58e7d4323d25449c87d83095ff4cba9
2 parents a43f08c + 3f4b104 commit ae9eaa0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

test/functional/p2p_orphan_handling.py

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def assert_no_immediate_response(self, message):
113113

114114
def assert_never_requested(self, txhash):
115115
"""Check that the node has never sent us a getdata for this hash (int type)"""
116+
self.sync_with_ping()
116117
for getdata in self.getdata_received:
117118
for request in getdata.inv:
118119
assert request.hash != txhash

0 commit comments

Comments
 (0)