-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APIv2(ledger_entry): return "invalidParams" when fields missing #4552
Changes from all commits
e770f0f
0961be3
42ca435
3687956
973e2cb
744b419
50cbc1c
c095bfb
2da51ed
4cf4856
13bf9cf
b486afc
0ed7cde
8298953
90b04cb
eb61c13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
#include <ripple/beast/unit_test.h> | ||
#include <ripple/protocol/ErrorCodes.h> | ||
#include <ripple/protocol/jss.h> | ||
#include <ripple/rpc/impl/RPCHelpers.h> | ||
#include <test/jtx.h> | ||
|
||
namespace ripple { | ||
|
@@ -1212,21 +1213,28 @@ class LedgerRPC_test : public beast::unit_test::suite | |
} | ||
|
||
void | ||
testLedgerEntryUnknownOption() | ||
testLedgerEntryInvalidParams(unsigned int apiVersion) | ||
{ | ||
testcase("ledger_entry Request Unknown Option"); | ||
testcase( | ||
"ledger_entry Request With Invalid Parameters v" + | ||
std::to_string(apiVersion)); | ||
using namespace test::jtx; | ||
Env env{*this}; | ||
|
||
std::string const ledgerHash{to_string(env.closed()->info().hash)}; | ||
|
||
// "features" is not an option supported by ledger_entry. | ||
Json::Value jvParams; | ||
jvParams[jss::api_version] = apiVersion; | ||
jvParams[jss::features] = ledgerHash; | ||
jvParams[jss::ledger_hash] = ledgerHash; | ||
Json::Value const jrr = | ||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result]; | ||
checkErrorValue(jrr, "unknownOption", ""); | ||
|
||
if (apiVersion < 2u) | ||
checkErrorValue(jrr, "unknownOption", ""); | ||
else | ||
checkErrorValue(jrr, "invalidParams", ""); | ||
} | ||
|
||
/// @brief ledger RPC requests as a way to drive | ||
|
@@ -1724,11 +1732,18 @@ class LedgerRPC_test : public beast::unit_test::suite | |
testLedgerEntryPayChan(); | ||
testLedgerEntryRippleState(); | ||
testLedgerEntryTicket(); | ||
testLedgerEntryUnknownOption(); | ||
testLookupLedger(); | ||
testNoQueue(); | ||
testQueue(); | ||
testLedgerAccountsOption(); | ||
|
||
// version specific tests | ||
for (auto testVersion = RPC::apiMinimumSupportedVersion; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be beneficial to extract this into some sort of helper function (maybe in the next pr) as i imagine this will be copy-pasted all over the place very soon. Better do it sooner than later. I'd go with a variadic template accepting callables (functions expecting api version as their input). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are right, it will get copied. I'll try this out in the next PR. Thank you for pointing it out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any idea what would be the most appropriate file to put this helper in ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it's only going to be used in tests, it should be under Another alternative if you feel like rewriting this test again is to create a member function of I don't know for sure, though. |
||
testVersion <= RPC::apiBetaVersion; | ||
arihantkothari marked this conversation as resolved.
Show resolved
Hide resolved
|
||
++testVersion) | ||
{ | ||
testLedgerEntryInvalidParams(testVersion); | ||
} | ||
intelliot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the convention is in rippled but i'd use uint32_t or perhaps uint16_t. Fine as it is if others are happy though