fix tx_history

This commit is contained in:
Mayukha Vadari
2025-11-17 18:01:26 +05:30
parent f1f2cc70ab
commit 2116ea6eae
2 changed files with 37 additions and 7 deletions

View File

@@ -5616,24 +5616,51 @@ static RPCCallTestData const rpcCallTestArray[] = {
"tx_history: start too small.",
__LINE__,
{"tx_history", "-1"},
RPCCallTestData::bad_cast,
R"()",
RPCCallTestData::no_exception,
R"({
"method" : "tx_history",
"params" : [
{
"error" : "invalidParams",
"error_code" : 31,
"error_message" : "Invalid field 'start'."
}
]
})",
},
{
// Note: this really shouldn't throw, but does at the moment.
"tx_history: start too big.",
__LINE__,
{"tx_history", "4294967296"},
RPCCallTestData::bad_cast,
R"()",
RPCCallTestData::no_exception,
R"({
"method" : "tx_history",
"params" : [
{
"error" : "invalidParams",
"error_code" : 31,
"error_message" : "Invalid field 'start'."
}
]
})",
},
{
// Note: this really shouldn't throw, but does at the moment.
"tx_history: start not integer.",
__LINE__,
{"tx_history", "beginning"},
RPCCallTestData::bad_cast,
R"()",
RPCCallTestData::no_exception,
R"({
"method" : "tx_history",
"params" : [
{
"error" : "invalidParams",
"error_code" : 31,
"error_message" : "Invalid field 'start'."
}
]
})",
},
// unl_list

View File

@@ -1163,7 +1163,10 @@ private:
{
Json::Value jvRequest{Json::objectValue};
jvRequest[jss::start] = jvParams[0u].asUInt();
if (auto const start = jvParseUInt(jvParams[0u]))
jvRequest[jss::start] = *start;
else
return RPC::invalid_field_error(jss::start);
return jvRequest;
}