mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 18:45:52 +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)'=='debug|x64'">True</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</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">
|
<ClCompile Include="..\..\src\test\rpc\LedgerData_test.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||||
|
|||||||
@@ -5415,6 +5415,9 @@
|
|||||||
<ClCompile Include="..\..\src\test\rpc\KeyGeneration_test.cpp">
|
<ClCompile Include="..\..\src\test\rpc\KeyGeneration_test.cpp">
|
||||||
<Filter>test\rpc</Filter>
|
<Filter>test\rpc</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\test\rpc\LedgerClosed_test.cpp">
|
||||||
|
<Filter>test\rpc</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\test\rpc\LedgerData_test.cpp">
|
<ClCompile Include="..\..\src\test\rpc\LedgerData_test.cpp">
|
||||||
<Filter>test\rpc</Filter>
|
<Filter>test\rpc</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
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,6 +27,7 @@
|
|||||||
#include <test/rpc/GatewayBalances_test.cpp>
|
#include <test/rpc/GatewayBalances_test.cpp>
|
||||||
#include <test/rpc/JSONRPC_test.cpp>
|
#include <test/rpc/JSONRPC_test.cpp>
|
||||||
#include <test/rpc/KeyGeneration_test.cpp>
|
#include <test/rpc/KeyGeneration_test.cpp>
|
||||||
|
#include <test/rpc/LedgerClosed_test.cpp>
|
||||||
#include <test/rpc/LedgerData_test.cpp>
|
#include <test/rpc/LedgerData_test.cpp>
|
||||||
#include <test/rpc/LedgerRequestRPC_test.cpp>
|
#include <test/rpc/LedgerRequestRPC_test.cpp>
|
||||||
#include <test/rpc/RobustTransaction_test.cpp>
|
#include <test/rpc/RobustTransaction_test.cpp>
|
||||||
|
|||||||
Reference in New Issue
Block a user