test: Use NodeClockContext in more tests #34858

pull maflcko wants to merge 3 commits into bitcoin:master from maflcko:2505-elapse-time changing 13 files +66 −57
  1. maflcko commented at 8:09 am on March 19, 2026: member

    Currently mocktime is written to a global, which may leak between sub-tests (albeit some tests try to reset the mocktime on a best-effort basis). Also, when advancing it, one has to keep a counter variable around.

    Fix both issues by using the recently added NodeClockContext, which resets the mocktime once it goes out of scope. Also, it has a method to advance the mocktime by a delta.

  2. DrahtBot renamed this:
    test: Use NodeClockContext in more tests
    test: Use NodeClockContext in more tests
    on Mar 19, 2026
  3. DrahtBot added the label Tests on Mar 19, 2026
  4. DrahtBot commented at 8:09 am on March 19, 2026: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK seduless

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35003 (net_processing: improve block data I/O error handling in P2P paths by furszy)
    • #34360 (bench: add WalletBalanceManySpent for high-history wallet scenario by w0xlt)
    • #33966 (refactor: disentangle miner startup defaults from runtime options by Sjors)
    • #31682 ([IBD] specialize CheckBlock’s input & coinbase checks by l0rinc)
    • #29700 (kernel, refactor: return error status on all fatal errors by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. test: Allow time_point in boost checks
    This is required in the next commit.
    fa9f434df8
  6. fuzz: Use NodeClockContext
    This refactor is a follow-up to commit
    eeeeb2a0b902ed69b5cd5523833d3ab5d963c81f and does not change any
    behavior.
    
    However, it is nice to know that no global mocktime leaks from the fuzz
    init step to the first fuzz input, or from one fuzz input execution to
    the next.
    With the clock context, the global is re-set at the end of the context.
    fa8fe0941e
  7. test: Use NodeClockContext in more tests faad08e59c
  8. maflcko force-pushed on Mar 20, 2026
  9. seduless commented at 4:00 pm on March 30, 2026: contributor

    Tested ACK faad08e59c4419e09eb75054bf468ca98a837ca8

    nit: First commit message says “required in the next commit” but it’s the third commit that needs it (the time_point comparison in testnet4_miner_tests).

    No need to expand scope, but these are the remaining SetMockTime call sites that seem to fit the spirit of these changes. Happy to pick these up in a follow-up PR:

    • chainstate_write_tests.cpp:91
    • addrman_tests.cpp:101,112,135
    • private_broadcast_tests.cpp:29,120
    • rpc_tests.cpp:345,347
    • bench/index_blockfilter.cpp:42
    • bench/wallet_encrypt.cpp:55
  10. maflcko commented at 8:09 am on March 31, 2026: member

    Happy to pick these up in a follow-up PR:

    Ok, I’ll leave this as-is. I guess some of them were merged in between I wrote the diff and now.


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-05 12:13 UTC

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