Accept 'strict' param in certain CLI options

account_info, owner_info, account_currencies
This commit is contained in:
Mo Morsi
2019-12-26 22:42:37 -05:00
committed by Nik Bougalis
parent 3578acaf0b
commit 60f0f5224d
3 changed files with 43 additions and 29 deletions

View File

@@ -133,7 +133,7 @@ void printHelp (const po::options_description& desc)
" account_lines <account> <account>|\"\" [<ledger>]\n"
" account_channels <account> <account>|\"\" [<ledger>]\n"
" account_objects <account> [<ledger>] [strict]\n"
" account_offers <account>|<account_public_key> [<ledger>]\n"
" account_offers <account>|<account_public_key> [<ledger>] [strict]\n"
" account_tx accountID [ledger_min [ledger_max [limit [offset]]]] [binary] [count] [descending]\n"
" book_offers <taker_pays> <taker_gets> [<taker [<ledger> [<limit> [<proof> [<marker>]]]]]\n"
" can_delete [<ledgerid>|<ledgerhash>|now|always|never]\n"

View File

@@ -724,11 +724,11 @@ private:
return jvRequest;
}
// owner_info <account>|<account_public_key>
// owner_info <seed>|<pass_phrase>|<key> [<ledfer>]
// account_info <account>|<account_public_key>
// account_info <seed>|<pass_phrase>|<key> [<ledger>]
// account_offers <account>|<account_public_key> [<ledger>]
// owner_info <account>|<account_public_key> [strict]
// owner_info <seed>|<pass_phrase>|<key> [<ledger>] [strict]
// account_info <account>|<account_public_key> [strict]
// account_info <seed>|<pass_phrase>|<key> [<ledger>] [strict]
// account_offers <account>|<account_public_key> [<ledger>] [strict]
Json::Value parseAccountItems (Json::Value const& jvParams)
{
return parseAccountRaw1 (jvParams);
@@ -1160,8 +1160,8 @@ public:
// Request-response methods
// - Returns an error, or the request.
// - To modify the method, provide a new method in the request.
{ "account_currencies", &RPCParser::parseAccountCurrencies, 1, 2 },
{ "account_info", &RPCParser::parseAccountItems, 1, 2 },
{ "account_currencies", &RPCParser::parseAccountCurrencies, 1, 3 },
{ "account_info", &RPCParser::parseAccountItems, 1, 3 },
{ "account_lines", &RPCParser::parseAccountLines, 1, 5 },
{ "account_channels", &RPCParser::parseAccountChannels, 1, 3 },
{ "account_objects", &RPCParser::parseAccountItems, 1, 5 },
@@ -1191,7 +1191,7 @@ public:
{ "log_level", &RPCParser::parseLogLevel, 0, 2 },
{ "logrotate", &RPCParser::parseAsIs, 0, 0 },
{ "manifest", &RPCParser::parseManifest, 1, 1 },
{ "owner_info", &RPCParser::parseAccountItems, 1, 2 },
{ "owner_info", &RPCParser::parseAccountItems, 1, 3 },
{ "peers", &RPCParser::parseAsIs, 0, 0 },
{ "ping", &RPCParser::parseAsIs, 0, 0 },
{ "print", &RPCParser::parseAsIs, 0, 1 },
@@ -1580,7 +1580,6 @@ int fromCommandLine (
{
auto const result = rpcClient(vCmd, config, logs);
if (result.first != rpcBAD_SYNTAX)
std::cout << result.second.toStyledString ();
return result.first;

View File

@@ -316,6 +316,26 @@ static RPCCallTestData const rpcCallTestArray [] =
]
})"
},
{
"account_currencies: current ledger.", __LINE__,
{
"account_currencies",
"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"current",
"strict"
},
RPCCallTestData::no_exception,
R"({
"method" : "account_currencies",
"params" : [
{
"account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"ledger_index" : "current",
"strict" : 1
}
]
})"
},
{
"account_currencies: too few arguments.", __LINE__,
{
@@ -339,7 +359,8 @@ static RPCCallTestData const rpcCallTestArray [] =
"account_currencies",
"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"current",
"strict"
"strict",
"spare"
},
RPCCallTestData::no_exception,
R"({
@@ -486,7 +507,6 @@ static RPCCallTestData const rpcCallTestArray [] =
})"
},
{
// Note: this works, but it doesn't match the documentation.
"account_info: strict.", __LINE__,
{
"account_info",
@@ -506,7 +526,6 @@ static RPCCallTestData const rpcCallTestArray [] =
})"
},
{
// Note: Somewhat according to the docs, this is should be valid syntax.
"account_info: with ledger index and strict.", __LINE__,
{
"account_info",
@@ -519,9 +538,9 @@ static RPCCallTestData const rpcCallTestArray [] =
"method" : "account_info",
"params" : [
{
"error" : "badSyntax",
"error_code" : 1,
"error_message" : "Syntax error."
"account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"ledger_index" : "validated",
"strict" : 1
}
]
})"
@@ -904,7 +923,6 @@ static RPCCallTestData const rpcCallTestArray [] =
})"
},
{
// Note: this works, but it doesn't match the documentation.
"account_objects: strict.", __LINE__,
{
"account_objects",
@@ -1168,7 +1186,6 @@ static RPCCallTestData const rpcCallTestArray [] =
})"
},
{
// Note: this works, but it doesn't match the documentation.
"account_offers: strict.", __LINE__,
{
"account_offers",
@@ -1188,7 +1205,6 @@ static RPCCallTestData const rpcCallTestArray [] =
})"
},
{
// Note: this works, but doesn't match the documentation.
"account_offers: with ledger index and strict.", __LINE__,
{
"account_offers",
@@ -4994,7 +5010,6 @@ static RPCCallTestData const rpcCallTestArray [] =
})"
},
{
// Note: this works, but it doesn't match the documentation.
"owner_info: strict.", __LINE__,
{
"owner_info",
@@ -5026,9 +5041,9 @@ static RPCCallTestData const rpcCallTestArray [] =
"method" : "owner_info",
"params" : [
{
"error" : "badSyntax",
"error_code" : 1,
"error_message" : "Syntax error."
"account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"ledger_index" : "validated",
"strict" : 1
}
]
})"
@@ -5092,7 +5107,7 @@ static RPCCallTestData const rpcCallTestArray [] =
{
// Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
// cannot currently occur because jvParseLedger() always returns true.
"owner_info: invalid ledger selection 1.", __LINE__,
"owner_info: invalid ledger selection.", __LINE__,
{
"owner_info",
"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
@@ -5113,7 +5128,7 @@ static RPCCallTestData const rpcCallTestArray [] =
{
// Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
// cannot currently occur because jvParseLedger() always returns true.
"owner_info: invalid ledger selection 2.", __LINE__,
"owner_info: invalid ledger selection and strict.", __LINE__,
{
"owner_info",
"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
@@ -5125,9 +5140,9 @@ static RPCCallTestData const rpcCallTestArray [] =
"method" : "owner_info",
"params" : [
{
"error" : "badSyntax",
"error_code" : 1,
"error_message" : "Syntax error."
"account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"ledger_index" : 0,
"strict" : 1
}
]
})",