test: make p2p_handshake robust against timeoffset warnings #29704

pull stickies-v wants to merge 1 commits into bitcoin:master from stickies-v:2024-03/patch-p2p-handshake changing 1 files +7 −2
  1. stickies-v commented at 2:46 PM on March 22, 2024: contributor

    The new p2p_handshake test requires that limited nodes are not peered with when the node's system time exceeds ~ 24h of the node's chaintip timestamp, as per PeerManagerImpl::GetDesirableServiceFlags.

    By patching this test to modify the timestamp of the chaintip as opposed to mocking the node's system time, we make it resilient to future commits where the node raises a warning if it detects its system time is too much out of sync with its outbound peers.

    Resolves a silent merge conflict in #29623, that is changing the warning behaviour when significant time differences with outbound peers are detected, failing the test as it's currently in master.

    Considerations/alternatives I've thought of:

    • could add self.setup_clean_chain = True to self.set_test_params(), to avoid creating a new tip with a (much) older date, but it doesn't seem to matter?
    • could avoid using setmocktime altogether and instead use create_block instead, but that seems like it'll be a lot more verbose and I don't think it's worth it?

    Big thanks to theStack for his time in discussing this with me offline.

  2. test: make p2p_handshake robust against timeoffset warnings
    The test requires that limited nodes are not peered with  when
    the node's system time exceeds ~ 24h of the node's chaintip
    timestamp, as per PeerManagerImpl::GetDesirableServiceFlags.
    
    By patching this test to modify the timestamp of the chaintip as
    opposed to mocking the node's system time, we make it resilient
    to future commits where the node raises a warning if it detects
    its system time is too much out of sync with its outbound peers.
    
    See https://github.com/bitcoin/bitcoin/pull/29623
    032a597482
  3. DrahtBot commented at 2:46 PM on March 22, 2024: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK maflcko, theStack, brunoerg, BrandonOdiwuor

    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 Mar 22, 2024
  5. maflcko commented at 3:27 PM on March 22, 2024: member

    lgtm ACK 032a59748295859845b2a9181ceb1c4ae70bae5c

    A third alternative might be to restart the node after each test to drop the state, but that seems fragile.

  6. maflcko commented at 3:28 PM on March 22, 2024: member

    Please don't @ (ping) in the OP, which ends up in the merge commit messeage

  7. theStack approved
  8. theStack commented at 3:38 PM on March 22, 2024: contributor

    ACK 032a59748295859845b2a9181ceb1c4ae70bae5c

  9. brunoerg approved
  10. brunoerg commented at 4:07 PM on March 22, 2024: contributor

    crACK 032a59748295859845b2a9181ceb1c4ae70bae5c

  11. BrandonOdiwuor approved
  12. BrandonOdiwuor commented at 5:39 PM on March 22, 2024: contributor

    Code Review ACK 032a59748295859845b2a9181ceb1c4ae70bae5c

  13. fanquake merged this on Mar 22, 2024
  14. fanquake closed this on Mar 22, 2024

  15. stickies-v deleted the branch on Mar 22, 2024
  16. bitcoin locked this on Mar 22, 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: 2026-04-19 03:13 UTC

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