File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 2929#include < fmt/core.h>
3030#include < ripple/basics/base_uint.h>
3131#include < ripple/protocol/AccountID.h>
32+ #include < ripple/protocol/ErrorCodes.h>
3233#include < ripple/protocol/UintTypes.h>
3334#include < ripple/protocol/tokens.h>
3435
@@ -140,8 +141,12 @@ CustomValidator CurrencyValidator =
140141 if (!value.is_string ())
141142 return Error{Status{RippledError::rpcINVALID_PARAMS, std::string (key) + " NotString" }};
142143
144+ auto const currencyStr = boost::json::value_to<std::string>(value);
145+ if (currencyStr.empty ())
146+ return Error{Status{RippledError::rpcINVALID_PARAMS, std::string (key) + " IsEmpty" }};
147+
143148 ripple::Currency currency;
144- if (!ripple::to_currency (currency, boost::json::value_to<std::string>(value) ))
149+ if (!ripple::to_currency (currency, currencyStr ))
145150 return Error{Status{ClioError::rpcMALFORMED_CURRENCY, " malformedCurrency" }};
146151
147152 return MaybeError{};
Original file line number Diff line number Diff line change @@ -160,6 +160,22 @@ generateTestValuesForParametersTest()
160160 " invalidParams" ,
161161 " Invalid parameters."
162162 },
163+ GetAggregatePriceParamTestCaseBundle{
164+ " emtpy_base_asset" ,
165+ R"( {
166+ "quote_asset" : "USD",
167+ "base_asset": "",
168+ "oracles":
169+ [
170+ {
171+ "account": "rGh1VZCRBJY6rJiaFpD4LZtyHiuCkC8aeD",
172+ "oracle_document_id": 2
173+ }
174+ ]
175+ })" ,
176+ " invalidParams" ,
177+ " Invalid parameters."
178+ },
163179 GetAggregatePriceParamTestCaseBundle{
164180 " invalid_base_asset2" ,
165181 R"( {
@@ -207,6 +223,22 @@ generateTestValuesForParametersTest()
207223 " invalidParams" ,
208224 " Invalid parameters."
209225 },
226+ GetAggregatePriceParamTestCaseBundle{
227+ " empty_quote_asset" ,
228+ R"( {
229+ "quote_asset" : "",
230+ "base_asset": "USD",
231+ "oracles":
232+ [
233+ {
234+ "account": "rGh1VZCRBJY6rJiaFpD4LZtyHiuCkC8aeD",
235+ "oracle_document_id": 2
236+ }
237+ ]
238+ })" ,
239+ " invalidParams" ,
240+ " Invalid parameters."
241+ },
210242 GetAggregatePriceParamTestCaseBundle{
211243 " invalid_quote_asset2" ,
212244 R"( {
You can’t perform that action at this time.
0 commit comments