Skip to content

Commit 0dc74c9

Browse files
committed
Merge bitcoin/bitcoin#32212: test: Remove confusing and failing system time test
fadf8f0 test: Remove confusing and failing system time test (MarcoFalke) Pull request description: This was just added as a sanity check in fa01366 by myself. However, the test uses system time, so it may obviously (albeit rarely) fail. Fix it by removing it. Can be tested by running two bash loops at the same time: `while ( ./bld-cmake/bin/test_bitcoin -t util_tests/util_time_GetTime ) ; do true ; done` `while ( date -s "$(date -d 'now + 0.015 seconds' '+%Y-%m-%d %H:%M:%S.%3N')" && date -s "$(date -d 'now - 0.015 seconds' '+%Y-%m-%d %H:%M:%S.%3N')" ) ; do true ; done` Eventually, it will fail: ``` test/util_tests.cpp(595): error: in "util_tests/util_time_GetTime": check ms_0 < GetTime<std::chrono::milliseconds>() has failed test/util_tests.cpp(596): error: in "util_tests/util_time_GetTime": check us_0 < GetTime<std::chrono::microseconds>() has failed *** 2 failures are detected in the test module "Bitcoin Core Test Suite" ACKs for top commit: janb84: ACK [fadf8f0](bitcoin/bitcoin@fadf8f0) mabu44: Tested ACK fadf8f0 hebasto: ACK fadf8f0, tested on Ubuntu 24.10. Tree-SHA512: fc468546f46a12804802df4f0e64d2898aca3db4df69602e5919ac31646c2fcb1e75b614fc2d1a3959c3db10fb0e315da5886d348b41589dba7cb43e618444a1
2 parents d42e82d + fadf8f0 commit 0dc74c9

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/test/util_tests.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,18 +582,14 @@ BOOST_AUTO_TEST_CASE(util_time_GetTime)
582582
BOOST_CHECK_EQUAL(111000, TicksSinceEpoch<std::chrono::milliseconds>(NodeClock::now()));
583583
BOOST_CHECK_EQUAL(111000000, GetTime<std::chrono::microseconds>().count());
584584
}
585+
SetMockTime(0s);
585586

586-
SetMockTime(0);
587-
// Check that steady time and system time changes after a sleep
587+
// Check that steady time changes after a sleep
588588
const auto steady_ms_0 = Now<SteadyMilliseconds>();
589589
const auto steady_0 = std::chrono::steady_clock::now();
590-
const auto ms_0 = GetTime<std::chrono::milliseconds>();
591-
const auto us_0 = GetTime<std::chrono::microseconds>();
592590
UninterruptibleSleep(1ms);
593591
BOOST_CHECK(steady_ms_0 < Now<SteadyMilliseconds>());
594592
BOOST_CHECK(steady_0 + 1ms <= std::chrono::steady_clock::now());
595-
BOOST_CHECK(ms_0 < GetTime<std::chrono::milliseconds>());
596-
BOOST_CHECK(us_0 < GetTime<std::chrono::microseconds>());
597593
}
598594

599595
BOOST_AUTO_TEST_CASE(test_IsDigit)

0 commit comments

Comments
 (0)