mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
rpc: Limit echo to 10 args
This commit is contained in:
parent
fa89ca9b5b
commit
fa50bdc755
2 changed files with 18 additions and 5 deletions
|
@ -583,16 +583,29 @@ static UniValue echo(const JSONRPCRequest& request)
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
RPCHelpMan{"echo|echojson ...",
|
RPCHelpMan{"echo|echojson ...",
|
||||||
"\nSimply echo back the input arguments. This command is for testing.\n"
|
"\nSimply echo back the input arguments. This command is for testing.\n"
|
||||||
"\nIt will return an internal bug report when exactly 100 arguments are passed.\n"
|
"\nIt will return an internal bug report when arg9='trigger_internal_bug' is passed.\n"
|
||||||
"\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in "
|
"\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in "
|
||||||
"bitcoin-cli and the GUI. There is no server-side difference.",
|
"bitcoin-cli and the GUI. There is no server-side difference.",
|
||||||
{},
|
{
|
||||||
|
{"arg0", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
|
||||||
|
{"arg1", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
|
||||||
|
{"arg2", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
|
||||||
|
{"arg3", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
|
||||||
|
{"arg4", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
|
||||||
|
{"arg5", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
|
||||||
|
{"arg6", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
|
||||||
|
{"arg7", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
|
||||||
|
{"arg8", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
|
||||||
|
{"arg9", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
|
||||||
|
},
|
||||||
RPCResult{RPCResult::Type::NONE, "", "Returns whatever was passed in"},
|
RPCResult{RPCResult::Type::NONE, "", "Returns whatever was passed in"},
|
||||||
RPCExamples{""},
|
RPCExamples{""},
|
||||||
}.ToString()
|
}.ToString()
|
||||||
);
|
);
|
||||||
|
|
||||||
CHECK_NONFATAL(request.params.size() != 100);
|
if (request.params[9].isStr()) {
|
||||||
|
CHECK_NONFATAL(request.params[9].get_str() != "trigger_internal_bug");
|
||||||
|
}
|
||||||
|
|
||||||
return request.params;
|
return request.params;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ class RpcMiscTest(BitcoinTestFramework):
|
||||||
self.log.info("test CHECK_NONFATAL")
|
self.log.info("test CHECK_NONFATAL")
|
||||||
assert_raises_rpc_error(
|
assert_raises_rpc_error(
|
||||||
-1,
|
-1,
|
||||||
"Internal bug detected: 'request.params.size() != 100'",
|
'Internal bug detected: \'request.params[9].get_str() != "trigger_internal_bug"\'',
|
||||||
lambda: node.echo(*[0] * 100),
|
lambda: node.echo(arg9='trigger_internal_bug'),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.log.info("test getmemoryinfo")
|
self.log.info("test getmemoryinfo")
|
||||||
|
|
Loading…
Add table
Reference in a new issue