diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-12-02 19:43:52 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-12-02 19:08:43 +0100 |
commit | fa52a86fd3acbcfc4b5ca1304c19d81df66d85d7 (patch) | |
tree | 78747a4b77856a5783b969dbfc2a76940b7ce1a4 /src | |
parent | 26a1147ce56083d7aa820ac115c16b01e47d911c (diff) |
fuzz: Rework rpc fuzz target
Diffstat (limited to 'src')
-rw-r--r-- | src/test/fuzz/rpc.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/test/fuzz/rpc.cpp b/src/test/fuzz/rpc.cpp index 251687104e..790421d60c 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 @@ -353,7 +357,11 @@ 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()}; + if (error_msg.find("Internal bug detected") != std::string::npos) { + // Only allow the intentional internal bug + assert(error_msg.find("trigger_internal_bug") != std::string::npos); + } } } |