diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-04-19 13:13:21 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-05-08 11:47:45 +0200 |
commit | faa5c62967174f1dd66e8a4ba61ab29c867cf450 (patch) | |
tree | 9772ce56976ae4806db2c93e383611fdcde134c4 /src/test/util_tests.cpp | |
parent | 59ac8bacd573891d84e8ab96ff43ea12bd266f26 (diff) | |
download | bitcoin-faa5c62967174f1dd66e8a4ba61ab29c867cf450.tar.xz |
Add time helpers for std::chrono::steady_clock
Diffstat (limited to 'src/test/util_tests.cpp')
-rw-r--r-- | src/test/util_tests.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 3b2aca5887..9dcfe009b3 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -1488,8 +1488,8 @@ BOOST_AUTO_TEST_CASE(util_time_GetTime) { SetMockTime(111); // Check that mock time does not change after a sleep - for (const auto& num_sleep : {0, 1}) { - UninterruptibleSleep(std::chrono::milliseconds{num_sleep}); + for (const auto& num_sleep : {0ms, 1ms}) { + UninterruptibleSleep(num_sleep); BOOST_CHECK_EQUAL(111, GetTime()); // Deprecated time getter BOOST_CHECK_EQUAL(111, GetTime<std::chrono::seconds>().count()); BOOST_CHECK_EQUAL(111000, GetTime<std::chrono::milliseconds>().count()); @@ -1497,10 +1497,14 @@ BOOST_AUTO_TEST_CASE(util_time_GetTime) } SetMockTime(0); - // Check that system time changes after a sleep + // Check that steady time and system time changes after a sleep + const auto steady_ms_0 = Now<SteadyMilliseconds>(); + const auto steady_0 = std::chrono::steady_clock::now(); const auto ms_0 = GetTime<std::chrono::milliseconds>(); const auto us_0 = GetTime<std::chrono::microseconds>(); - UninterruptibleSleep(std::chrono::milliseconds{1}); + UninterruptibleSleep(1ms); + BOOST_CHECK(steady_ms_0 < Now<SteadyMilliseconds>()); + BOOST_CHECK(steady_0 + 1ms <= std::chrono::steady_clock::now()); BOOST_CHECK(ms_0 < GetTime<std::chrono::milliseconds>()); BOOST_CHECK(us_0 < GetTime<std::chrono::microseconds>()); } |