test: make sure we are on sync with a peer before checking if they have sent a message #31760

pull sr-gi wants to merge 1 commits into bitcoin:master from sr-gi:2025-01-fix-p2p-orphan-halding-requests-check changing 1 files +1 −0
  1. sr-gi commented at 7:47 pm on January 29, 2025: member

    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:

     0index 963d92485c..30ab5f2035 100755
     1--- a/test/functional/p2p_orphan_handling.py
     2+++ b/test/functional/p2p_orphan_handling.py
     3@@ -186,9 +185,12 @@ class OrphanHandlingTest(BitcoinTestFramework):
     4         parent_inv = CInv(t=MSG_WTX, h=int(tx_parent_arrives["tx"].getwtxid(), 16))
     5         assert_equal(len(peer_spy.get_invs()), 0)
     6         peer_spy.assert_no_immediate_response(msg_getdata([parent_inv]))
     7+        txid = 0xdeadbeef
     8+        peer_spy.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=txid)]))
     9
    10         # Request would be scheduled with this delay because it is not a preferred relay peer.
    11         self.nodes[0].bumpmocktime(NONPREF_PEER_TX_DELAY)
    12+        peer_spy.assert_never_requested(int(txid))
    13         peer_spy.assert_never_requested(int(tx_parent_arrives["txid"], 16))
    14         peer_spy.assert_never_requested(int(tx_parent_doesnt_arrive["txid"], 16))
    15         # 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.

  2. test: make sure we are on sync with a peer before checking if they have sent a message
    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
    3f4b104b1b
  3. DrahtBot commented at 7:47 pm on January 29, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31760.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK i-am-yuvi, instagibbs, glozow

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  4. DrahtBot added the label Tests on Jan 29, 2025
  5. i-am-yuvi approved
  6. i-am-yuvi commented at 6:28 am on January 30, 2025: contributor
    ACK 3f4b104b1b7e1b87c0be8e395e02b6ae3c5d7b08
  7. instagibbs approved
  8. instagibbs commented at 2:44 pm on February 5, 2025: member

    ACK 3f4b104b1b7e1b87c0be8e395e02b6ae3c5d7b08

    Makes sense and can’t really hurt to apply it every time.

  9. fanquake requested review from glozow on Feb 5, 2025
  10. glozow commented at 5:00 am on February 6, 2025: member
    ACK 3f4b104b1b7e1b87c0be8e395e02b6ae3c5d7b08
  11. glozow merged this on Feb 6, 2025
  12. glozow closed this on Feb 6, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-02-22 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me