mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Remove SHAMap V2
This commit is contained in:
committed by
Manoj doshi
parent
33ab0cd7bd
commit
7228b2e068
@@ -1,80 +0,0 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2015 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/app/ledger/Ledger.h>
|
||||
#include <test/jtx.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace test {
|
||||
|
||||
// Test that converting a ledger to SHAMapV2
|
||||
// works as expected
|
||||
|
||||
class SHAMapV2_test : public beast::unit_test::suite
|
||||
{
|
||||
void
|
||||
testSHAMapV2()
|
||||
{
|
||||
jtx::Env env(*this);
|
||||
Config config;
|
||||
|
||||
std::set<uint256> amendments;
|
||||
std::vector<uint256> amendments_v;
|
||||
amendments_v.push_back(from_hex_text<uint256>("12345"));
|
||||
amendments.insert(from_hex_text<uint256>("12345"));
|
||||
|
||||
auto ledger =
|
||||
std::make_shared<Ledger>(create_genesis, config,
|
||||
amendments_v, env.app().family());
|
||||
BEAST_EXPECT(! getSHAMapV2 (ledger->info()));
|
||||
BEAST_EXPECT(ledger->stateMap().get_version() == SHAMap::version{1});
|
||||
BEAST_EXPECT(ledger->txMap().get_version() == SHAMap::version{1});
|
||||
BEAST_EXPECT(getEnabledAmendments(*ledger) == amendments);
|
||||
|
||||
ledger =
|
||||
std::make_shared<Ledger>(*ledger, NetClock::time_point{});
|
||||
BEAST_EXPECT(! getSHAMapV2 (ledger->info()));
|
||||
BEAST_EXPECT(ledger->stateMap().get_version() == SHAMap::version{1});
|
||||
BEAST_EXPECT(ledger->txMap().get_version() == SHAMap::version{1});
|
||||
BEAST_EXPECT(getEnabledAmendments(*ledger) == amendments);
|
||||
|
||||
ledger->make_v2();
|
||||
BEAST_EXPECT(getSHAMapV2 (ledger->info()));
|
||||
BEAST_EXPECT(ledger->stateMap().get_version() == SHAMap::version{2});
|
||||
BEAST_EXPECT(ledger->txMap().get_version() == SHAMap::version{2});
|
||||
BEAST_EXPECT(getEnabledAmendments(*ledger) == amendments);
|
||||
|
||||
ledger = std::make_shared<Ledger>(*ledger, NetClock::time_point{});
|
||||
BEAST_EXPECT(getSHAMapV2 (ledger->info()));
|
||||
BEAST_EXPECT(ledger->stateMap().get_version() == SHAMap::version{2});
|
||||
BEAST_EXPECT(ledger->txMap().get_version() == SHAMap::version{2});
|
||||
BEAST_EXPECT(getEnabledAmendments(*ledger) == amendments);
|
||||
}
|
||||
|
||||
void run() override
|
||||
{
|
||||
testSHAMapV2();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(SHAMapV2,ledger,ripple);
|
||||
|
||||
} // test
|
||||
} // ripple
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
|
||||
TestFamily f(journal);
|
||||
std::shared_ptr <Table> t1 (std::make_shared <Table> (
|
||||
SHAMapType::FREE, f, SHAMap::version{2}));
|
||||
SHAMapType::FREE, f));
|
||||
|
||||
pass ();
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
namespace ripple {
|
||||
namespace tests {
|
||||
|
||||
class sync_test : public beast::unit_test::suite
|
||||
class SHAMapSync_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
beast::xor_shift_engine eng_;
|
||||
@@ -90,18 +90,9 @@ public:
|
||||
using namespace beast::severities;
|
||||
test::SuiteJournal journal ("SHAMapSync_test", *this);
|
||||
|
||||
log << "Run, version 1\n" << std::endl;
|
||||
run(SHAMap::version{1}, journal);
|
||||
|
||||
log << "Run, version 2\n" << std::endl;
|
||||
run(SHAMap::version{2}, journal);
|
||||
}
|
||||
|
||||
void run(SHAMap::version v, beast::Journal const& journal)
|
||||
{
|
||||
TestFamily f(journal), f2(journal);
|
||||
SHAMap source (SHAMapType::FREE, f, v);
|
||||
SHAMap destination (SHAMapType::FREE, f2, v);
|
||||
SHAMap source (SHAMapType::FREE, f);
|
||||
SHAMap destination (SHAMapType::FREE, f2);
|
||||
|
||||
int items = 10000;
|
||||
for (int i = 0; i < items; ++i)
|
||||
@@ -207,9 +198,10 @@ public:
|
||||
log << "Checking destination invariants..." << std::endl;
|
||||
destination.invariants();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(sync,shamap,ripple);
|
||||
BEAST_DEFINE_TESTSUITE(SHAMapSync,shamap,ripple);
|
||||
|
||||
} // tests
|
||||
} // ripple
|
||||
|
||||
@@ -36,13 +36,6 @@ static_assert(!std::is_copy_assignable <SHAMap>{}, "");
|
||||
static_assert(!std::is_move_constructible <SHAMap>{}, "");
|
||||
static_assert(!std::is_move_assignable <SHAMap>{}, "");
|
||||
|
||||
static_assert( std::is_nothrow_destructible <SHAMap::version>{}, "");
|
||||
static_assert(!std::is_default_constructible <SHAMap::version>{}, "");
|
||||
static_assert( std::is_trivially_copy_constructible<SHAMap::version>{}, "");
|
||||
static_assert( std::is_trivially_copy_assignable <SHAMap::version>{}, "");
|
||||
static_assert( std::is_trivially_move_constructible<SHAMap::version>{}, "");
|
||||
static_assert( std::is_trivially_move_assignable <SHAMap::version>{}, "");
|
||||
|
||||
static_assert( std::is_nothrow_destructible <SHAMap::const_iterator>{}, "");
|
||||
static_assert( std::is_default_constructible<SHAMap::const_iterator>{}, "");
|
||||
static_assert( std::is_copy_constructible <SHAMap::const_iterator>{}, "");
|
||||
@@ -85,13 +78,6 @@ static_assert(!std::is_copy_assignable <SHAMapInnerNode>{}, "");
|
||||
static_assert(!std::is_move_constructible <SHAMapInnerNode>{}, "");
|
||||
static_assert(!std::is_move_assignable <SHAMapInnerNode>{}, "");
|
||||
|
||||
static_assert( std::is_nothrow_destructible <SHAMapInnerNodeV2>{}, "");
|
||||
static_assert(!std::is_default_constructible<SHAMapInnerNodeV2>{}, "");
|
||||
static_assert(!std::is_copy_constructible <SHAMapInnerNodeV2>{}, "");
|
||||
static_assert(!std::is_copy_assignable <SHAMapInnerNodeV2>{}, "");
|
||||
static_assert(!std::is_move_constructible <SHAMapInnerNodeV2>{}, "");
|
||||
static_assert(!std::is_move_assignable <SHAMapInnerNodeV2>{}, "");
|
||||
|
||||
static_assert( std::is_nothrow_destructible <SHAMapTreeNode>{}, "");
|
||||
static_assert(!std::is_default_constructible<SHAMapTreeNode>{}, "");
|
||||
static_assert(!std::is_copy_constructible <SHAMapTreeNode>{}, "");
|
||||
@@ -123,13 +109,11 @@ public:
|
||||
using namespace beast::severities;
|
||||
test::SuiteJournal journal ("SHAMap_test", *this);
|
||||
|
||||
run (true, SHAMap::version{1}, journal);
|
||||
run (false, SHAMap::version{1}, journal);
|
||||
run (true, SHAMap::version{2}, journal);
|
||||
run (false, SHAMap::version{2}, journal);
|
||||
run (true, journal);
|
||||
run (false, journal);
|
||||
}
|
||||
|
||||
void run (bool backed, SHAMap::version v, beast::Journal const& journal)
|
||||
void run (bool backed, beast::Journal const& journal)
|
||||
{
|
||||
if (backed)
|
||||
testcase ("add/traverse backed");
|
||||
@@ -146,7 +130,7 @@ public:
|
||||
h4.SetHex ("b92891fe4ef6cee585fdc6fda2e09eb4d386363158ec3321b8123e5a772c6ca8");
|
||||
h5.SetHex ("a92891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");
|
||||
|
||||
SHAMap sMap (SHAMapType::FREE, f, v);
|
||||
SHAMap sMap (SHAMapType::FREE, f);
|
||||
sMap.invariants();
|
||||
if (! backed)
|
||||
sMap.setUnbacked ();
|
||||
@@ -208,8 +192,6 @@ public:
|
||||
|
||||
sMap.dump();
|
||||
|
||||
auto const is_v2 = sMap.is_v2();
|
||||
|
||||
if (backed)
|
||||
testcase ("build/tear backed");
|
||||
else
|
||||
@@ -226,30 +208,16 @@ public:
|
||||
keys[7].SetHex ("292891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
|
||||
|
||||
std::vector<uint256> hashes(8);
|
||||
if (is_v2)
|
||||
{
|
||||
hashes[0].SetHex ("90F77DA53895E34042DC8048518CC98AD24276D0A96CCA2C515A83FDAF9F9FC9");
|
||||
hashes[1].SetHex ("425A3B6A68FAD9CB43B9981C7D0D39B942FE62110B437201057EE703F5E76390");
|
||||
hashes[2].SetHex ("1B4BE72DD18F90F367D64C0147D2414329149724339F79958D6470E7C99E3F4A");
|
||||
hashes[3].SetHex ("CCC18ED9B0C353278F02465E2E2F3A8A07427B458CF74C51D87ABE9C1B2ECAD8");
|
||||
hashes[4].SetHex ("24AF98675227F387CE0E4932B71B099FE8BC66E5F07BE2DA70D7E7D98E16C8BC");
|
||||
hashes[5].SetHex ("EAA373271474A9BF18F1CC240B40C7B5C83C7017977F1388771E56D5943F2B9B");
|
||||
hashes[6].SetHex ("C7968A323A06BD46769B402B2A85A7FE7F37FCE99C0004A6197AD8E5D76F200D");
|
||||
hashes[7].SetHex ("0A2412DBB16308706211E5FA5B0160817D54757B4DDC0CB105391A79D06B47BA");
|
||||
}
|
||||
else
|
||||
{
|
||||
hashes[0].SetHex ("B7387CFEA0465759ADC718E8C42B52D2309D179B326E239EB5075C64B6281F7F");
|
||||
hashes[1].SetHex ("FBC195A9592A54AB44010274163CB6BA95F497EC5BA0A8831845467FB2ECE266");
|
||||
hashes[2].SetHex ("4E7D2684B65DFD48937FFB775E20175C43AF0C94066F7D5679F51AE756795B75");
|
||||
hashes[3].SetHex ("7A2F312EB203695FFD164E038E281839EEF06A1B99BFC263F3CECC6C74F93E07");
|
||||
hashes[4].SetHex ("395A6691A372387A703FB0F2C6D2C405DAF307D0817F8F0E207596462B0E3A3E");
|
||||
hashes[5].SetHex ("D044C0A696DE3169CC70AE216A1564D69DE96582865796142CE7D98A84D9DDE4");
|
||||
hashes[6].SetHex ("76DCC77C4027309B5A91AD164083264D70B77B5E43E08AEDA5EBF94361143615");
|
||||
hashes[7].SetHex ("DF4220E93ADC6F5569063A01B4DC79F8DB9553B6A3222ADE23DEA02BBE7230E5");
|
||||
}
|
||||
hashes[0].SetHex ("B7387CFEA0465759ADC718E8C42B52D2309D179B326E239EB5075C64B6281F7F");
|
||||
hashes[1].SetHex ("FBC195A9592A54AB44010274163CB6BA95F497EC5BA0A8831845467FB2ECE266");
|
||||
hashes[2].SetHex ("4E7D2684B65DFD48937FFB775E20175C43AF0C94066F7D5679F51AE756795B75");
|
||||
hashes[3].SetHex ("7A2F312EB203695FFD164E038E281839EEF06A1B99BFC263F3CECC6C74F93E07");
|
||||
hashes[4].SetHex ("395A6691A372387A703FB0F2C6D2C405DAF307D0817F8F0E207596462B0E3A3E");
|
||||
hashes[5].SetHex ("D044C0A696DE3169CC70AE216A1564D69DE96582865796142CE7D98A84D9DDE4");
|
||||
hashes[6].SetHex ("76DCC77C4027309B5A91AD164083264D70B77B5E43E08AEDA5EBF94361143615");
|
||||
hashes[7].SetHex ("DF4220E93ADC6F5569063A01B4DC79F8DB9553B6A3222ADE23DEA02BBE7230E5");
|
||||
|
||||
SHAMap map (SHAMapType::FREE, f, v);
|
||||
SHAMap map (SHAMapType::FREE, f);
|
||||
if (! backed)
|
||||
map.setUnbacked ();
|
||||
|
||||
@@ -261,24 +229,6 @@ public:
|
||||
BEAST_EXPECT(map.getHash().as_uint256() == hashes[k]);
|
||||
map.invariants();
|
||||
}
|
||||
if (v == SHAMap::version{1})
|
||||
{
|
||||
BEAST_EXPECT(!map.is_v2());
|
||||
auto map_v2 = map.make_v2();
|
||||
BEAST_EXPECT(map_v2 != nullptr);
|
||||
BEAST_EXPECT(map_v2->is_v2());
|
||||
map_v2->invariants();
|
||||
auto m1 = map.begin();
|
||||
auto e1 = map.end();
|
||||
auto m2 = map_v2->begin();
|
||||
auto e2 = map_v2->end();
|
||||
for (; m1 != e1; ++m1, ++m2)
|
||||
{
|
||||
BEAST_EXPECT(m2 != e2);
|
||||
BEAST_EXPECT(*m1 == *m2);
|
||||
}
|
||||
BEAST_EXPECT(m2 == e2);
|
||||
}
|
||||
for (int k = keys.size() - 1; k >= 0; --k)
|
||||
{
|
||||
BEAST_EXPECT(map.getHash().as_uint256() == hashes[k]);
|
||||
@@ -305,7 +255,7 @@ public:
|
||||
keys[7].SetHex ("292891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
|
||||
|
||||
tests::TestFamily tf{journal};
|
||||
SHAMap map{SHAMapType::FREE, tf, v};
|
||||
SHAMap map{SHAMapType::FREE, tf};
|
||||
if (! backed)
|
||||
map.setUnbacked ();
|
||||
for (auto const& k : keys)
|
||||
|
||||
@@ -24,6 +24,5 @@
|
||||
#include <test/ledger/Invariants_test.cpp>
|
||||
#include <test/ledger/PaymentSandbox_test.cpp>
|
||||
#include <test/ledger/PendingSaves_test.cpp>
|
||||
#include <test/ledger/SHAMapV2_test.cpp>
|
||||
#include <test/ledger/SkipList_test.cpp>
|
||||
#include <test/ledger/View_test.cpp>
|
||||
|
||||
Reference in New Issue
Block a user