@@ -35,8 +35,27 @@ namespace {
35
35
const TestingSetup* g_setup;
36
36
} // namespace
37
37
38
+ size_t & GetNumMsgTypes ()
39
+ {
40
+ static size_t g_num_msg_types{0 };
41
+ return g_num_msg_types;
42
+ }
43
+ #define FUZZ_TARGET_MSG (msg_type ) \
44
+ struct msg_type ##_Count_Before_Main { \
45
+ msg_type##_Count_Before_Main() \
46
+ { \
47
+ ++GetNumMsgTypes (); \
48
+ } \
49
+ } const static g_##msg_type##_count_before_main; \
50
+ FUZZ_TARGET_INIT (process_message_##msg_type, initialize_process_message) \
51
+ { \
52
+ fuzz_target (buffer, #msg_type); \
53
+ }
54
+
38
55
void initialize_process_message ()
39
56
{
57
+ Assert (GetNumMsgTypes () == getAllNetMessageTypes ().size ()); // If this fails, add or remove the message type below
58
+
40
59
static const auto testing_setup = MakeFuzzingContext<const TestingSetup>();
41
60
g_setup = testing_setup.get ();
42
61
for (int i = 0 ; i < 2 * COINBASE_MATURITY; i++) {
@@ -86,27 +105,37 @@ void fuzz_target(FuzzBufferType buffer, const std::string& LIMIT_TO_MESSAGE_TYPE
86
105
}
87
106
88
107
FUZZ_TARGET_INIT (process_message, initialize_process_message) { fuzz_target (buffer, " " ); }
89
- FUZZ_TARGET_INIT (process_message_addr, initialize_process_message) { fuzz_target (buffer, " addr" ); }
90
- FUZZ_TARGET_INIT (process_message_block, initialize_process_message) { fuzz_target (buffer, " block" ); }
91
- FUZZ_TARGET_INIT (process_message_blocktxn, initialize_process_message) { fuzz_target (buffer, " blocktxn" ); }
92
- FUZZ_TARGET_INIT (process_message_cmpctblock, initialize_process_message) { fuzz_target (buffer, " cmpctblock" ); }
93
- FUZZ_TARGET_INIT (process_message_feefilter, initialize_process_message) { fuzz_target (buffer, " feefilter" ); }
94
- FUZZ_TARGET_INIT (process_message_filteradd, initialize_process_message) { fuzz_target (buffer, " filteradd" ); }
95
- FUZZ_TARGET_INIT (process_message_filterclear, initialize_process_message) { fuzz_target (buffer, " filterclear" ); }
96
- FUZZ_TARGET_INIT (process_message_filterload, initialize_process_message) { fuzz_target (buffer, " filterload" ); }
97
- FUZZ_TARGET_INIT (process_message_getaddr, initialize_process_message) { fuzz_target (buffer, " getaddr" ); }
98
- FUZZ_TARGET_INIT (process_message_getblocks, initialize_process_message) { fuzz_target (buffer, " getblocks" ); }
99
- FUZZ_TARGET_INIT (process_message_getblocktxn, initialize_process_message) { fuzz_target (buffer, " getblocktxn" ); }
100
- FUZZ_TARGET_INIT (process_message_getdata, initialize_process_message) { fuzz_target (buffer, " getdata" ); }
101
- FUZZ_TARGET_INIT (process_message_getheaders, initialize_process_message) { fuzz_target (buffer, " getheaders" ); }
102
- FUZZ_TARGET_INIT (process_message_headers, initialize_process_message) { fuzz_target (buffer, " headers" ); }
103
- FUZZ_TARGET_INIT (process_message_inv, initialize_process_message) { fuzz_target (buffer, " inv" ); }
104
- FUZZ_TARGET_INIT (process_message_mempool, initialize_process_message) { fuzz_target (buffer, " mempool" ); }
105
- FUZZ_TARGET_INIT (process_message_notfound, initialize_process_message) { fuzz_target (buffer, " notfound" ); }
106
- FUZZ_TARGET_INIT (process_message_ping, initialize_process_message) { fuzz_target (buffer, " ping" ); }
107
- FUZZ_TARGET_INIT (process_message_pong, initialize_process_message) { fuzz_target (buffer, " pong" ); }
108
- FUZZ_TARGET_INIT (process_message_sendcmpct, initialize_process_message) { fuzz_target (buffer, " sendcmpct" ); }
109
- FUZZ_TARGET_INIT (process_message_sendheaders, initialize_process_message) { fuzz_target (buffer, " sendheaders" ); }
110
- FUZZ_TARGET_INIT (process_message_tx, initialize_process_message) { fuzz_target (buffer, " tx" ); }
111
- FUZZ_TARGET_INIT (process_message_verack, initialize_process_message) { fuzz_target (buffer, " verack" ); }
112
- FUZZ_TARGET_INIT (process_message_version, initialize_process_message) { fuzz_target (buffer, " version" ); }
108
+ FUZZ_TARGET_MSG (addr);
109
+ FUZZ_TARGET_MSG (addrv2);
110
+ FUZZ_TARGET_MSG (block);
111
+ FUZZ_TARGET_MSG (blocktxn);
112
+ FUZZ_TARGET_MSG (cfcheckpt);
113
+ FUZZ_TARGET_MSG (cfheaders);
114
+ FUZZ_TARGET_MSG (cfilter);
115
+ FUZZ_TARGET_MSG (cmpctblock);
116
+ FUZZ_TARGET_MSG (feefilter);
117
+ FUZZ_TARGET_MSG (filteradd);
118
+ FUZZ_TARGET_MSG (filterclear);
119
+ FUZZ_TARGET_MSG (filterload);
120
+ FUZZ_TARGET_MSG (getaddr);
121
+ FUZZ_TARGET_MSG (getblocks);
122
+ FUZZ_TARGET_MSG (getblocktxn);
123
+ FUZZ_TARGET_MSG (getcfcheckpt);
124
+ FUZZ_TARGET_MSG (getcfheaders);
125
+ FUZZ_TARGET_MSG (getcfilters);
126
+ FUZZ_TARGET_MSG (getdata);
127
+ FUZZ_TARGET_MSG (getheaders);
128
+ FUZZ_TARGET_MSG (headers);
129
+ FUZZ_TARGET_MSG (inv);
130
+ FUZZ_TARGET_MSG (mempool);
131
+ FUZZ_TARGET_MSG (merkleblock);
132
+ FUZZ_TARGET_MSG (notfound);
133
+ FUZZ_TARGET_MSG (ping);
134
+ FUZZ_TARGET_MSG (pong);
135
+ FUZZ_TARGET_MSG (sendaddrv2);
136
+ FUZZ_TARGET_MSG (sendcmpct);
137
+ FUZZ_TARGET_MSG (sendheaders);
138
+ FUZZ_TARGET_MSG (tx);
139
+ FUZZ_TARGET_MSG (verack);
140
+ FUZZ_TARGET_MSG (version);
141
+ FUZZ_TARGET_MSG (wtxidrelay);
0 commit comments