test: Use operator<< for time_points instead of manual TickSinceEpoch
What changed, and why it matters
This is a minor cleanup commit in Bitcoin Core's test code only. It replaces a manual time-comparison helper with a direct comparison and removes some code-comment markers related to include-file management. There is no change to production code, no security fix, and no vulnerability.
No action required. This is a non-security test-only refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies five test source files. It removes // IWYU pragma: keep comments from include directives and reorders one include. In testnet4_miner_tests.cpp, it replaces a TicksSinceEpoch<std::chrono::seconds>(...) comparison with a direct operator== comparison of std::chrono::time_point values, enabled by an added include of <test/util/common.h> which provides a streaming operator. The change is purely a test-code readability and maintainability improvement.
Changed components
src/test/blockfilter_index_tests.cppsrc/test/fuzz/package_eval.cppsrc/test/testnet4_miner_tests.cppsrc/test/validation_block_tests.cppsrc/test/validation_chainstate_tests.cppInspect captured patch +6 / −6
diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp
index 3fb273df..e9d9a409 100644
--- a/src/test/blockfilter_index_tests.cpp
+++ b/src/test/blockfilter_index_tests.cpp
@@ -19,7 +19,7 @@
#include <script/script.h>
#include <sync.h>
#include <test/util/blockfilter.h>
-#include <test/util/common.h> // IWYU pragma: keep
+#include <test/util/common.h>
#include <test/util/setup_common.h>
#include <tinyformat.h>
#include <uint256.h>
diff --git a/src/test/fuzz/package_eval.cpp b/src/test/fuzz/package_eval.cpp
index 9cb51c7d..bcf76cf3 100644
--- a/src/test/fuzz/package_eval.cpp
+++ b/src/test/fuzz/package_eval.cpp
@@ -6,7 +6,7 @@
#include <consensus/amount.h>
#include <consensus/consensus.h>
#include <consensus/validation.h>
-#include <node/mining_types.h> // IWYU pragma: keep
+#include <node/mining_types.h>
#include <policy/feerate.h>
#include <policy/packages.h>
#include <policy/policy.h>
diff --git a/src/test/testnet4_miner_tests.cpp b/src/test/testnet4_miner_tests.cpp
index 5998b5e6..ccd12cb2 100644
--- a/src/test/testnet4_miner_tests.cpp
+++ b/src/test/testnet4_miner_tests.cpp
@@ -7,6 +7,7 @@
#include <node/mining_types.h>
#include <primitives/block.h>
#include <sync.h>
+#include <test/util/common.h>
#include <test/util/setup_common.h>
#include <test/util/time.h>
#include <util/time.h>
@@ -47,8 +48,7 @@ BOOST_AUTO_TEST_CASE(MiningInterface)
BOOST_REQUIRE(block_template);
// The template should use the mocked system time
- BOOST_REQUIRE_EQUAL(TicksSinceEpoch<std::chrono::seconds>(block_template->getBlockHeader().Time()),
- TicksSinceEpoch<std::chrono::seconds>(template_time));
+ BOOST_REQUIRE_EQUAL(block_template->getBlockHeader().Time(), template_time);
const BlockWaitOptions wait_options{.timeout = MillisecondsDouble{0}, .fee_threshold = 1};
diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp
index 51aecd60..5de89376 100644
--- a/src/test/validation_block_tests.cpp
+++ b/src/test/validation_block_tests.cpp
@@ -15,7 +15,7 @@
#include <random.h>
#include <script/script.h>
#include <sync.h>
-#include <test/util/common.h> // IWYU pragma: keep
+#include <test/util/common.h>
#include <test/util/script.h>
#include <test/util/setup_common.h>
#include <txmempool.h>
diff --git a/src/test/validation_chainstate_tests.cpp b/src/test/validation_chainstate_tests.cpp
index c9110655..141c67da 100644
--- a/src/test/validation_chainstate_tests.cpp
+++ b/src/test/validation_chainstate_tests.cpp
@@ -15,8 +15,8 @@
#include <script/script.h>
#include <sync.h>
#include <test/util/chainstate.h>
-#include <test/util/common.h> // IWYU pragma: keep
#include <test/util/coins.h>
+#include <test/util/common.h>
#include <test/util/setup_common.h>
#include <tinyformat.h>
#include <uint256.h>
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.