mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-18 18:15:50 +00:00
Add LedgerClosed test (RIPD-1272)
Migrate the logic in monitor-test.js to a new jtx test that covers the ledger_closed RPC method.
This commit is contained in:
committed by
Nik Bougalis
parent
87756b9324
commit
ad9be4dbf6
@@ -4720,6 +4720,10 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\test\rpc\LedgerClosed_test.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\test\rpc\LedgerData_test.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
|
||||
@@ -5415,6 +5415,9 @@
|
||||
<ClCompile Include="..\..\src\test\rpc\KeyGeneration_test.cpp">
|
||||
<Filter>test\rpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\test\rpc\LedgerClosed_test.cpp">
|
||||
<Filter>test\rpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\test\rpc\LedgerData_test.cpp">
|
||||
<Filter>test\rpc</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -94,4 +94,4 @@
|
||||
#include <ripple/rpc/impl/Role.cpp>
|
||||
#include <ripple/rpc/impl/RPCHelpers.cpp>
|
||||
#include <ripple/rpc/impl/ServerHandlerImp.cpp>
|
||||
#include <ripple/rpc/impl/TransactionSign.cpp>
|
||||
#include <ripple/rpc/impl/TransactionSign.cpp>
|
||||
|
||||
64
src/test/rpc/LedgerClosed_test.cpp
Normal file
64
src/test/rpc/LedgerClosed_test.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2016 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/protocol/Feature.h>
|
||||
#include <ripple/test/jtx.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class LedgerClosed_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
|
||||
void testMonitorRoot()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
Env env {*this};
|
||||
Account const alice {"alice"};
|
||||
env.fund(XRP(10000), alice);
|
||||
|
||||
auto lc_result = env.rpc("ledger_closed") [jss::result];
|
||||
BEAST_EXPECT(lc_result[jss::ledger_hash] == "8AEDBB96643962F1D40F01E25632ABB3C56C9F04B0231EE4B18248B90173D189");
|
||||
BEAST_EXPECT(lc_result[jss::ledger_index] == 2);
|
||||
|
||||
env.close();
|
||||
auto const ar_master = env.le(env.master);
|
||||
BEAST_EXPECT(ar_master->getAccountID(sfAccount) == env.master.id());
|
||||
BEAST_EXPECT((*ar_master)[sfBalance] == drops( 99999989999999980 ));
|
||||
|
||||
auto const ar_alice = env.le(alice);
|
||||
BEAST_EXPECT(ar_alice->getAccountID(sfAccount) == alice.id());
|
||||
BEAST_EXPECT((*ar_alice)[sfBalance] == XRP( 10000 ));
|
||||
|
||||
lc_result = env.rpc("ledger_closed") [jss::result];
|
||||
BEAST_EXPECT(lc_result[jss::ledger_hash] == "7C3EEDB3124D92E49E75D81A8826A2E65A75FD71FC3FD6F36FEB803C5F1D812D");
|
||||
BEAST_EXPECT(lc_result[jss::ledger_index] == 3);
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
testMonitorRoot();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(LedgerClosed,app,ripple);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,9 +27,10 @@
|
||||
#include <test/rpc/GatewayBalances_test.cpp>
|
||||
#include <test/rpc/JSONRPC_test.cpp>
|
||||
#include <test/rpc/KeyGeneration_test.cpp>
|
||||
#include <test/rpc/LedgerClosed_test.cpp>
|
||||
#include <test/rpc/LedgerData_test.cpp>
|
||||
#include <test/rpc/LedgerRequestRPC_test.cpp>
|
||||
#include <test/rpc/RobustTransaction_test.cpp>
|
||||
#include <test/rpc/ServerInfo_test.cpp>
|
||||
#include <test/rpc/Status_test.cpp>
|
||||
#include <test/rpc/Subscribe_test.cpp>
|
||||
#include <test/rpc/Subscribe_test.cpp>
|
||||
|
||||
Reference in New Issue
Block a user