diff options
author | fanquake <fanquake@gmail.com> | 2022-05-20 07:35:26 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-05-20 07:48:07 +0100 |
commit | 6407c0e8a33f5a04eae4ebfb5befdcc1c2ab2b57 (patch) | |
tree | e12de5d04c2be4f17c6601101a02633e6eb67d0e /src/test | |
parent | 0de36941eca1bff91420dd878eb097db2b1a596c (diff) | |
parent | fa305fd92c0a5a91831be3ccec0a5ef962a5fbcb (diff) |
Merge bitcoin/bitcoin#25101: Add mockable clock type
fa305fd92c0a5a91831be3ccec0a5ef962a5fbcb Add mockable clock type and TicksSinceEpoch helper (MarcoFalke)
Pull request description:
This will be used primarily by the addr time refactor (https://github.com/bitcoin/bitcoin/pull/24697) to make addr relay time type safe. However, it can also be used in other places, and can be reviewed independently, so I split it up.
ACKs for top commit:
jonatack:
ACK fa305fd92c0a5a91831be3ccec0a5ef962a5fbcb per `git range-diff 7b3343f fa20781 fa305fd`
ajtowns:
ACK fa305fd92c0a5a91831be3ccec0a5ef962a5fbcb
Tree-SHA512: da00200126833c1f55b1b1e68f596eab5c9254e82b188ad17779c08ffd685e198a7c5270791b4b69a858dc6ba4e051fe0c8b445d203d356d0c884f6365ee1cfe
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/util_tests.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index c110cd44aa..56a1155469 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -1488,8 +1488,12 @@ BOOST_AUTO_TEST_CASE(util_time_GetTime) for (const auto& num_sleep : {0ms, 1ms}) { UninterruptibleSleep(num_sleep); BOOST_CHECK_EQUAL(111, GetTime()); // Deprecated time getter + BOOST_CHECK_EQUAL(111, Now<NodeSeconds>().time_since_epoch().count()); + BOOST_CHECK_EQUAL(111, TicksSinceEpoch<std::chrono::seconds>(NodeClock::now())); + BOOST_CHECK_EQUAL(111, TicksSinceEpoch<SecondsDouble>(Now<NodeSeconds>())); BOOST_CHECK_EQUAL(111, GetTime<std::chrono::seconds>().count()); BOOST_CHECK_EQUAL(111000, GetTime<std::chrono::milliseconds>().count()); + BOOST_CHECK_EQUAL(111000, TicksSinceEpoch<std::chrono::milliseconds>(NodeClock::now())); BOOST_CHECK_EQUAL(111000000, GetTime<std::chrono::microseconds>().count()); } |