diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2021-07-22 18:23:21 +0200 |
---|---|---|
committer | Vasil Dimov <vd@FreeBSD.org> | 2022-03-02 15:40:36 +0100 |
commit | 3cb9d9c861710c0cff018bee90b1969193d3ed68 (patch) | |
tree | f0db6729c585e7d8e819762cf9437a678d78590e /src/net.h | |
parent | 43868ba416727effd515a471e2a337c3b8cacc37 (diff) |
net: make CaptureMessage() mockable
Rename `CaptureMessage()` to `CaptureMessageToFile()` and introduce a
`std::function` variable called `CaptureMessage` whose value can be
changed by unit tests, should they need to inspect message contents.
Diffstat (limited to 'src/net.h')
-rw-r--r-- | src/net.h | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -31,6 +31,7 @@ #include <condition_variable> #include <cstdint> #include <deque> +#include <functional> #include <map> #include <memory> #include <optional> @@ -1272,7 +1273,17 @@ private: }; /** Dump binary message to file, with timestamp */ -void CaptureMessage(const CAddress& addr, const std::string& msg_type, const Span<const unsigned char>& data, bool is_incoming); +void CaptureMessageToFile(const CAddress& addr, + const std::string& msg_type, + const Span<const unsigned char>& data, + bool is_incoming); + +/** Defaults to `CaptureMessageToFile()`, but can be overridden by unit tests. */ +extern std::function<void(const CAddress& addr, + const std::string& msg_type, + const Span<const unsigned char>& data, + bool is_incoming)> + CaptureMessage; struct NodeEvictionCandidate { |