rippled
Loading...
Searching...
No Matches
LedgerClosed_test.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2016 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <test/jtx.h>
21
22#include <xrpl/protocol/Feature.h>
23#include <xrpl/protocol/jss.h>
24
25namespace ripple {
26
28{
29public:
30 void
32 {
33 using namespace test::jtx;
34
35 // This test relies on ledger hash so must lock it to fee 10.
36 auto p = envconfig();
37 p->FEES.reference_fee = 10;
38 Env env{*this, std::move(p), FeatureBitset{}};
39 Account const alice{"alice"};
40 env.fund(XRP(10000), alice);
41
42 auto lc_result = env.rpc("ledger_closed")[jss::result];
43 BEAST_EXPECT(
44 lc_result[jss::ledger_hash] ==
45 "CCC3B3E88CCAC17F1BE6B4A648A55999411F19E3FE55EB721960EB0DF28EDDA5");
46 BEAST_EXPECT(lc_result[jss::ledger_index] == 2);
47
48 env.close();
49 auto const ar_master = env.le(env.master);
50 BEAST_EXPECT(ar_master->getAccountID(sfAccount) == env.master.id());
51 BEAST_EXPECT((*ar_master)[sfBalance] == drops(99999989999999980));
52
53 auto const ar_alice = env.le(alice);
54 BEAST_EXPECT(ar_alice->getAccountID(sfAccount) == alice.id());
55 BEAST_EXPECT((*ar_alice)[sfBalance] == XRP(10000));
56
57 lc_result = env.rpc("ledger_closed")[jss::result];
58 BEAST_EXPECT(
59 lc_result[jss::ledger_hash] ==
60 "E86DE7F3D7A4D9CE17EF7C8BA08A8F4D8F643B9552F0D895A31CDA78F541DE4E");
61 BEAST_EXPECT(lc_result[jss::ledger_index] == 3);
62 }
63
64 void
65 run() override
66 {
68 }
69};
70
71BEAST_DEFINE_TESTSUITE(LedgerClosed, rpc, ripple);
72
73} // namespace ripple
A testsuite class.
Definition suite.h:55
void run() override
Runs the suite.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25