mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
Merge bitcoin/bitcoin#23654: fuzz: Rework rpc fuzz target
fa52a86fd3
fuzz: Rework rpc fuzz target (MarcoFalke) Pull request description: Changes (reason): * Return `void` in `CallRPC` (the result is unused anyway) * Reduce the `catch`-scope of `std::runtime_error` to `RPCConvertValues` (Code clarity and easier bug-finding) * Crash when an internal bug is detected (bugs are bad) ACKs for top commit: shaavan: Code Review ACKfa52a86fd3
Tree-SHA512: 576411a0e50bca9be3e6ffaf745001b1808fd37029251f8ec2c279e0671efe91d43dd81fd4ca26871c28b119e593ee2a0043d4b75f44da578f17541ee3afd696
This commit is contained in:
commit
57982f419e
1 changed files with 13 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue