mirror of
https://github.com/Xahau/xahaud.git
synced 2026-04-29 15:37:46 +00:00
APIv2(gateway_balances, channel_authorize): update errors (#4618)
gateway_balances * When `account` does not exist in the ledger, return `actNotFound` * (Previously, a normal response was returned) * Fix #4290 * When required field(s) are missing, return `invalidParams` * (Previously, `invalidHotWallet` was incorrectly returned) * Fix #4548 channel_authorize * When the specified `key_type` is invalid, return `badKeyType` * (Previously, `invalidParams` was returned) * Fix #4289 Since these are breaking changes, they apply only to API version 2. Supersedes #4577
This commit is contained in:
@@ -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>
|
||||
#include <chrono>
|
||||
#include <test/jtx.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace test {
|
||||
@@ -1144,6 +1144,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)
|
||||
{
|
||||
@@ -5653,6 +5694,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testAccountChannelsRPC(features);
|
||||
testAccountChannelsRPCMarkers(features);
|
||||
testAccountChannelsRPCSenderOnly(features);
|
||||
testAccountChannelAuthorize(features);
|
||||
testAuthVerifyRPC(features);
|
||||
testOptionalFields(features);
|
||||
testMalformedPK(features);
|
||||
|
||||
Reference in New Issue
Block a user