Skip to content

Commit

Permalink
fuzz: Reduce maintenance requirements by allowing RPC annotations als…
Browse files Browse the repository at this point in the history
…o for conditionally available RPC commands (such as wallet commands) without the fragility of #ifdef forests
  • Loading branch information
practicalswift committed Apr 29, 2021
1 parent 54549dd commit 5252f86
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/test/fuzz/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,13 @@ const std::vector<std::string> RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{
"addpeeraddress", // avoid DNS lookups
"analyzepsbt", // avoid signed integer overflow in CFeeRate::GetFee(unsigned long) (https://github.com/bitcoin/bitcoin/issues/20607)
"dumptxoutset", // avoid writing to disk
#ifdef ENABLE_WALLET
"dumpwallet", // avoid writing to disk
#endif
"echoipc", // avoid assertion failure (Assertion `"EnsureAnyNodeContext(request.context).init" && check' failed.)
"generatetoaddress", // avoid prohibitively slow execution (when `num_blocks` is large)
"generatetodescriptor", // avoid prohibitively slow execution (when `nblocks` is large)
"gettxoutproof", // avoid prohibitively slow execution
#ifdef ENABLE_WALLET
"importwallet", // avoid reading from disk
"loadwallet", // avoid reading from disk
#endif
"prioritisetransaction", // avoid signed integer overflow in CTxMemPool::PrioritiseTransaction(uint256 const&, long const&) (https://github.com/bitcoin/bitcoin/issues/20626)
"savemempool", // disabled as a precautionary measure: may take a file path argument in the future
"setban", // avoid DNS lookups
Expand Down Expand Up @@ -332,20 +328,6 @@ void initialize_rpc()
std::terminate();
}
}
for (const std::string& rpc_command : RPC_COMMANDS_SAFE_FOR_FUZZING) {
const bool supported_rpc_command = std::find(supported_rpc_commands.begin(), supported_rpc_commands.end(), rpc_command) != supported_rpc_commands.end();
if (!supported_rpc_command) {
std::cerr << "Error: Unknown RPC command \"" << rpc_command << "\" found in RPC_COMMANDS_SAFE_FOR_FUZZING. Please update " << __FILE__ << ".\n";
std::terminate();
}
}
for (const std::string& rpc_command : RPC_COMMANDS_NOT_SAFE_FOR_FUZZING) {
const bool supported_rpc_command = std::find(supported_rpc_commands.begin(), supported_rpc_commands.end(), rpc_command) != supported_rpc_commands.end();
if (!supported_rpc_command) {
std::cerr << "Error: Unknown RPC command \"" << rpc_command << "\" found in RPC_COMMANDS_NOT_SAFE_FOR_FUZZING. Please update " << __FILE__ << ".\n";
std::terminate();
}
}
const char* limit_to_rpc_command_env = std::getenv("LIMIT_TO_RPC_COMMAND");
if (limit_to_rpc_command_env != nullptr) {
g_limit_to_rpc_command = std::string{limit_to_rpc_command_env};
Expand Down

0 comments on commit 5252f86

Please sign in to comment.