mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Improve error handling in some RPC commands
This commit is contained in:
committed by
Ed Hennis
parent
2df635693d
commit
eba5d19377
@@ -36,6 +36,7 @@ public:
|
||||
void
|
||||
testErrors()
|
||||
{
|
||||
testcase("Errors");
|
||||
using namespace jtx;
|
||||
Env env(*this);
|
||||
{
|
||||
@@ -78,12 +79,53 @@ public:
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_message] == "Account malformed.");
|
||||
}
|
||||
{
|
||||
// Cannot pass a non-string into the `account` param
|
||||
|
||||
auto testInvalidAccountParam = [&](auto const& param) {
|
||||
Json::Value params;
|
||||
params[jss::account] = param;
|
||||
auto jrr = env.rpc(
|
||||
"json", "account_info", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'account'.");
|
||||
};
|
||||
|
||||
testInvalidAccountParam(1);
|
||||
testInvalidAccountParam(1.1);
|
||||
testInvalidAccountParam(true);
|
||||
testInvalidAccountParam(Json::Value(Json::nullValue));
|
||||
testInvalidAccountParam(Json::Value(Json::objectValue));
|
||||
testInvalidAccountParam(Json::Value(Json::arrayValue));
|
||||
}
|
||||
{
|
||||
// Cannot pass a non-string into the `ident` param
|
||||
|
||||
auto testInvalidIdentParam = [&](auto const& param) {
|
||||
Json::Value params;
|
||||
params[jss::ident] = param;
|
||||
auto jrr = env.rpc(
|
||||
"json", "account_info", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'ident'.");
|
||||
};
|
||||
|
||||
testInvalidIdentParam(1);
|
||||
testInvalidIdentParam(1.1);
|
||||
testInvalidIdentParam(true);
|
||||
testInvalidIdentParam(Json::Value(Json::nullValue));
|
||||
testInvalidIdentParam(Json::Value(Json::objectValue));
|
||||
testInvalidIdentParam(Json::Value(Json::arrayValue));
|
||||
}
|
||||
}
|
||||
|
||||
// Test the "signer_lists" argument in account_info.
|
||||
void
|
||||
testSignerLists()
|
||||
{
|
||||
testcase("Signer lists");
|
||||
using namespace jtx;
|
||||
Env env(*this);
|
||||
Account const alice{"alice"};
|
||||
@@ -205,6 +247,7 @@ public:
|
||||
void
|
||||
testSignerListsApiVersion2()
|
||||
{
|
||||
testcase("Signer lists APIv2");
|
||||
using namespace jtx;
|
||||
Env env{*this};
|
||||
Account const alice{"alice"};
|
||||
@@ -326,6 +369,7 @@ public:
|
||||
void
|
||||
testSignerListsV2()
|
||||
{
|
||||
testcase("Signer lists v2");
|
||||
using namespace jtx;
|
||||
Env env(*this);
|
||||
Account const alice{"alice"};
|
||||
@@ -515,6 +559,7 @@ public:
|
||||
void
|
||||
testAccountFlags(FeatureBitset const& features)
|
||||
{
|
||||
testcase("Account flags");
|
||||
using namespace jtx;
|
||||
|
||||
Env env(*this, features);
|
||||
@@ -652,7 +697,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(AccountInfo, app, ripple);
|
||||
BEAST_DEFINE_TESTSUITE(AccountInfo, rpc, ripple);
|
||||
|
||||
} // namespace test
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user