mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
refactor: replace string JSONs with Json::Value (#5886)
There are some tests that write out JSONs as a string instead of using the Json::Value library, which are cleaned up by this change. Co-authored-by: Bart Thomee <11445373+bthomee@users.noreply.github.com>
This commit is contained in:
@@ -3081,16 +3081,23 @@ public:
|
||||
env.fund(XRP(1000000), alice);
|
||||
env.close();
|
||||
|
||||
auto const withQueue =
|
||||
R"({ "account": ")" + alice.human() + R"(", "queue": true })";
|
||||
auto const withoutQueue = R"({ "account": ")" + alice.human() + R"("})";
|
||||
auto const prevLedgerWithQueue = R"({ "account": ")" + alice.human() +
|
||||
R"(", "queue": true, "ledger_index": 3 })";
|
||||
Json::Value withQueue;
|
||||
withQueue[jss::account] = alice.human();
|
||||
withQueue[jss::queue] = true;
|
||||
|
||||
Json::Value withoutQueue;
|
||||
withoutQueue[jss::account] = alice.human();
|
||||
|
||||
Json::Value prevLedgerWithQueue;
|
||||
prevLedgerWithQueue[jss::account] = alice.human();
|
||||
prevLedgerWithQueue[jss::queue] = true;
|
||||
prevLedgerWithQueue[jss::ledger_index] = 3;
|
||||
BEAST_EXPECT(env.current()->info().seq > 3);
|
||||
|
||||
{
|
||||
// account_info without the "queue" argument.
|
||||
auto const info = env.rpc("json", "account_info", withoutQueue);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withoutQueue));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -3098,7 +3105,8 @@ public:
|
||||
}
|
||||
{
|
||||
// account_info with the "queue" argument.
|
||||
auto const info = env.rpc("json", "account_info", withQueue);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withQueue));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -3120,7 +3128,8 @@ public:
|
||||
checkMetrics(*this, env, 0, 6, 4, 3);
|
||||
|
||||
{
|
||||
auto const info = env.rpc("json", "account_info", withQueue);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withQueue));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -3149,7 +3158,8 @@ public:
|
||||
checkMetrics(*this, env, 4, 6, 4, 3);
|
||||
|
||||
{
|
||||
auto const info = env.rpc("json", "account_info", withQueue);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withQueue));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -3212,7 +3222,8 @@ public:
|
||||
checkMetrics(*this, env, 1, 8, 5, 4);
|
||||
|
||||
{
|
||||
auto const info = env.rpc("json", "account_info", withQueue);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withQueue));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -3276,7 +3287,8 @@ public:
|
||||
checkMetrics(*this, env, 1, 8, 5, 4);
|
||||
|
||||
{
|
||||
auto const info = env.rpc("json", "account_info", withQueue);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withQueue));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -3344,7 +3356,7 @@ public:
|
||||
|
||||
{
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", prevLedgerWithQueue);
|
||||
env.rpc("json", "account_info", to_string(prevLedgerWithQueue));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
RPC::contains_error(info[jss::result]));
|
||||
@@ -3356,7 +3368,8 @@ public:
|
||||
checkMetrics(*this, env, 0, 10, 0, 5);
|
||||
|
||||
{
|
||||
auto const info = env.rpc("json", "account_info", withQueue);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withQueue));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
|
||||
@@ -58,10 +58,10 @@ public:
|
||||
{
|
||||
// account_info with an account that's not in the ledger.
|
||||
Account const bogie{"bogie"};
|
||||
auto const info = env.rpc(
|
||||
"json",
|
||||
"account_info",
|
||||
R"({ "account": ")" + bogie.human() + R"("})");
|
||||
Json::Value params;
|
||||
params[jss::account] = bogie.human();
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(params));
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_code] == rpcACT_NOT_FOUND);
|
||||
BEAST_EXPECT(
|
||||
@@ -128,16 +128,18 @@ public:
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(1000), alice);
|
||||
|
||||
auto const withoutSigners =
|
||||
std::string("{ ") + "\"account\": \"" + alice.human() + "\"}";
|
||||
Json::Value withoutSigners;
|
||||
withoutSigners[jss::account] = alice.human();
|
||||
|
||||
auto const withSigners = std::string("{ ") + "\"account\": \"" +
|
||||
alice.human() + "\", " + "\"signer_lists\": true }";
|
||||
Json::Value withSigners;
|
||||
withSigners[jss::account] = alice.human();
|
||||
withSigners[jss::signer_lists] = true;
|
||||
|
||||
// Alice has no SignerList yet.
|
||||
{
|
||||
// account_info without the "signer_lists" argument.
|
||||
auto const info = env.rpc("json", "account_info", withoutSigners);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withoutSigners));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -146,7 +148,8 @@ public:
|
||||
}
|
||||
{
|
||||
// account_info with the "signer_lists" argument.
|
||||
auto const info = env.rpc("json", "account_info", withSigners);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withSigners));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -164,7 +167,8 @@ public:
|
||||
env(smallSigners);
|
||||
{
|
||||
// account_info without the "signer_lists" argument.
|
||||
auto const info = env.rpc("json", "account_info", withoutSigners);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withoutSigners));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -173,7 +177,8 @@ public:
|
||||
}
|
||||
{
|
||||
// account_info with the "signer_lists" argument.
|
||||
auto const info = env.rpc("json", "account_info", withSigners);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withSigners));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -216,7 +221,8 @@ public:
|
||||
env(bigSigners);
|
||||
{
|
||||
// account_info with the "signer_lists" argument.
|
||||
auto const info = env.rpc("json", "account_info", withSigners);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withSigners));
|
||||
BEAST_EXPECT(
|
||||
info.isMember(jss::result) &&
|
||||
info[jss::result].isMember(jss::account_data));
|
||||
@@ -250,12 +256,14 @@ public:
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(1000), alice);
|
||||
|
||||
auto const withoutSigners = std::string("{ ") +
|
||||
"\"api_version\": 2, \"account\": \"" + alice.human() + "\"}";
|
||||
Json::Value withoutSigners;
|
||||
withoutSigners[jss::api_version] = 2;
|
||||
withoutSigners[jss::account] = alice.human();
|
||||
|
||||
auto const withSigners = std::string("{ ") +
|
||||
"\"api_version\": 2, \"account\": \"" + alice.human() + "\", " +
|
||||
"\"signer_lists\": true }";
|
||||
Json::Value withSigners;
|
||||
withSigners[jss::api_version] = 2;
|
||||
withSigners[jss::account] = alice.human();
|
||||
withSigners[jss::signer_lists] = true;
|
||||
|
||||
auto const withSignersAsString = std::string("{ ") +
|
||||
"\"api_version\": 2, \"account\": \"" + alice.human() + "\", " +
|
||||
@@ -264,13 +272,15 @@ public:
|
||||
// Alice has no SignerList yet.
|
||||
{
|
||||
// account_info without the "signer_lists" argument.
|
||||
auto const info = env.rpc("json", "account_info", withoutSigners);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withoutSigners));
|
||||
BEAST_EXPECT(info.isMember(jss::result));
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::signer_lists));
|
||||
}
|
||||
{
|
||||
// account_info with the "signer_lists" argument.
|
||||
auto const info = env.rpc("json", "account_info", withSigners);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withSigners));
|
||||
BEAST_EXPECT(info.isMember(jss::result));
|
||||
auto const& data = info[jss::result];
|
||||
BEAST_EXPECT(data.isMember(jss::signer_lists));
|
||||
@@ -286,13 +296,15 @@ public:
|
||||
env(smallSigners);
|
||||
{
|
||||
// account_info without the "signer_lists" argument.
|
||||
auto const info = env.rpc("json", "account_info", withoutSigners);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withoutSigners));
|
||||
BEAST_EXPECT(info.isMember(jss::result));
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::signer_lists));
|
||||
}
|
||||
{
|
||||
// account_info with the "signer_lists" argument.
|
||||
auto const info = env.rpc("json", "account_info", withSigners);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withSigners));
|
||||
BEAST_EXPECT(info.isMember(jss::result));
|
||||
auto const& data = info[jss::result];
|
||||
BEAST_EXPECT(data.isMember(jss::signer_lists));
|
||||
@@ -340,7 +352,8 @@ public:
|
||||
env(bigSigners);
|
||||
{
|
||||
// account_info with the "signer_lists" argument.
|
||||
auto const info = env.rpc("json", "account_info", withSigners);
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(withSigners));
|
||||
BEAST_EXPECT(info.isMember(jss::result));
|
||||
auto const& data = info[jss::result];
|
||||
BEAST_EXPECT(data.isMember(jss::signer_lists));
|
||||
@@ -567,10 +580,10 @@ public:
|
||||
auto getAccountFlag = [&env](
|
||||
std::string_view fName,
|
||||
Account const& account) {
|
||||
auto const info = env.rpc(
|
||||
"json",
|
||||
"account_info",
|
||||
R"({"account" : ")" + account.human() + R"("})");
|
||||
Json::Value params;
|
||||
params[jss::account] = account.human();
|
||||
auto const info =
|
||||
env.rpc("json", "account_info", to_string(params));
|
||||
|
||||
std::optional<bool> res;
|
||||
if (info[jss::result][jss::status] == "success" &&
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user