diff --git a/src/test/rpc/RPCCall_test.cpp b/src/test/rpc/RPCCall_test.cpp index 45914efd2d..6c75d59174 100644 --- a/src/test/rpc/RPCCall_test.cpp +++ b/src/test/rpc/RPCCall_test.cpp @@ -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 // ------------------------------------------------------------------------ diff --git a/src/xrpld/rpc/detail/RPCCall.cpp b/src/xrpld/rpc/detail/RPCCall.cpp index 09af2b9db1..6089912564 100644 --- a/src/xrpld/rpc/detail/RPCCall.cpp +++ b/src/xrpld/rpc/detail/RPCCall.cpp @@ -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; }