mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-13 00:00:23 +02:00
Merge bitcoin/bitcoin#24974: refactor: Make FEELER_SLEEP_WINDOW type safe (std::chrono)
fa74e726c4refactor: Make FEELER_SLEEP_WINDOW type safe (std::chrono) (MacroFake)fa3b3cb9b5Expose underlying clock in CThreadInterrupt (MacroFake) Pull request description: This gets rid of the `value*1000` manual conversion. ACKs for top commit: naumenkogs: utACKfa74e726c4dergoegge: Code review ACKfa74e726c4Tree-SHA512: 90409c05c25f0dd2f1c4dead78f707ebfd78b7d84ea4db9fcefd9c4958a1a3338ac657cd9e99eb8b47d52d4485fa3c947dce4ee1559fb56ae65878685e1ed9a3
This commit is contained in:
@@ -53,6 +53,16 @@ BOOST_AUTO_TEST_CASE(fastrandom_tests)
|
||||
BOOST_CHECK_EQUAL(ctx1.randbits(3), ctx2.randbits(3));
|
||||
BOOST_CHECK(ctx1.rand256() == ctx2.rand256());
|
||||
BOOST_CHECK(ctx1.randbytes(50) == ctx2.randbytes(50));
|
||||
{
|
||||
struct MicroClock {
|
||||
using duration = std::chrono::microseconds;
|
||||
};
|
||||
FastRandomContext ctx{true};
|
||||
// Check with clock type
|
||||
BOOST_CHECK_EQUAL(47222, ctx.rand_uniform_duration<MicroClock>(1s).count());
|
||||
// Check with time-point type
|
||||
BOOST_CHECK_EQUAL(2782, ctx.rand_uniform_duration<SteadySeconds>(9h).count());
|
||||
}
|
||||
|
||||
// Check that a nondeterministic ones are not
|
||||
g_mock_deterministic_tests = false;
|
||||
|
||||
Reference in New Issue
Block a user