fix get_counts

This commit is contained in:
Mayukha Vadari
2025-11-17 17:59:50 +05:30
parent 9e23d50339
commit f1f2cc70ab
2 changed files with 28 additions and 5 deletions

View File

@@ -3002,13 +3002,31 @@ static RPCCallTestData const rpcCallTestArray[] = {
"get_counts",
"-1",
},
RPCCallTestData::bad_cast,
R"()"},
RPCCallTestData::no_exception,
R"({
"method" : "get_counts",
"params" : [
{
"error" : "invalidParams",
"error_code" : 31,
"error_message" : "Invalid field 'min_count'."
}
]
})"},
{"get_counts: count too large.",
__LINE__,
{"get_counts", "4294967296"},
RPCCallTestData::bad_cast,
R"()"},
RPCCallTestData::no_exception,
R"({
"method" : "get_counts",
"params" : [
{
"error" : "invalidParams",
"error_code" : 31,
"error_message" : "Invalid field 'min_count'."
}
]
})"},
// json
// ------------------------------------------------------------------------

View File

@@ -546,7 +546,12 @@ private:
Json::Value jvRequest(Json::objectValue);
if (jvParams.size())
jvRequest[jss::min_count] = jvParams[0u].asUInt();
{
if (auto minCount = jvParseUInt(jvParams[0u]))
jvRequest[jss::min_count] = *minCount;
else
return RPC::invalid_field_error(jss::min_count);
}
return jvRequest;
}