-
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(AccountTx): Added error messages on AccountTx #4571
Changes from 1 commit
4dadab6
2f3c7e3
f123188
42ca45f
7c838eb
ac88045
86a9b31
2e1e1a8
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 |
---|---|---|
|
@@ -241,7 +241,7 @@ extern beast::SemanticVersion const lastVersion; | |
constexpr unsigned int apiInvalidVersion = 0; | ||
constexpr unsigned int apiVersionIfUnspecified = 1; | ||
constexpr unsigned int apiMinimumSupportedVersion = 1; | ||
constexpr unsigned int apiMaximumSupportedVersion = 1; | ||
constexpr unsigned int apiMaximumSupportedVersion = 2; | ||
constexpr unsigned int apiBetaVersion = 2; | ||
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. Don't change the 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. Just wondering what do you mean by "until the updated version is locked in and final and ready for release."? Do you you mean until PR #4522 is merged into develop, so I don't have to change apiMaximumSupportedVersion to 2? 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. I'll be popping over to add the same kind of comment to #4568 and #4552 after I'm done here. "until the updated version is locked in and final and ready for release" means that once a version of Now, if you (and #4568 and #4552) are saying that version 2 is done, let's talk about version 2 being done. This will be the first I've heard about it. If you want a node to properly handle API v2 requests, the correct way to do that, for now, is with the 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. Please see also #4573. 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. Just to close the loop on this: API v2 will be considered "Done" in the 1.12 release. Any breaking changes in 1.13 will be API v3. |
||
|
||
static_assert(apiMinimumSupportedVersion >= apiVersionIfUnspecified); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,11 +166,21 @@ class AccountTx_test : public beast::unit_test::suite | |
|
||
p[jss::ledger_index_min] = 0; | ||
p[jss::ledger_index_max] = 100; | ||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p)))); | ||
RPC::apiMaximumSupportedVersion == 1 | ||
? BEAST_EXPECT( | ||
hasTxs(env.rpc("json", "account_tx", to_string(p)))) | ||
: BEAST_EXPECT(isErr( | ||
env.rpc("json", "account_tx", to_string(p)), | ||
rpcLGR_IDX_MALFORMED)); | ||
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 should copy these tests for an explicit 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. To follow on @thejohnfreeman's suggestion, loop over both versions for these tests, because we need to keep supporting version 1 indefinitely and ensure it's working correctly. |
||
|
||
p[jss::ledger_index_min] = 1; | ||
p[jss::ledger_index_max] = 2; | ||
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p)))); | ||
RPC::apiMaximumSupportedVersion == 1 | ||
? BEAST_EXPECT( | ||
noTxs(env.rpc("json", "account_tx", to_string(p)))) | ||
: BEAST_EXPECT(isErr( | ||
env.rpc("json", "account_tx", to_string(p)), | ||
rpcLGR_IDX_MALFORMED)); | ||
|
||
p[jss::ledger_index_min] = 2; | ||
p[jss::ledger_index_max] = 1; | ||
|
@@ -187,6 +197,14 @@ class AccountTx_test : public beast::unit_test::suite | |
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p)))); | ||
|
||
p[jss::ledger_index_min] = 1; | ||
RPC::apiMaximumSupportedVersion == 1 | ||
? BEAST_EXPECT( | ||
hasTxs(env.rpc("json", "account_tx", to_string(p)))) | ||
: BEAST_EXPECT(isErr( | ||
env.rpc("json", "account_tx", to_string(p)), | ||
rpcLGR_IDX_MALFORMED)); | ||
|
||
p[jss::ledger_index_min] = 2; | ||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p)))); | ||
|
||
p[jss::ledger_index_min] = env.current()->info().seq; | ||
|
@@ -203,6 +221,14 @@ class AccountTx_test : public beast::unit_test::suite | |
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p)))); | ||
|
||
p[jss::ledger_index_max] = env.current()->info().seq; | ||
RPC::apiMaximumSupportedVersion == 1 | ||
? BEAST_EXPECT( | ||
hasTxs(env.rpc("json", "account_tx", to_string(p)))) | ||
: BEAST_EXPECT(isErr( | ||
env.rpc("json", "account_tx", to_string(p)), | ||
rpcLGR_IDX_MALFORMED)); | ||
|
||
p[jss::ledger_index_max] = 3; | ||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p)))); | ||
|
||
p[jss::ledger_index_max] = env.closed()->info().seq; | ||
|
@@ -212,6 +238,21 @@ class AccountTx_test : public beast::unit_test::suite | |
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p)))); | ||
} | ||
|
||
// Ledger index max/min/index | ||
// ERRORS out with invalid Parenthesis | ||
{ | ||
Json::Value p{jParms}; | ||
p[jss::ledger_index_max] = -1; | ||
p[jss::ledger_index_min] = -1; | ||
p[jss::ledger_index] = -1; | ||
RPC::apiMaximumSupportedVersion == 1 | ||
? BEAST_EXPECT( | ||
hasTxs(env.rpc("json", "account_tx", to_string(p)))) | ||
: BEAST_EXPECT(isErr( | ||
env.rpc("json", "account_tx", to_string(p)), | ||
rpcINVALID_PARAMS)); | ||
} | ||
|
||
// Ledger Sequence | ||
{ | ||
Json::Value p{jParms}; | ||
|
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.
not so important, but I'm wondering if it'll be nice to make constants like API_VERSION_1 and API_VERSION_2 instead of using raw numbers 1 and 2 since we are using it in a lot of places ?
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 don't think it's worth it when we're just using consecutive integers to name the versions.