-
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
Added Error messages on Gateway_Balance and Channel_Authorize #4577
Closed
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
f7c5c65
Error messages for ApiV2
PeterChen13579 2b78768
added clang format
PeterChen13579 2eb175e
changed ledger->read to exist
PeterChen13579 e493534
quick fix
PeterChen13579 690ce23
changed env unit test based on ED's commit
PeterChen13579 0cd5145
Revert "changed env unit test based on ED's commit"
PeterChen13579 c843248
Merge remote-tracking branch 'upstream/master' into Error_messages
PeterChen13579 614cea4
Merge remote-tracking branch 'upstream/develop' into Error_messages
PeterChen13579 29971ca
changed unit test based on ED's API Beta commit
PeterChen13579 311e66c
Update src/test/app/PayChan_test.cpp
PeterChen13579 3adae5b
changed unittest based on Arihant's comment
PeterChen13579 dad2e8e
added clang format
PeterChen13579 7344b30
Fixed issue #4548 as dealing with same rpc
PeterChen13579 b1bae4d
Fix for arihant's comment
PeterChen13579 da46159
compare to 2u, for faster step
PeterChen13579 41fcf31
sign commit attempt
PeterChen13579 682a1a4
quick fix on Arihant's comment
PeterChen13579 920cd81
Merge remote-tracking branch 'upstream/develop' into Error_messages
PeterChen13579 21c5ebd
fixes based on Greg's comments
PeterChen13579 38e7f8e
move account/HW outside of loop
PeterChen13579 ce680b5
typo fix
PeterChen13579 092f6c3
refactor based on shawn's comments
PeterChen13579 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
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 |
---|---|---|
|
@@ -78,6 +78,12 @@ doGatewayBalances(RPC::JsonContext& context) | |
|
||
result[jss::account] = toBase58(accountID); | ||
|
||
if (!ledger->exists(keylet::account(accountID)) && context.apiVersion > 1u) | ||
{ | ||
RPC::inject_error(rpcACT_NOT_FOUND, result); | ||
return result; | ||
} | ||
|
||
// Parse the specified hotwallet(s), if any | ||
std::set<AccountID> hotWallets; | ||
|
||
|
@@ -116,7 +122,18 @@ doGatewayBalances(RPC::JsonContext& context) | |
|
||
if (!valid) | ||
{ | ||
result[jss::error] = "invalidHotWallet"; | ||
// The documentation states that invalidParams is used when | ||
// One or more fields are specified incorrectly. | ||
// invalidHotwallet should be used when the account exists, but does | ||
// not have currency issued by the account from the request. | ||
if (context.apiVersion < 2u) | ||
{ | ||
RPC::inject_error(rpcINVALID_HOTWALLET, result); | ||
} | ||
else | ||
{ | ||
RPC::inject_error(rpcINVALID_PARAMS, result); | ||
} | ||
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. brackets here as well |
||
return result; | ||
} | ||
} | ||
|
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
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 |
---|---|---|
|
@@ -24,9 +24,9 @@ | |
#include <ripple/protocol/PayChan.h> | ||
#include <ripple/protocol/TxFlags.h> | ||
#include <ripple/protocol/jss.h> | ||
#include <test/jtx.h> | ||
|
||
#include <ripple/rpc/impl/RPCHelpers.h> | ||
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. Why did you change the headers order? The original order and the new line looks right to me. |
||
#include <chrono> | ||
#include <test/jtx.h> | ||
|
||
namespace ripple { | ||
namespace test { | ||
|
@@ -1160,6 +1160,47 @@ struct PayChan_test : public beast::unit_test::suite | |
bob.human()); | ||
} | ||
|
||
void | ||
testAccountChannelAuthorize(FeatureBitset features) | ||
{ | ||
using namespace jtx; | ||
using namespace std::literals::chrono_literals; | ||
|
||
Env env{*this, features}; | ||
auto const alice = Account("alice"); | ||
auto const bob = Account("bob"); | ||
auto const charlie = Account("charlie", KeyType::ed25519); | ||
env.fund(XRP(10000), alice, bob, charlie); | ||
auto const pk = alice.pk(); | ||
auto const settleDelay = 3600s; | ||
auto const channelFunds = XRP(1000); | ||
auto const chan1Str = to_string(channel(alice, bob, env.seq(alice))); | ||
env(create(alice, bob, channelFunds, settleDelay, pk)); | ||
env.close(); | ||
|
||
Json::Value args{Json::objectValue}; | ||
args[jss::channel_id] = chan1Str; | ||
args[jss::key_type] = "ed255191"; | ||
args[jss::seed] = "snHq1rzQoN2qiUkC3XF5RyxBzUtN"; | ||
args[jss::amount] = 51110000; | ||
|
||
// test for all api versions | ||
for (auto apiVersion = RPC::apiMinimumSupportedVersion; | ||
apiVersion <= RPC::apiBetaVersion; | ||
++apiVersion) | ||
{ | ||
testcase( | ||
"PayChan Channel_Auth RPC Api " + std::to_string(apiVersion)); | ||
args[jss::api_version] = apiVersion; | ||
auto const rs = env.rpc( | ||
"json", | ||
"channel_authorize", | ||
args.toStyledString())[jss::result]; | ||
auto const error = apiVersion < 2u ? "invalidParams" : "badKeyType"; | ||
BEAST_EXPECT(rs[jss::error] == error); | ||
} | ||
} | ||
|
||
void | ||
testAuthVerifyRPC(FeatureBitset features) | ||
{ | ||
|
@@ -2139,6 +2180,7 @@ struct PayChan_test : public beast::unit_test::suite | |
testAccountChannelsRPC(features); | ||
testAccountChannelsRPCMarkers(features); | ||
testAccountChannelsRPCSenderOnly(features); | ||
testAccountChannelAuthorize(features); | ||
testAuthVerifyRPC(features); | ||
testOptionalFields(features); | ||
testMalformedPK(features); | ||
|
Oops, something went wrong.
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.
Please add
rpcINALID_HOT_WALLET
error and inject it into the result.