mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 20:05:51 +00:00
@@ -22,6 +22,7 @@
|
||||
#include "data/BackendInterface.hpp"
|
||||
#include "rpc/Errors.hpp"
|
||||
#include "rpc/JS.hpp"
|
||||
#include "rpc/common/MetaProcessors.hpp"
|
||||
#include "rpc/common/Modifiers.hpp"
|
||||
#include "rpc/common/Specs.hpp"
|
||||
#include "rpc/common/Types.hpp"
|
||||
@@ -32,7 +33,6 @@
|
||||
#include <boost/json/conversion.hpp>
|
||||
#include <ripple/basics/Number.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/STAmount.h>
|
||||
#include <ripple/protocol/STObject.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace rpc {
|
||||
|
||||
/**
|
||||
@@ -162,11 +163,13 @@ public:
|
||||
static auto const rpcSpec = RpcSpec{
|
||||
{JS(ledger_hash), validation::Uint256HexStringValidator},
|
||||
{JS(ledger_index), validation::LedgerIndexValidator},
|
||||
// note: Rippled's base_asset and quote_asset can be non-string. It will eventually return
|
||||
// "rpcOBJECT_NOT_FOUND". Clio will return "rpcINVALID_PARAMS" if the base_asset or quote_asset is not a
|
||||
// string. User can clearly know there is a mistake in the input.
|
||||
// validate quoteAsset in accordance to the currency code found in XRPL doc:
|
||||
// https://xrpl.org/docs/references/protocol/data-types/currency-formats#currency-codes
|
||||
// usually Clio returns rpcMALFORMED_CURRENCY , return InvalidParam here just to mimic rippled
|
||||
{JS(base_asset), validation::Required{}, validation::Type<std::string>{}},
|
||||
{JS(quote_asset), validation::Required{}, validation::Type<std::string>{}},
|
||||
{JS(quote_asset),
|
||||
validation::Required{},
|
||||
meta::WithCustomError{validation::CurrencyValidator, Status(RippledError::rpcINVALID_PARAMS)}},
|
||||
{JS(oracles), validation::Required{}, oraclesValidator},
|
||||
// note: Unlike `rippled`, Clio only supports UInt as input, no string, no `null`, etc.
|
||||
{JS(time_threshold), validation::Type<std::uint32_t>{}},
|
||||
|
||||
@@ -159,6 +159,38 @@ generateTestValuesForParametersTest()
|
||||
"invalidParams",
|
||||
"Required field 'quote_asset' missing"
|
||||
},
|
||||
GetAggregatePriceParamTestCaseBundle{
|
||||
"invalid_quote_asset",
|
||||
R"({
|
||||
"quote_asset" : "asdf",
|
||||
"base_asset": "USD",
|
||||
"oracles":
|
||||
[
|
||||
{
|
||||
"account": "rGh1VZCRBJY6rJiaFpD4LZtyHiuCkC8aeD",
|
||||
"oracle_document_id": 2
|
||||
}
|
||||
]
|
||||
})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."
|
||||
},
|
||||
GetAggregatePriceParamTestCaseBundle{
|
||||
"invalid_quote_asset2",
|
||||
R"({
|
||||
"quote_asset" : "+aa",
|
||||
"base_asset": "USD",
|
||||
"oracles":
|
||||
[
|
||||
{
|
||||
"account": "rGh1VZCRBJY6rJiaFpD4LZtyHiuCkC8aeD",
|
||||
"oracle_document_id": 2
|
||||
}
|
||||
]
|
||||
})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."
|
||||
},
|
||||
GetAggregatePriceParamTestCaseBundle{
|
||||
"oraclesIsEmpty",
|
||||
R"({
|
||||
|
||||
Reference in New Issue
Block a user