mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 17:54:19 +02:00
Merge #18638: net: Use mockable time for ping/pong, add tests
fa3365430cnet: Use mockable time for ping/pong, add tests (MarcoFalke)faab4aaf2futil: Add count_microseconds helper (MarcoFalke) Pull request description: Switch `CNode::m_ping_start` and `CNetMessage::m_time` to mockable time, so that tests can be added. Mockable time is also type-safe, since it uses `std::chrono` ACKs for top commit: jonatack: Code review re-ACKfa33654re-read code, verified rebase per `git range-diff4b5c919fa94d6f fa33654`, previous tested ACKs still valid troygiorshev: ACKfa3365430cTree-SHA512: 7d632bd6019ce7c882029e71b667a61517e783af82755a85dd979ef09380934e172dec8b8f91d57b200a30a6e096aeaf01f19fee7f3aed0e0e871c72eb44d70e
This commit is contained in:
@@ -15,10 +15,15 @@ void UninterruptibleSleep(const std::chrono::microseconds& n);
|
||||
/**
|
||||
* Helper to count the seconds of a duration.
|
||||
*
|
||||
* All durations should be using std::chrono and calling this should generally be avoided in code. Though, it is still
|
||||
* preferred to an inline t.count() to protect against a reliance on the exact type of t.
|
||||
* All durations should be using std::chrono and calling this should generally
|
||||
* be avoided in code. Though, it is still preferred to an inline t.count() to
|
||||
* protect against a reliance on the exact type of t.
|
||||
*
|
||||
* This helper is used to convert durations before passing them over an
|
||||
* interface that doesn't support std::chrono (e.g. RPC, debug log, or the GUI)
|
||||
*/
|
||||
inline int64_t count_seconds(std::chrono::seconds t) { return t.count(); }
|
||||
inline int64_t count_microseconds(std::chrono::microseconds t) { return t.count(); }
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
|
||||
Reference in New Issue
Block a user