xrpld
Loading...
Searching...
No Matches
LedgerHeader_test.cpp
1#include <test/jtx/Env.h>
2#include <test/jtx/envconfig.h>
3
4#include <xrpl/beast/unit_test/suite.h>
5#include <xrpl/json/json_value.h>
6#include <xrpl/protocol/ErrorCodes.h>
7#include <xrpl/protocol/jss.h>
8
9namespace xrpl {
10
12{
13 void
15 {
16 testcase("Current ledger");
17 using namespace test::jtx;
18 Env env{*this, envconfig(noAdmin)};
19
21 params[jss::api_version] = 1;
22 params[jss::ledger_index] = "current";
23 auto const result = env.client().invoke("ledger_header", params)[jss::result];
24 BEAST_EXPECT(result[jss::status] == "success");
25 BEAST_EXPECT(result.isMember("ledger"));
26 BEAST_EXPECT(result[jss::ledger][jss::closed] == false);
27 BEAST_EXPECT(result[jss::validated] == false);
28 }
29
30 void
32 {
33 testcase("Validated ledger");
34 using namespace test::jtx;
35 Env env{*this, envconfig(noAdmin)};
36
38 params[jss::api_version] = 1;
39 params[jss::ledger_index] = "validated";
40 auto const result = env.client().invoke("ledger_header", params)[jss::result];
41 BEAST_EXPECT(result[jss::status] == "success");
42 BEAST_EXPECT(result.isMember("ledger"));
43 BEAST_EXPECT(result[jss::ledger][jss::closed] == true);
44 BEAST_EXPECT(result[jss::validated] == true);
45 }
46
47 void
49 {
50 testcase("Command retired from API v2");
51 using namespace test::jtx;
52 Env env{*this, envconfig(noAdmin)};
53
55 params[jss::api_version] = 2;
56 auto const result = env.client().invoke("ledger_header", params)[jss::result];
57 BEAST_EXPECT(result[jss::status] == "error");
58 BEAST_EXPECT(result[jss::error] == "unknownCmd");
59 BEAST_EXPECT(result[jss::error_code] == RpcUnknownCommand);
60 BEAST_EXPECT(result[jss::error_message] == "Unknown method.");
61 }
62
63public:
64 void
65 run() override
66 {
70 }
71};
72
74
75} // namespace xrpl
A testsuite class.
Definition suite.h:52
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
Represents a JSON value.
Definition json_value.h:121
void run() override
Runs the suite.
@ Object
object value (collection of name/value pairs).
Definition json_value.h:33
The api_version numbers this server serves.
Definition ApiVersion.h:26
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ RpcUnknownCommand
Definition ErrorCodes.h:68
BEAST_DEFINE_TESTSUITE(AccountTxPaging, app, xrpl)
Information about the notional ledger backing the view.