mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Merge #20915: fuzz: Fail if message type is not fuzzed
fa4bc897fc
fuzz: Fail if message type is not fuzzed (MarcoFalke)faefed8cd5
fuzz: Count message type fuzzers before main() (MarcoFalke) Pull request description: `process_message_*` is a nice way to quickly fuzz a single message type. However, the offered message types are outdated and all BIPs implemented in the last years are missing. Fix that by adding them and failing when the number of message types don't add up. ACKs for top commit: practicalswift: cr ACKfa4bc897fc
: patch looks correct and touches only `src/test/fuzz/` Tree-SHA512: 8c98374b50fb4ab2ff2550daeab4c6e9f486bfe847466d217d4bc97d119adc99a82b87b56f47535b1cf8f844232bc7fa1230712a9147cda514ae78851556f988
This commit is contained in:
commit
a59e7ed0bc
1 changed files with 53 additions and 24 deletions
|
@ -35,8 +35,27 @@ namespace {
|
|||
const TestingSetup* g_setup;
|
||||
} // namespace
|
||||
|
||||
size_t& GetNumMsgTypes()
|
||||
{
|
||||
static size_t g_num_msg_types{0};
|
||||
return g_num_msg_types;
|
||||
}
|
||||
#define FUZZ_TARGET_MSG(msg_type) \
|
||||
struct msg_type##_Count_Before_Main { \
|
||||
msg_type##_Count_Before_Main() \
|
||||
{ \
|
||||
++GetNumMsgTypes(); \
|
||||
} \
|
||||
} const static g_##msg_type##_count_before_main; \
|
||||
FUZZ_TARGET_INIT(process_message_##msg_type, initialize_process_message) \
|
||||
{ \
|
||||
fuzz_target(buffer, #msg_type); \
|
||||
}
|
||||
|
||||
void initialize_process_message()
|
||||
{
|
||||
Assert(GetNumMsgTypes() == getAllNetMessageTypes().size()); // If this fails, add or remove the message type below
|
||||
|
||||
static const auto testing_setup = MakeFuzzingContext<const TestingSetup>();
|
||||
g_setup = testing_setup.get();
|
||||
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
|
|||
}
|
||||
|
||||
FUZZ_TARGET_INIT(process_message, initialize_process_message) { fuzz_target(buffer, ""); }
|
||||
FUZZ_TARGET_INIT(process_message_addr, initialize_process_message) { fuzz_target(buffer, "addr"); }
|
||||
FUZZ_TARGET_INIT(process_message_block, initialize_process_message) { fuzz_target(buffer, "block"); }
|
||||
FUZZ_TARGET_INIT(process_message_blocktxn, initialize_process_message) { fuzz_target(buffer, "blocktxn"); }
|
||||
FUZZ_TARGET_INIT(process_message_cmpctblock, initialize_process_message) { fuzz_target(buffer, "cmpctblock"); }
|
||||
FUZZ_TARGET_INIT(process_message_feefilter, initialize_process_message) { fuzz_target(buffer, "feefilter"); }
|
||||
FUZZ_TARGET_INIT(process_message_filteradd, initialize_process_message) { fuzz_target(buffer, "filteradd"); }
|
||||
FUZZ_TARGET_INIT(process_message_filterclear, initialize_process_message) { fuzz_target(buffer, "filterclear"); }
|
||||
FUZZ_TARGET_INIT(process_message_filterload, initialize_process_message) { fuzz_target(buffer, "filterload"); }
|
||||
FUZZ_TARGET_INIT(process_message_getaddr, initialize_process_message) { fuzz_target(buffer, "getaddr"); }
|
||||
FUZZ_TARGET_INIT(process_message_getblocks, initialize_process_message) { fuzz_target(buffer, "getblocks"); }
|
||||
FUZZ_TARGET_INIT(process_message_getblocktxn, initialize_process_message) { fuzz_target(buffer, "getblocktxn"); }
|
||||
FUZZ_TARGET_INIT(process_message_getdata, initialize_process_message) { fuzz_target(buffer, "getdata"); }
|
||||
FUZZ_TARGET_INIT(process_message_getheaders, initialize_process_message) { fuzz_target(buffer, "getheaders"); }
|
||||
FUZZ_TARGET_INIT(process_message_headers, initialize_process_message) { fuzz_target(buffer, "headers"); }
|
||||
FUZZ_TARGET_INIT(process_message_inv, initialize_process_message) { fuzz_target(buffer, "inv"); }
|
||||
FUZZ_TARGET_INIT(process_message_mempool, initialize_process_message) { fuzz_target(buffer, "mempool"); }
|
||||
FUZZ_TARGET_INIT(process_message_notfound, initialize_process_message) { fuzz_target(buffer, "notfound"); }
|
||||
FUZZ_TARGET_INIT(process_message_ping, initialize_process_message) { fuzz_target(buffer, "ping"); }
|
||||
FUZZ_TARGET_INIT(process_message_pong, initialize_process_message) { fuzz_target(buffer, "pong"); }
|
||||
FUZZ_TARGET_INIT(process_message_sendcmpct, initialize_process_message) { fuzz_target(buffer, "sendcmpct"); }
|
||||
FUZZ_TARGET_INIT(process_message_sendheaders, initialize_process_message) { fuzz_target(buffer, "sendheaders"); }
|
||||
FUZZ_TARGET_INIT(process_message_tx, initialize_process_message) { fuzz_target(buffer, "tx"); }
|
||||
FUZZ_TARGET_INIT(process_message_verack, initialize_process_message) { fuzz_target(buffer, "verack"); }
|
||||
FUZZ_TARGET_INIT(process_message_version, initialize_process_message) { fuzz_target(buffer, "version"); }
|
||||
FUZZ_TARGET_MSG(addr);
|
||||
FUZZ_TARGET_MSG(addrv2);
|
||||
FUZZ_TARGET_MSG(block);
|
||||
FUZZ_TARGET_MSG(blocktxn);
|
||||
FUZZ_TARGET_MSG(cfcheckpt);
|
||||
FUZZ_TARGET_MSG(cfheaders);
|
||||
FUZZ_TARGET_MSG(cfilter);
|
||||
FUZZ_TARGET_MSG(cmpctblock);
|
||||
FUZZ_TARGET_MSG(feefilter);
|
||||
FUZZ_TARGET_MSG(filteradd);
|
||||
FUZZ_TARGET_MSG(filterclear);
|
||||
FUZZ_TARGET_MSG(filterload);
|
||||
FUZZ_TARGET_MSG(getaddr);
|
||||
FUZZ_TARGET_MSG(getblocks);
|
||||
FUZZ_TARGET_MSG(getblocktxn);
|
||||
FUZZ_TARGET_MSG(getcfcheckpt);
|
||||
FUZZ_TARGET_MSG(getcfheaders);
|
||||
FUZZ_TARGET_MSG(getcfilters);
|
||||
FUZZ_TARGET_MSG(getdata);
|
||||
FUZZ_TARGET_MSG(getheaders);
|
||||
FUZZ_TARGET_MSG(headers);
|
||||
FUZZ_TARGET_MSG(inv);
|
||||
FUZZ_TARGET_MSG(mempool);
|
||||
FUZZ_TARGET_MSG(merkleblock);
|
||||
FUZZ_TARGET_MSG(notfound);
|
||||
FUZZ_TARGET_MSG(ping);
|
||||
FUZZ_TARGET_MSG(pong);
|
||||
FUZZ_TARGET_MSG(sendaddrv2);
|
||||
FUZZ_TARGET_MSG(sendcmpct);
|
||||
FUZZ_TARGET_MSG(sendheaders);
|
||||
FUZZ_TARGET_MSG(tx);
|
||||
FUZZ_TARGET_MSG(verack);
|
||||
FUZZ_TARGET_MSG(version);
|
||||
FUZZ_TARGET_MSG(wtxidrelay);
|
||||
|
|
Loading…
Add table
Reference in a new issue