mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-03 19:51:32 +02:00
fuzz: Rework rpc fuzz target
This commit is contained in:
parent
26a1147ce5
commit
fa52a86fd3
@ -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;
|
JSONRPCRequest request;
|
||||||
request.context = &m_node;
|
request.context = &m_node;
|
||||||
request.strMethod = rpc_method;
|
request.strMethod = rpc_method;
|
||||||
request.params = RPCConvertValues(rpc_method, arguments);
|
try {
|
||||||
return tableRPC.execute(request);
|
request.params = RPCConvertValues(rpc_method, arguments);
|
||||||
|
} catch (const std::runtime_error&) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tableRPC.execute(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> GetRPCCommands() const
|
std::vector<std::string> GetRPCCommands() const
|
||||||
@ -353,7 +357,11 @@ FUZZ_TARGET_INIT(rpc, initialize_rpc)
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
rpc_testing_setup->CallRPC(rpc_command, arguments);
|
rpc_testing_setup->CallRPC(rpc_command, arguments);
|
||||||
} catch (const UniValue&) {
|
} catch (const UniValue& json_rpc_error) {
|
||||||
} catch (const std::runtime_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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user