2
2
// Distributed under the MIT software license, see the accompanying
3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
- #include < banman.h>
6
- #include < chainparams.h>
7
5
#include < consensus/consensus.h>
8
6
#include < net.h>
9
7
#include < net_processing.h>
8
+ #include < primitives/transaction.h>
10
9
#include < protocol.h>
11
- #include < scheduler.h>
12
10
#include < script/script.h>
11
+ #include < serialize.h>
12
+ #include < span.h>
13
13
#include < streams.h>
14
+ #include < sync.h>
14
15
#include < test/fuzz/FuzzedDataProvider.h>
15
16
#include < test/fuzz/fuzz.h>
16
17
#include < test/fuzz/util.h>
20
21
#include < test/util/setup_common.h>
21
22
#include < test/util/validation.h>
22
23
#include < util/chaintype.h>
24
+ #include < util/check.h>
25
+ #include < util/time.h>
26
+ #include < validation.h>
23
27
#include < validationinterface.h>
24
28
#include < version.h>
25
29
30
+
26
31
#include < atomic>
27
- #include < cassert>
28
- #include < chrono>
29
- #include < cstdint>
30
- #include < iosfwd>
32
+ #include < cstdlib>
31
33
#include < iostream>
32
34
#include < memory>
33
35
#include < string>
36
+ #include < string_view>
37
+ #include < vector>
34
38
35
39
namespace {
36
40
const TestingSetup* g_setup;
41
+ std::string_view LIMIT_TO_MESSAGE_TYPE{};
37
42
} // namespace
38
43
39
- size_t & GetNumMsgTypes ()
40
- {
41
- static size_t g_num_msg_types{0 };
42
- return g_num_msg_types;
43
- }
44
- #define FUZZ_TARGET_MSG (msg_type ) \
45
- struct msg_type ##_Count_Before_Main { \
46
- msg_type##_Count_Before_Main() \
47
- { \
48
- ++GetNumMsgTypes (); \
49
- } \
50
- } const static g_##msg_type##_count_before_main; \
51
- FUZZ_TARGET_INIT (process_message_##msg_type, initialize_process_message) \
52
- { \
53
- fuzz_target (buffer, #msg_type); \
54
- }
55
-
56
44
void initialize_process_message ()
57
45
{
58
- Assert (GetNumMsgTypes () == getAllNetMessageTypes ().size ()); // If this fails, add or remove the message type below
46
+ if (const auto val{std::getenv (" LIMIT_TO_MESSAGE_TYPE" )}) {
47
+ LIMIT_TO_MESSAGE_TYPE = val;
48
+ Assert (std::count (getAllNetMessageTypes ().begin (), getAllNetMessageTypes ().end (), LIMIT_TO_MESSAGE_TYPE)); // Unknown message type passed
49
+ }
59
50
60
51
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(
61
52
/* chain_type=*/ ChainType::REGTEST,
@@ -67,7 +58,7 @@ void initialize_process_message()
67
58
SyncWithValidationInterfaceQueue ();
68
59
}
69
60
70
- void fuzz_target (FuzzBufferType buffer, const std::string& LIMIT_TO_MESSAGE_TYPE )
61
+ FUZZ_TARGET_INIT (process_message, initialize_process_message )
71
62
{
72
63
FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
73
64
@@ -101,40 +92,3 @@ void fuzz_target(FuzzBufferType buffer, const std::string& LIMIT_TO_MESSAGE_TYPE
101
92
SyncWithValidationInterfaceQueue ();
102
93
g_setup->m_node .connman ->StopNodes ();
103
94
}
104
-
105
- FUZZ_TARGET_INIT (process_message, initialize_process_message) { fuzz_target (buffer, " " ); }
106
- FUZZ_TARGET_MSG (addr);
107
- FUZZ_TARGET_MSG (addrv2);
108
- FUZZ_TARGET_MSG (block);
109
- FUZZ_TARGET_MSG (blocktxn);
110
- FUZZ_TARGET_MSG (cfcheckpt);
111
- FUZZ_TARGET_MSG (cfheaders);
112
- FUZZ_TARGET_MSG (cfilter);
113
- FUZZ_TARGET_MSG (cmpctblock);
114
- FUZZ_TARGET_MSG (feefilter);
115
- FUZZ_TARGET_MSG (filteradd);
116
- FUZZ_TARGET_MSG (filterclear);
117
- FUZZ_TARGET_MSG (filterload);
118
- FUZZ_TARGET_MSG (getaddr);
119
- FUZZ_TARGET_MSG (getblocks);
120
- FUZZ_TARGET_MSG (getblocktxn);
121
- FUZZ_TARGET_MSG (getcfcheckpt);
122
- FUZZ_TARGET_MSG (getcfheaders);
123
- FUZZ_TARGET_MSG (getcfilters);
124
- FUZZ_TARGET_MSG (getdata);
125
- FUZZ_TARGET_MSG (getheaders);
126
- FUZZ_TARGET_MSG (headers);
127
- FUZZ_TARGET_MSG (inv);
128
- FUZZ_TARGET_MSG (mempool);
129
- FUZZ_TARGET_MSG (merkleblock);
130
- FUZZ_TARGET_MSG (notfound);
131
- FUZZ_TARGET_MSG (ping);
132
- FUZZ_TARGET_MSG (pong);
133
- FUZZ_TARGET_MSG (sendaddrv2);
134
- FUZZ_TARGET_MSG (sendcmpct);
135
- FUZZ_TARGET_MSG (sendheaders);
136
- FUZZ_TARGET_MSG (sendtxrcncl);
137
- FUZZ_TARGET_MSG (tx);
138
- FUZZ_TARGET_MSG (verack);
139
- FUZZ_TARGET_MSG (version);
140
- FUZZ_TARGET_MSG (wtxidrelay);
0 commit comments