test: Use NodeClockContext in more tests

This commit is contained in:
MarcoFalke
2025-05-07 02:04:48 +02:00
parent fa8fe0941e
commit faad08e59c
11 changed files with 57 additions and 55 deletions

View File

@@ -12,6 +12,7 @@
#include <test/util/common.h>
#include <test/util/random.h>
#include <test/util/setup_common.h>
#include <test/util/time.h>
#include <uint256.h>
#include <util/bitdeque.h>
#include <util/byte_units.h>
@@ -585,7 +586,7 @@ BOOST_AUTO_TEST_CASE(strprintf_numbers)
BOOST_AUTO_TEST_CASE(util_mocktime)
{
SetMockTime(111s);
NodeClockContext clock_ctx{111s};
// Check that mock time does not change after a sleep
for (const auto& num_sleep : {0ms, 1ms}) {
UninterruptibleSleep(num_sleep);
@@ -598,7 +599,6 @@ BOOST_AUTO_TEST_CASE(util_mocktime)
BOOST_CHECK_EQUAL(111000, TicksSinceEpoch<std::chrono::milliseconds>(NodeClock::now()));
BOOST_CHECK_EQUAL(111000000, GetTime<std::chrono::microseconds>().count());
}
SetMockTime(0s);
}
BOOST_AUTO_TEST_CASE(util_ticksseconds)