mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 21:52:53 +02:00
35a814a045test: Limit clocks to one active instance (MarcoFalke)55e402ffefscripted-diff: Rename NodeClockContext to FakeNodeClock (seduless)1e9546fcf4test: Use NodeClockContext in more call sites (seduless)758fea59a8test: Drop ++ from NodeClockContext default constructor (seduless)7c2ec3949atest: Enter mocktime before peer creation in block_relay_only_eviction (seduless) Pull request description: Follow-up to #34858 Updates remaining `SetMockTime` call sites that are clean, mechanical swaps fitting the spirit of the original PR (see: https://github.com/bitcoin/bitcoin/pull/34858#pullrequestreview-4031647119 and https://github.com/bitcoin/bitcoin/pull/34858#issuecomment-4221757881). Further updates to `SetMockTime` are more complex and deserve separate, isolated PRs. The default constructor for `NodeClockContext` increments to the next tick, which is a defensive measure to prevent time going backwards on construction. This has caused some confusion (see thread: https://github.com/bitcoin/bitcoin/pull/34858#discussion_r3057648646) and can be safely removed after updating the only test where this is load-bearing (b3c9bd7f2df230525c8e339394a315a2c500055d) (see: https://github.com/bitcoin/bitcoin/pull/34858#discussion_r3091085328). The removal also tightens the `addrman_tests/addrman_evictionworks` test to sit exactly on the `ADDRMAN_REPLACEMENT` boundary (4h), catching mutations such as: ```diff diff --git a/src/addrman.cpp b/src/addrman.cpp index d3dae59ae7..d0929c62cb 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -920,3 +920,3 @@ void AddrManImpl::ResolveCollisions_() // Has successfully connected in last X hours - if (current_time - info_old.m_last_success < ADDRMAN_REPLACEMENT) { + if (current_time - info_old.m_last_success <= ADDRMAN_REPLACEMENT) { erase_collision = true; ``` The last follow-up item is updating `NodeClockContext` to `FakeNodeClock` to make it clear it is intended for testing (motivated by https://github.com/bitcoin/bitcoin/pull/34858#pullrequestreview-4082110904 and supported in https://github.com/bitcoin/bitcoin/pull/34858#issuecomment-4214352770). ACKs for top commit: maflcko: re-ACK35a814a045🛒 sedited: ACK35a814a045Tree-SHA512: ade776e288a4b7bbc4c8855c14d61381b5b20329fe1e72fee87f773e47a9519975d58c277fbacda37dd73c0c1d4ce358c92dcdc4ca049d58cb3453ddf751b45b