mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 11:55:51 +00:00
Fix empty currency (#1481)
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <fmt/core.h>
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/UintTypes.h>
|
||||
#include <ripple/protocol/tokens.h>
|
||||
|
||||
@@ -140,8 +141,12 @@ CustomValidator CurrencyValidator =
|
||||
if (!value.is_string())
|
||||
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotString"}};
|
||||
|
||||
auto const currencyStr = boost::json::value_to<std::string>(value);
|
||||
if (currencyStr.empty())
|
||||
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "IsEmpty"}};
|
||||
|
||||
ripple::Currency currency;
|
||||
if (!ripple::to_currency(currency, boost::json::value_to<std::string>(value)))
|
||||
if (!ripple::to_currency(currency, currencyStr))
|
||||
return Error{Status{ClioError::rpcMALFORMED_CURRENCY, "malformedCurrency"}};
|
||||
|
||||
return MaybeError{};
|
||||
|
||||
@@ -160,6 +160,22 @@ generateTestValuesForParametersTest()
|
||||
"invalidParams",
|
||||
"Invalid parameters."
|
||||
},
|
||||
GetAggregatePriceParamTestCaseBundle{
|
||||
"emtpy_base_asset",
|
||||
R"({
|
||||
"quote_asset" : "USD",
|
||||
"base_asset": "",
|
||||
"oracles":
|
||||
[
|
||||
{
|
||||
"account": "rGh1VZCRBJY6rJiaFpD4LZtyHiuCkC8aeD",
|
||||
"oracle_document_id": 2
|
||||
}
|
||||
]
|
||||
})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."
|
||||
},
|
||||
GetAggregatePriceParamTestCaseBundle{
|
||||
"invalid_base_asset2",
|
||||
R"({
|
||||
@@ -207,6 +223,22 @@ generateTestValuesForParametersTest()
|
||||
"invalidParams",
|
||||
"Invalid parameters."
|
||||
},
|
||||
GetAggregatePriceParamTestCaseBundle{
|
||||
"empty_quote_asset",
|
||||
R"({
|
||||
"quote_asset" : "",
|
||||
"base_asset": "USD",
|
||||
"oracles":
|
||||
[
|
||||
{
|
||||
"account": "rGh1VZCRBJY6rJiaFpD4LZtyHiuCkC8aeD",
|
||||
"oracle_document_id": 2
|
||||
}
|
||||
]
|
||||
})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."
|
||||
},
|
||||
GetAggregatePriceParamTestCaseBundle{
|
||||
"invalid_quote_asset2",
|
||||
R"({
|
||||
|
||||
Reference in New Issue
Block a user