-
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4dadab6
Changed error messages on AccountTx
PeterChen13579 2f3c7e3
Fixed unit test based on comments given
PeterChen13579 f123188
Added clang format
PeterChen13579 42ca45f
Merge branch 'XRPLF:develop' into AccountTxErrorFixes
PeterChen13579 7c838eb
Merge remote-tracking branch 'upstream/develop' into AccountTxErrorFixes
PeterChen13579 ac88045
changed unit test based on Ed's change
PeterChen13579 86a9b31
changed unittest based on Arihant's comment
PeterChen13579 2e1e1a8
Merge branch 'develop' into AccountTxErrorFixes
intelliot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,7 @@ class AccountTx_test : public beast::unit_test::suite | |
}; | ||
|
||
Json::Value jParms; | ||
jParms[jss::api_version] = 1; | ||
|
||
BEAST_EXPECT(isErr( | ||
env.rpc("json", "account_tx", to_string(jParms)), | ||
|
@@ -205,6 +206,9 @@ class AccountTx_test : public beast::unit_test::suite | |
p[jss::ledger_index_max] = env.current()->info().seq; | ||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p)))); | ||
|
||
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; | ||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p)))); | ||
|
||
|
@@ -244,6 +248,83 @@ class AccountTx_test : public beast::unit_test::suite | |
} | ||
} | ||
|
||
void | ||
testParametersApiV2() | ||
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. Might wanna:
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. |
||
{ | ||
using namespace test::jtx; | ||
// test for API version 2 | ||
Env env{*this, envconfig([](std::unique_ptr<Config> c) { | ||
c->loadFromString("\n[beta_rpc_api]\n1\n"); | ||
return c; | ||
})}; | ||
PeterChen13579 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Account A1{"A1"}; | ||
env.fund(XRP(10000), A1); | ||
env.close(); | ||
|
||
auto hasTxs = [](Json::Value const& j) { | ||
return j.isMember(jss::result) && | ||
(j[jss::result][jss::status] == "success") && | ||
(j[jss::result][jss::transactions].size() == 2) && | ||
(j[jss::result][jss::transactions][0u][jss::tx] | ||
[jss::TransactionType] == jss::AccountSet) && | ||
(j[jss::result][jss::transactions][1u][jss::tx] | ||
[jss::TransactionType] == jss::Payment); | ||
}; | ||
|
||
auto isErr = [](Json::Value const& j, error_code_i code) { | ||
return j.isMember(jss::result) && | ||
j[jss::result].isMember(jss::error) && | ||
j[jss::result][jss::error] == RPC::get_error_info(code).token; | ||
}; | ||
|
||
Json::Value jParms; | ||
jParms[jss::api_version] = 2; | ||
jParms[jss::account] = A1.human(); | ||
|
||
// Ledger index max/min/index all specified | ||
// 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; | ||
|
||
BEAST_EXPECT(isErr( | ||
env.rpc("json", "account_tx", to_string(p)), | ||
rpcINVALID_PARAMS)); | ||
} | ||
|
||
// Ledger index min/max only | ||
{ | ||
Json::Value p{jParms}; | ||
p[jss::ledger_index_max] = 100; | ||
p[jss::ledger_index_min] = 0; | ||
BEAST_EXPECT(isErr( | ||
env.rpc("json", "account_tx", to_string(p)), | ||
rpcLGR_IDX_MALFORMED)); | ||
|
||
p[jss::ledger_index_max] = -1; | ||
p[jss::ledger_index_min] = -1; | ||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p)))); | ||
|
||
p[jss::ledger_index_min] = 2; | ||
p[jss::ledger_index_max] = 1; | ||
BEAST_EXPECT(isErr( | ||
env.rpc("json", "account_tx", to_string(p)), | ||
rpcINVALID_LGR_RANGE)); | ||
} | ||
|
||
// Ledger index max only | ||
{ | ||
Json::Value p{jParms}; | ||
p[jss::ledger_index_max] = env.current()->info().seq; | ||
BEAST_EXPECT(isErr( | ||
env.rpc("json", "account_tx", to_string(p)), | ||
rpcLGR_IDX_MALFORMED)); | ||
} | ||
} | ||
|
||
void | ||
testContents() | ||
{ | ||
|
@@ -594,6 +675,7 @@ class AccountTx_test : public beast::unit_test::suite | |
run() override | ||
{ | ||
testParameters(); | ||
testParametersApiV2(); | ||
testContents(); | ||
testAccountDelete(); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.