diff options
Diffstat (limited to 'src/test/fuzz/rpc.cpp')
-rw-r--r-- | src/test/fuzz/rpc.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/test/fuzz/rpc.cpp b/src/test/fuzz/rpc.cpp index 251687104e..b6ecf1c492 100644 --- a/src/test/fuzz/rpc.cpp +++ b/src/test/fuzz/rpc.cpp @@ -41,13 +41,17 @@ struct RPCFuzzTestingSetup : public TestingSetup { { } - UniValue CallRPC(const std::string& rpc_method, const std::vector<std::string>& arguments) + void CallRPC(const std::string& rpc_method, const std::vector<std::string>& arguments) { JSONRPCRequest request; request.context = &m_node; request.strMethod = rpc_method; - request.params = RPCConvertValues(rpc_method, arguments); - return tableRPC.execute(request); + try { + request.params = RPCConvertValues(rpc_method, arguments); + } catch (const std::runtime_error&) { + return; + } + tableRPC.execute(request); } std::vector<std::string> GetRPCCommands() const @@ -110,6 +114,7 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{ "getblockfilter", "getblockhash", "getblockheader", + "getblockfrompeer", // when no peers are connected, no p2p message is sent "getblockstats", "getblocktemplate", "getchaintips", @@ -353,7 +358,13 @@ FUZZ_TARGET_INIT(rpc, initialize_rpc) } try { rpc_testing_setup->CallRPC(rpc_command, arguments); - } catch (const UniValue&) { - } catch (const std::runtime_error&) { + } catch (const UniValue& json_rpc_error) { + const std::string error_msg{find_value(json_rpc_error, "message").get_str()}; + // Once c++20 is allowed, starts_with can be used. + // if (error_msg.starts_with("Internal bug detected")) { + if (0 == error_msg.rfind("Internal bug detected", 0)) { + // Only allow the intentional internal bug + assert(error_msg.find("trigger_internal_bug") != std::string::npos); + } } } |