From 60f0f5224da2a235ce5457b52dbddcc105c85dd0 Mon Sep 17 00:00:00 2001 From: Mo Morsi Date: Thu, 26 Dec 2019 22:42:37 -0500 Subject: [PATCH] Accept 'strict' param in certain CLI options account_info, owner_info, account_currencies --- src/ripple/app/main/Main.cpp | 2 +- src/ripple/net/impl/RPCCall.cpp | 19 ++++++------ src/test/rpc/RPCCall_test.cpp | 51 +++++++++++++++++++++------------ 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index dbbb0b6ddb..21267db99d 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -133,7 +133,7 @@ void printHelp (const po::options_description& desc) " account_lines |\"\" []\n" " account_channels |\"\" []\n" " account_objects [] [strict]\n" - " account_offers | []\n" + " account_offers | [] [strict]\n" " account_tx accountID [ledger_min [ledger_max [limit [offset]]]] [binary] [count] [descending]\n" " book_offers [ [ [ []]]]]\n" " can_delete [||now|always|never]\n" diff --git a/src/ripple/net/impl/RPCCall.cpp b/src/ripple/net/impl/RPCCall.cpp index 1601f7ce9d..64f2941653 100644 --- a/src/ripple/net/impl/RPCCall.cpp +++ b/src/ripple/net/impl/RPCCall.cpp @@ -724,11 +724,11 @@ private: return jvRequest; } - // owner_info | - // owner_info || [] - // account_info | - // account_info || [] - // account_offers | [] + // owner_info | [strict] + // owner_info || [] [strict] + // account_info | [strict] + // account_info || [] [strict] + // account_offers | [] [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,8 +1580,7 @@ int fromCommandLine ( { auto const result = rpcClient(vCmd, config, logs); - if (result.first != rpcBAD_SYNTAX) - std::cout << result.second.toStyledString (); + std::cout << result.second.toStyledString (); return result.first; } diff --git a/src/test/rpc/RPCCall_test.cpp b/src/test/rpc/RPCCall_test.cpp index 186da9a11a..db253765e0 100644 --- a/src/test/rpc/RPCCall_test.cpp +++ b/src/test/rpc/RPCCall_test.cpp @@ -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 } ] })",