mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
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.
This commit is contained in:
13
src/net.h
13
src/net.h
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user