mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
APIv2(account_tx, noripple_check): return error on invalid input (#4620)
For the `account_tx` and `noripple_check` methods, perform input validation for optional parameters such as "binary", "forward", "strict", "transactions". Previously, when these parameters had invalid values (e.g. not a bool), no error would be returned. Now, it returns an `invalidParams` error. * This updates the behavior to match Clio (https://github.com/XRPLF/clio). * Since this is potentially a breaking change, it only applies to requests specifying api_version: 2. * Fix #4543.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <ripple/protocol/Feature.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <ripple/rpc/impl/RPCHelpers.h>
|
||||
#include <test/jtx.h>
|
||||
|
||||
namespace ripple {
|
||||
@@ -202,9 +203,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
testDefaultRipple(FeatureBitset features)
|
||||
testDefaultRipple(FeatureBitset features, unsigned int apiVersion)
|
||||
{
|
||||
testcase("Set default ripple on an account and check new trustlines");
|
||||
testcase(
|
||||
"Set default ripple on an account and check new trustlines "
|
||||
"Version " +
|
||||
std::to_string(apiVersion));
|
||||
|
||||
using namespace jtx;
|
||||
Env env(*this, features);
|
||||
@@ -221,9 +225,10 @@ public:
|
||||
|
||||
env(trust(gw, USD(100), alice, 0));
|
||||
env(trust(gw, USD(100), bob, 0));
|
||||
Json::Value params;
|
||||
params[jss::api_version] = apiVersion;
|
||||
|
||||
{
|
||||
Json::Value params;
|
||||
params[jss::account] = gw.human();
|
||||
params[jss::peer] = alice.human();
|
||||
|
||||
@@ -232,7 +237,6 @@ public:
|
||||
BEAST_EXPECT(line0[jss::no_ripple_peer].asBool() == true);
|
||||
}
|
||||
{
|
||||
Json::Value params;
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::peer] = gw.human();
|
||||
|
||||
@@ -241,7 +245,6 @@ public:
|
||||
BEAST_EXPECT(line0[jss::no_ripple].asBool() == true);
|
||||
}
|
||||
{
|
||||
Json::Value params;
|
||||
params[jss::account] = gw.human();
|
||||
params[jss::peer] = bob.human();
|
||||
|
||||
@@ -250,7 +253,6 @@ public:
|
||||
BEAST_EXPECT(line0[jss::no_ripple].asBool() == false);
|
||||
}
|
||||
{
|
||||
Json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::peer] = gw.human();
|
||||
|
||||
@@ -258,6 +260,22 @@ public:
|
||||
auto const& line0 = lines[jss::result][jss::lines][0u];
|
||||
BEAST_EXPECT(line0[jss::no_ripple_peer].asBool() == false);
|
||||
}
|
||||
{
|
||||
// test for transactions
|
||||
{
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::role] = "gateway";
|
||||
params[jss::transactions] = "asdf";
|
||||
|
||||
auto lines =
|
||||
env.rpc("json", "noripple_check", to_string(params));
|
||||
if (apiVersion < 2u)
|
||||
BEAST_EXPECT(lines[jss::result][jss::status] == "success");
|
||||
else
|
||||
BEAST_EXPECT(
|
||||
lines[jss::result][jss::error] == "invalidParams");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -266,9 +284,14 @@ public:
|
||||
testSetAndClear();
|
||||
|
||||
auto withFeatsTests = [this](FeatureBitset features) {
|
||||
for (auto testVersion = RPC::apiMinimumSupportedVersion;
|
||||
testVersion <= RPC::apiBetaVersion;
|
||||
++testVersion)
|
||||
{
|
||||
testDefaultRipple(features, testVersion);
|
||||
}
|
||||
testNegativeBalance(features);
|
||||
testPairwise(features);
|
||||
testDefaultRipple(features);
|
||||
};
|
||||
using namespace jtx;
|
||||
auto const sa = supported_amendments();
|
||||
|
||||
Reference in New Issue
Block a user