diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-04-04 07:30:51 +0800 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-04-05 10:46:24 +0800 |
commit | fa6a00843447d53a5708ea3a629b9150cfe58be2 (patch) | |
tree | 788c0a0be44c45cc94bbaad8ea543d0f1b67e3b2 /src/test/util/net.h | |
parent | 96a30b98c925b4ca63993759ddf7b4dd1fa58ec1 (diff) | |
download | bitcoin-fa6a00843447d53a5708ea3a629b9150cfe58be2.tar.xz |
fuzz: Add process_messages harness
Diffstat (limited to 'src/test/util/net.h')
-rw-r--r-- | src/test/util/net.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/util/net.h b/src/test/util/net.h new file mode 100644 index 0000000000..ca8cb7fad5 --- /dev/null +++ b/src/test/util/net.h @@ -0,0 +1,33 @@ +// Copyright (c) 2020 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_TEST_UTIL_NET_H +#define BITCOIN_TEST_UTIL_NET_H + +#include <net.h> + +struct ConnmanTestMsg : public CConnman { + using CConnman::CConnman; + void AddTestNode(CNode& node) + { + LOCK(cs_vNodes); + vNodes.push_back(&node); + } + void ClearTestNodes() + { + LOCK(cs_vNodes); + for (CNode* node : vNodes) { + delete node; + } + vNodes.clear(); + } + + void ProcessMessagesOnce(CNode& node) { m_msgproc->ProcessMessages(&node, flagInterruptMsgProc); } + + void NodeReceiveMsgBytes(CNode& node, const char* pch, unsigned int nBytes, bool& complete) const; + + bool ReceiveMsgFrom(CNode& node, CSerializedNetMsg& ser_msg) const; +}; + +#endif // BITCOIN_TEST_UTIL_NET_H |