Compare commits

...

1 Commits
2.3.1 ... 2.2.0

Author SHA1 Message Date
cyan317
4940d463dc Fix empty currency (#1481) 2024-06-21 13:01:14 +01:00
2 changed files with 38 additions and 1 deletions

View File

@@ -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{};

View File

@@ -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"({