mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Merge #17243: p2p: add PoissonNextSend method that returns mockable time
1a8f0d5a74[tools] update nNextInvSend to use mockable time (Amiti Uttarwar)4de630354f[tools] add PoissonNextSend method that returns mockable time (Amiti Uttarwar) Pull request description: Introduce a Poisson helper method that wraps the existing method to return `std::chrono::duration` type, which is mockable. Needed for https://github.com/bitcoin/bitcoin/pull/16698. ACKs for top commit: ajtowns: ACK1a8f0d5a74MarcoFalke: re-ACK1a8f0d5a74naumenkogs: ACK1a8f0d5, and let's merge it and come back to it later. Tree-SHA512: 7e2325d7c55fc0b4357cb86b83e0c218ba269f678c1786342d8bc380bfd9696373bc24ff124b9ff17a6e761c62b2b44ff5247c3911e2afdc7cc5c20417e8290b
This commit is contained in:
@@ -301,5 +301,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