aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-07-10 16:06:11 +0200
committerMarcoFalke <falke.marco@gmail.com>2020-07-10 16:06:28 +0200
commit107b8559c5a7ed4c514e50d1df6bd2407d1d6f27 (patch)
tree0a0925aa61f7da26d5e619ac1e9fdd3784256e5c /src/util
parenta4eb6a51a7f6eb68c35a90436739e0a7d884ed94 (diff)
parentfa3365430c5fb57d7c0b5f2bce9fbbe290be93c3 (diff)
downloadbitcoin-107b8559c5a7ed4c514e50d1df6bd2407d1d6f27.tar.xz
Merge #18638: net: Use mockable time for ping/pong, add tests
fa3365430c5fb57d7c0b5f2bce9fbbe290be93c3 net: Use mockable time for ping/pong, add tests (MarcoFalke) faab4aaf2fa1153c6d76efc8113fa01b06943ece util: 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-ACK fa33654 re-read code, verified rebase per `git range-diff 4b5c919 fa94d6f fa33654`, previous tested ACKs still valid troygiorshev: ACK fa3365430c5fb57d7c0b5f2bce9fbbe290be93c3 Tree-SHA512: 7d632bd6019ce7c882029e71b667a61517e783af82755a85dd979ef09380934e172dec8b8f91d57b200a30a6e096aeaf01f19fee7f3aed0e0e871c72eb44d70e
Diffstat (limited to 'src/util')
-rw-r--r--src/util/time.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/util/time.h b/src/util/time.h
index b00c25f67c..af934e423b 100644
--- a/src/util/time.h
+++ b/src/util/time.h
@@ -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