mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
[tools] add PoissonNextSend method that returns mockable time
This commit is contained in:
@@ -303,5 +303,19 @@ BOOST_AUTO_TEST_CASE(LocalAddress_BasicLifecycle)
|
||||
BOOST_CHECK_EQUAL(IsLocal(addr), false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(PoissonNextSend)
|
||||
{
|
||||
g_mock_deterministic_tests = true;
|
||||
|
||||
int64_t now = 5000;
|
||||
int average_interval_seconds = 600;
|
||||
|
||||
auto poisson = ::PoissonNextSend(now, average_interval_seconds);
|
||||
std::chrono::microseconds poisson_chrono = ::PoissonNextSend(std::chrono::microseconds{now}, std::chrono::seconds{average_interval_seconds});
|
||||
|
||||
BOOST_CHECK_EQUAL(poisson, poisson_chrono.count());
|
||||
|
||||
g_mock_deterministic_tests = false;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user