mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Format first-party source according to .clang-format
This commit is contained in:
committed by
manojsdoshi
parent
65dfc5d19e
commit
50760c6935
@@ -17,11 +17,11 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <test/jtx.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace RPC {
|
||||
class LedgerRequestRPC_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
|
||||
void testLedgerRequest()
|
||||
void
|
||||
testLedgerRequest()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
|
||||
@@ -44,69 +44,73 @@ public:
|
||||
{
|
||||
// arbitrary text is converted to 0.
|
||||
auto const result = env.rpc("ledger_request", "arbitrary_text");
|
||||
BEAST_EXPECT(RPC::contains_error(result[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
RPC::contains_error(result[jss::result]) &&
|
||||
result[jss::result][jss::error_message] ==
|
||||
"Ledger index too small");
|
||||
"Ledger index too small");
|
||||
}
|
||||
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "-1");
|
||||
BEAST_EXPECT(RPC::contains_error(result[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
RPC::contains_error(result[jss::result]) &&
|
||||
result[jss::result][jss::error_message] ==
|
||||
"Ledger index too small");
|
||||
"Ledger index too small");
|
||||
}
|
||||
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "0");
|
||||
BEAST_EXPECT(RPC::contains_error(result[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
RPC::contains_error(result[jss::result]) &&
|
||||
result[jss::result][jss::error_message] ==
|
||||
"Ledger index too small");
|
||||
}
|
||||
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "1");
|
||||
BEAST_EXPECT(!RPC::contains_error(result[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
!RPC::contains_error(result[jss::result]) &&
|
||||
result[jss::result][jss::ledger_index] == 1 &&
|
||||
result[jss::result].isMember(jss::ledger));
|
||||
BEAST_EXPECT(result[jss::result][jss::ledger].
|
||||
isMember(jss::ledger_hash) &&
|
||||
result[jss::result][jss::ledger]
|
||||
[jss::ledger_hash].isString());
|
||||
result[jss::result].isMember(jss::ledger));
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::ledger].isMember(jss::ledger_hash) &&
|
||||
result[jss::result][jss::ledger][jss::ledger_hash].isString());
|
||||
}
|
||||
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "2");
|
||||
BEAST_EXPECT(!RPC::contains_error(result[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
!RPC::contains_error(result[jss::result]) &&
|
||||
result[jss::result][jss::ledger_index] == 2 &&
|
||||
result[jss::result].isMember(jss::ledger));
|
||||
BEAST_EXPECT(result[jss::result][jss::ledger].
|
||||
isMember(jss::ledger_hash) &&
|
||||
result[jss::result][jss::ledger]
|
||||
[jss::ledger_hash].isString());
|
||||
result[jss::result].isMember(jss::ledger));
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::ledger].isMember(jss::ledger_hash) &&
|
||||
result[jss::result][jss::ledger][jss::ledger_hash].isString());
|
||||
}
|
||||
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "3");
|
||||
BEAST_EXPECT(!RPC::contains_error(result[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
!RPC::contains_error(result[jss::result]) &&
|
||||
result[jss::result][jss::ledger_index] == 3 &&
|
||||
result[jss::result].isMember(jss::ledger));
|
||||
BEAST_EXPECT(result[jss::result][jss::ledger].
|
||||
isMember(jss::ledger_hash) &&
|
||||
result[jss::result][jss::ledger]
|
||||
[jss::ledger_hash].isString());
|
||||
result[jss::result].isMember(jss::ledger));
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::ledger].isMember(jss::ledger_hash) &&
|
||||
result[jss::result][jss::ledger][jss::ledger_hash].isString());
|
||||
|
||||
auto const ledgerHash = result[jss::result]
|
||||
[jss::ledger][jss::ledger_hash].asString();
|
||||
auto const ledgerHash =
|
||||
result[jss::result][jss::ledger][jss::ledger_hash].asString();
|
||||
|
||||
{
|
||||
auto const r = env.rpc("ledger_request", ledgerHash);
|
||||
BEAST_EXPECT(!RPC::contains_error(r[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
!RPC::contains_error(r[jss::result]) &&
|
||||
r[jss::result][jss::ledger_index] == 3 &&
|
||||
r[jss::result].isMember(jss::ledger));
|
||||
BEAST_EXPECT(r[jss::result][jss::ledger].
|
||||
isMember(jss::ledger_hash) &&
|
||||
r[jss::result][jss::ledger]
|
||||
[jss::ledger_hash] == ledgerHash);
|
||||
r[jss::result].isMember(jss::ledger));
|
||||
BEAST_EXPECT(
|
||||
r[jss::result][jss::ledger].isMember(jss::ledger_hash) &&
|
||||
r[jss::result][jss::ledger][jss::ledger_hash] ==
|
||||
ledgerHash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +119,8 @@ public:
|
||||
|
||||
auto const result = env.rpc("ledger_request", ledgerHash);
|
||||
|
||||
BEAST_EXPECT(RPC::contains_error(result[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
RPC::contains_error(result[jss::result]) &&
|
||||
result[jss::result][jss::error_message] ==
|
||||
"Invalid field 'ledger_hash'.");
|
||||
}
|
||||
@@ -125,32 +130,35 @@ public:
|
||||
|
||||
auto const result = env.rpc("ledger_request", ledgerHash);
|
||||
|
||||
BEAST_EXPECT(!RPC::contains_error(result[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
!RPC::contains_error(result[jss::result]) &&
|
||||
result[jss::result][jss::have_header] == false);
|
||||
}
|
||||
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "4");
|
||||
BEAST_EXPECT(RPC::contains_error(result[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
RPC::contains_error(result[jss::result]) &&
|
||||
result[jss::result][jss::error_message] ==
|
||||
"Ledger index too large");
|
||||
}
|
||||
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "5");
|
||||
BEAST_EXPECT(RPC::contains_error(result[jss::result]) &&
|
||||
BEAST_EXPECT(
|
||||
RPC::contains_error(result[jss::result]) &&
|
||||
result[jss::result][jss::error_message] ==
|
||||
"Ledger index too large");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void testEvolution()
|
||||
void
|
||||
testEvolution()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
Env env {*this, FeatureBitset{}}; //the hashes being checked below assume
|
||||
//no amendments
|
||||
Account const gw { "gateway" };
|
||||
Env env{*this, FeatureBitset{}}; // the hashes being checked below
|
||||
// assume no amendments
|
||||
Account const gw{"gateway"};
|
||||
auto const USD = gw["USD"];
|
||||
env.fund(XRP(100000), gw);
|
||||
env.close();
|
||||
@@ -167,90 +175,141 @@ public:
|
||||
env.fund(XRP(1000), "carol");
|
||||
env.close();
|
||||
|
||||
auto result = env.rpc ( "ledger_request", "1" ) [jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "1");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::total_coins] == "100000000000000000");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_hash] == "AB868A6CFEEC779C2FF845C0AF00A642259986AF40C01976A7F842B6918936C7");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::parent_hash] == "0000000000000000000000000000000000000000000000000000000000000000");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::account_hash] == "A21ED30C04C88046FC61DB9DC19375EEDBD365FD8C17286F27127DF804E9CAA6");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::transaction_hash] == "0000000000000000000000000000000000000000000000000000000000000000");
|
||||
auto result = env.rpc("ledger_request", "1")[jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "1");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::total_coins] == "100000000000000000");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::ledger_hash] ==
|
||||
"AB868A6CFEEC779C2FF845C0AF00A642259986AF40C01976A7F842B6918936C7");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::parent_hash] ==
|
||||
"0000000000000000000000000000000000000000000000000000000000000000");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::account_hash] ==
|
||||
"A21ED30C04C88046FC61DB9DC19375EEDBD365FD8C17286F27127DF804E9CAA6");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::transaction_hash] ==
|
||||
"0000000000000000000000000000000000000000000000000000000000000000");
|
||||
|
||||
result = env.rpc ( "ledger_request", "2" ) [jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "2");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::total_coins] == "100000000000000000");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_hash] == "8AEDBB96643962F1D40F01E25632ABB3C56C9F04B0231EE4B18248B90173D189");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::parent_hash] == "AB868A6CFEEC779C2FF845C0AF00A642259986AF40C01976A7F842B6918936C7");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::account_hash] == "183D5235C7C1FB5AE67AD2F6CC3B28F5FB86E8C4F89DB50DD85641A96470534E");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::transaction_hash] == "0000000000000000000000000000000000000000000000000000000000000000");
|
||||
result = env.rpc("ledger_request", "2")[jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "2");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::total_coins] == "100000000000000000");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::ledger_hash] ==
|
||||
"8AEDBB96643962F1D40F01E25632ABB3C56C9F04B0231EE4B18248B90173D189");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::parent_hash] ==
|
||||
"AB868A6CFEEC779C2FF845C0AF00A642259986AF40C01976A7F842B6918936C7");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::account_hash] ==
|
||||
"183D5235C7C1FB5AE67AD2F6CC3B28F5FB86E8C4F89DB50DD85641A96470534E");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::transaction_hash] ==
|
||||
"0000000000000000000000000000000000000000000000000000000000000000");
|
||||
|
||||
result = env.rpc ( "ledger_request", "3" ) [jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "3");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::total_coins] == "99999999999999980");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_hash] == "D2EE1E2A7288AAD43D6FA8AD8007FD1A95646F365EF3A1AD608A03258F11CF18");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::parent_hash] == "8AEDBB96643962F1D40F01E25632ABB3C56C9F04B0231EE4B18248B90173D189");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::account_hash] == "22565DC00D1A30F2C15871714E512976EF476281E5E87FF63D3E129C9069F4F4");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::transaction_hash] == "0213EC486C058B3942FBE3DAC6839949A5C5B02B8B4244C8998EFDF04DBD8222");
|
||||
result = env.rpc("ledger_request", "3")[jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "3");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::total_coins] == "99999999999999980");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::ledger_hash] ==
|
||||
"D2EE1E2A7288AAD43D6FA8AD8007FD1A95646F365EF3A1AD608A03258F11CF18");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::parent_hash] ==
|
||||
"8AEDBB96643962F1D40F01E25632ABB3C56C9F04B0231EE4B18248B90173D189");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::account_hash] ==
|
||||
"22565DC00D1A30F2C15871714E512976EF476281E5E87FF63D3E129C9069F4F4");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::transaction_hash] ==
|
||||
"0213EC486C058B3942FBE3DAC6839949A5C5B02B8B4244C8998EFDF04DBD8222");
|
||||
|
||||
result = env.rpc ( "ledger_request", "4" ) [jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "4");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::total_coins] == "99999999999999960");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_hash] == "8F9032390CDD4C9D7A5B216AFDA3B525A3B39D7589C69D90D4C6BCA4619DD33C");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::parent_hash] == "D2EE1E2A7288AAD43D6FA8AD8007FD1A95646F365EF3A1AD608A03258F11CF18");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::account_hash] == "C3335CA14E712CB28F2A7C09BEB9A24BF30BBFA5528F156C19F6665D7A588FEA");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::transaction_hash] == "3CBDB8F42E04333E1642166BFB93AC9A7E1C6C067092CD5D881D6F3AB3D67E76");
|
||||
result = env.rpc("ledger_request", "4")[jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "4");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::total_coins] == "99999999999999960");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::ledger_hash] ==
|
||||
"8F9032390CDD4C9D7A5B216AFDA3B525A3B39D7589C69D90D4C6BCA4619DD33C");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::parent_hash] ==
|
||||
"D2EE1E2A7288AAD43D6FA8AD8007FD1A95646F365EF3A1AD608A03258F11CF18");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::account_hash] ==
|
||||
"C3335CA14E712CB28F2A7C09BEB9A24BF30BBFA5528F156C19F6665D7A588FEA");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::transaction_hash] ==
|
||||
"3CBDB8F42E04333E1642166BFB93AC9A7E1C6C067092CD5D881D6F3AB3D67E76");
|
||||
|
||||
result = env.rpc ( "ledger_request", "5" ) [jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "5");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::total_coins] == "99999999999999940");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_hash] == "3EDEB201735867A8EEECBC79A75902C05A7E3F192E4C12E02E67BFDDE5566CCE");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::parent_hash] == "8F9032390CDD4C9D7A5B216AFDA3B525A3B39D7589C69D90D4C6BCA4619DD33C");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::account_hash] == "7C77B1E9EB86410D84EE0CD50716AAA21192F19CF533194AD705798895248212");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::transaction_hash] == "C3D086CD6BDB9E97AD1D513B2C049EF2840BD21D0B3E22D84EBBB89B6D2EF59D");
|
||||
result = env.rpc("ledger_request", "5")[jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "5");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::total_coins] == "99999999999999940");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::ledger_hash] ==
|
||||
"3EDEB201735867A8EEECBC79A75902C05A7E3F192E4C12E02E67BFDDE5566CCE");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::parent_hash] ==
|
||||
"8F9032390CDD4C9D7A5B216AFDA3B525A3B39D7589C69D90D4C6BCA4619DD33C");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::account_hash] ==
|
||||
"7C77B1E9EB86410D84EE0CD50716AAA21192F19CF533194AD705798895248212");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::transaction_hash] ==
|
||||
"C3D086CD6BDB9E97AD1D513B2C049EF2840BD21D0B3E22D84EBBB89B6D2EF59D");
|
||||
|
||||
result = env.rpc ( "ledger_request", "6" ) [jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
result = env.rpc("ledger_request", "6")[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error_message] == "Ledger index too large");
|
||||
}
|
||||
|
||||
void testBadInput()
|
||||
void
|
||||
testBadInput()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
Env env { *this };
|
||||
Account const gw { "gateway" };
|
||||
Env env{*this};
|
||||
Account const gw{"gateway"};
|
||||
auto const USD = gw["USD"];
|
||||
env.fund(XRP(100000), gw);
|
||||
env.close();
|
||||
|
||||
Json::Value jvParams;
|
||||
jvParams[jss::ledger_hash] = "AB868A6CFEEC779C2FF845C0AF00A642259986AF40C01976A7F842B6918936C7";
|
||||
jvParams[jss::ledger_hash] =
|
||||
"AB868A6CFEEC779C2FF845C0AF00A642259986AF40C01976A7F842B6918936C7";
|
||||
jvParams[jss::ledger_index] = "1";
|
||||
auto result = env.rpc ("json", "ledger_request", jvParams.toStyledString()) [jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error_message] == "Exactly one of ledger_hash and ledger_index can be set.");
|
||||
auto result = env.rpc(
|
||||
"json", "ledger_request", jvParams.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] ==
|
||||
"Exactly one of ledger_hash and ledger_index can be set.");
|
||||
|
||||
// the purpose in this test is to force the ledger expiration/out of
|
||||
// date check to trigger
|
||||
env.timeKeeper().adjustCloseTime(weeks{3});
|
||||
result = env.rpc ( "ledger_request", "1" ) [jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "noCurrent");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error_message] == "Current ledger is unavailable.");
|
||||
|
||||
result = env.rpc("ledger_request", "1")[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "noCurrent");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] == "Current ledger is unavailable.");
|
||||
}
|
||||
|
||||
void testMoreThan256Closed()
|
||||
void
|
||||
testMoreThan256Closed()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
using namespace std::chrono_literals;
|
||||
Env env {*this};
|
||||
Account const gw {"gateway"};
|
||||
Env env{*this};
|
||||
Account const gw{"gateway"};
|
||||
env.app().getLedgerMaster().tune(0, 1h);
|
||||
auto const USD = gw["USD"];
|
||||
env.fund(XRP(100000), gw);
|
||||
@@ -259,39 +318,49 @@ public:
|
||||
|
||||
for (auto i = 0; i < max_limit + 10; i++)
|
||||
{
|
||||
Account const bob {std::string("bob") + std::to_string(i)};
|
||||
Account const bob{std::string("bob") + std::to_string(i)};
|
||||
env.fund(XRP(1000), bob);
|
||||
env.close();
|
||||
}
|
||||
|
||||
auto result = env.rpc ( "ledger_request", "1" ) [jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "1");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::total_coins] == "100000000000000000");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_hash] == "AB868A6CFEEC779C2FF845C0AF00A642259986AF40C01976A7F842B6918936C7");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::parent_hash] == "0000000000000000000000000000000000000000000000000000000000000000");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::account_hash] == "A21ED30C04C88046FC61DB9DC19375EEDBD365FD8C17286F27127DF804E9CAA6");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::transaction_hash] == "0000000000000000000000000000000000000000000000000000000000000000");
|
||||
auto result = env.rpc("ledger_request", "1")[jss::result];
|
||||
BEAST_EXPECT(result[jss::ledger][jss::ledger_index] == "1");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::total_coins] == "100000000000000000");
|
||||
BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::ledger_hash] ==
|
||||
"AB868A6CFEEC779C2FF845C0AF00A642259986AF40C01976A7F842B6918936C7");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::parent_hash] ==
|
||||
"0000000000000000000000000000000000000000000000000000000000000000");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::account_hash] ==
|
||||
"A21ED30C04C88046FC61DB9DC19375EEDBD365FD8C17286F27127DF804E9CAA6");
|
||||
BEAST_EXPECT(
|
||||
result[jss::ledger][jss::transaction_hash] ==
|
||||
"0000000000000000000000000000000000000000000000000000000000000000");
|
||||
}
|
||||
|
||||
void testNonAdmin()
|
||||
void
|
||||
testNonAdmin()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
Env env { *this, envconfig(no_admin) };
|
||||
Account const gw { "gateway" };
|
||||
Env env{*this, envconfig(no_admin)};
|
||||
Account const gw{"gateway"};
|
||||
auto const USD = gw["USD"];
|
||||
env.fund(XRP(100000), gw);
|
||||
env.close();
|
||||
|
||||
auto const result = env.rpc ( "ledger_request", "1" ) [jss::result];
|
||||
auto const result = env.rpc("ledger_request", "1")[jss::result];
|
||||
// The current HTTP/S ServerHandler returns an HTTP 403 error code here
|
||||
// rather than a noPermission JSON error. The JSONRPCClient just eats that
|
||||
// error and returns an null result.
|
||||
// rather than a noPermission JSON error. The JSONRPCClient just eats
|
||||
// that error and returns an null result.
|
||||
BEAST_EXPECT(result.type() == Json::nullValue);
|
||||
|
||||
}
|
||||
|
||||
void run () override
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testLedgerRequest();
|
||||
testEvolution();
|
||||
@@ -301,8 +370,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(LedgerRequestRPC,app,ripple);
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
BEAST_DEFINE_TESTSUITE(LedgerRequestRPC, app, ripple);
|
||||
|
||||
} // namespace RPC
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user