kernel: add `btck_set_mock_time` for testing time-dependent paths #35496

pull stringintech wants to merge 1 commits into bitcoin:master from stringintech:2026/06/kernel-mocktime changing 4 files +71 −0
  1. stringintech commented at 3:09 PM on June 9, 2026: contributor

    Some kernel paths read the current time (e.g. header validation's future-time check, and the btck_SynchronizationState carried by btck_NotifyBlockTip / btck_NotifyHeaderTip callbacks), which makes them awkward to exercise deterministically in tests. This PR exposes btck_set_mock_time as a wrapper over the existing SetMockTime, mirroring what the node has via the setmocktime RPC.

    Prior IRC discussion: https://gnusha.org/bitcoin-kernel/2026-06-04.log

  2. DrahtBot added the label Validation on Jun 9, 2026
  3. DrahtBot commented at 3:09 PM on June 9, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK sedited

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #30342 (kernel, logging: Pass Logger instances to kernel objects 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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. stringintech force-pushed on Jun 9, 2026
  5. DrahtBot added the label CI failed on Jun 9, 2026
  6. DrahtBot commented at 3:13 PM on June 9, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task No wallet: https://github.com/bitcoin/bitcoin/actions/runs/27215802797/job/80356864067</sub> <sub>LLM reason (✨ experimental): CI failed due to a build linker error: test_kernel couldn’t link because NodeClock::now() had undefined references.</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  7. stringintech marked this as a draft on Jun 9, 2026
  8. sedited commented at 3:28 PM on June 9, 2026: contributor

    Interesting, Concept ACK.

  9. stringintech force-pushed on Jun 9, 2026
  10. stringintech marked this as ready for review on Jun 9, 2026
  11. stringintech commented at 6:27 PM on June 9, 2026: contributor

    Force-pushed: the test now verifies the effect through the kernel API instead of reading Now<NodeSeconds>() directly. Depending on the build configuration, g_mock_time can end up duplicated between libbitcoinkernel and the test binary, so the test's read and the kernel's write hit different globals and the assertion fails even if the link issue is resolved by linking bitcoin_util into test_kernel.

  12. kernel: add `btck_set_mock_time` for testing time-dependent paths
    Some kernel paths read the current time (e.g. header validation's future-time check, and the `btck_SynchronizationState` carried by `btck_NotifyBlockTip` / `btck_NotifyHeaderTip` callbacks), which makes them awkward to exercise deterministically in tests. This commit exposes `btck_set_mock_time` as a wrapper over the existing `SetMockTime`, mirroring what the node has via the `setmocktime` RPC.
    142d7110cc
  13. stringintech force-pushed on Jun 9, 2026
  14. DrahtBot removed the label CI failed on Jun 9, 2026

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-06-10 04:51 UTC

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