20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/ledger/LedgerToJson.h>
22 #include <ripple/beast/utility/temp_dir.h>
23 #include <ripple/core/ConfigSections.h>
24 #include <ripple/nodestore/DatabaseShard.h>
25 #include <ripple/nodestore/DummyScheduler.h>
26 #include <ripple/nodestore/Manager.h>
27 #include <ripple/nodestore/impl/DecodedBlob.h>
28 #include <ripple/nodestore/impl/EncodedBlob.h>
29 #include <ripple/nodestore/impl/Shard.h>
32 #include <test/nodestore/TestBase.h>
97 for (
int j = 0; j < p; ++j)
104 }
while (from == to);
114 for (
int j = 0; j < 8; ++j)
135 using namespace test::jtx;
158 if (ledger->info().seq != i)
184 using namespace test::jtx;
189 for (
auto const& sles : ledger->sles)
195 const auto id = sles->getAccountID(
sfAccount);
197 for (
int i = 0; i < data.accounts_.size(); ++i)
199 if (
id == data.accounts_[i].id())
202 for (
int j = 0; j <= seq; ++j)
203 if (data.nAccounts_[j] > i + 1 ||
204 (data.nAccounts_[j] == i + 1 &&
205 !data.isNewAccounts(j)))
207 for (
int k = 0; k < data.payAccounts_[j].size();
209 if (data.payAccounts_[j][k].first == i)
220 reqsq = data.nAccounts_[seq] + 1;
223 BEAST_EXPECT(sq == reqsq);
228 BEAST_EXPECT(rootCount == 1);
229 BEAST_EXPECT(accCount == data.nAccounts_[seq]);
230 BEAST_EXPECT(sothCount == 3);
236 for (
auto const& tx : ledger->txs)
241 tx.first->getFieldAmount(
sfAmount).xrp().decimalXRP();
247 BEAST_EXPECT(xrpAmount == data.xrpAmount_[seq]);
255 int newacc = data.isNewAccounts(seq) ? 1 : 0;
256 BEAST_EXPECT(iniCount == newacc);
257 BEAST_EXPECT(setCount == newacc);
258 BEAST_EXPECT(payCount == data.payAccounts_[seq].size());
259 BEAST_EXPECT(tothCount == !seq);
275 std::move(s.modData()),
285 node.getType() == SHAMapAbstractNode::TNType::tnINNER
289 node.getNodeHash().as_uint256(),
298 if (next && next->info().parentHash == ledger.
info().
hash)
300 auto have = next->stateMap().snapShot(
false);
309 auto visitTx = [&](SHAMapAbstractNode& node) {
313 node.getType() == SHAMapAbstractNode::TNType::tnINNER
316 std::move(s.modData()),
317 node.getNodeHash().as_uint256(),
336 if (!BEAST_EXPECT(fetched))
359 node.getType() == SHAMapAbstractNode::TNType::tnINNER
363 node.getNodeHash().as_uint256())};
364 if (!BEAST_EXPECT(nSrc))
368 db.
fetch(node.getNodeHash().as_uint256(), ledger.
info().
seq);
369 if (!BEAST_EXPECT(nDst))
372 BEAST_EXPECT(
isSame(nSrc, nDst));
383 node.getType() == SHAMapAbstractNode::TNType::tnINNER
387 node.getNodeHash().as_uint256())};
388 if (!BEAST_EXPECT(nSrc))
392 db.
fetch(node.getNodeHash().as_uint256(), ledger.
info().
seq);
393 if (!BEAST_EXPECT(nDst))
396 BEAST_EXPECT(
isSame(nSrc, nDst));
414 if (bitmask & (1ll << i))
435 using namespace test::jtx;
440 "DatabaseShard " + testName +
" with backend " + backendType;
485 auto end = start + timeout;
487 !boost::icl::contains(rs, shardNumber))
500 int shardNumber = -1;
505 if (!BEAST_EXPECT(ind != boost::none))
511 BEAST_EXPECT(
saveLedger(db, *data.ledgers_[arrInd]));
519 s.
addRaw(data.ledgers_[arrInd]->info().hash.data(), 256 / 8);
531 using namespace test::jtx;
534 Env env{*
this,
testConfig(
"standalone", backendType, shardDir.
path())};
542 BEAST_EXPECT(db->ledgersPerShard() == db->ledgersPerShardDefault);
543 BEAST_EXPECT(db->init());
552 BEAST_EXPECT(db->getRootDir().string() == shardDir.
path());
560 using namespace test::jtx;
563 Env env{*
this,
testConfig(
"createShard", backendType, shardDir.
path())};
568 if (!BEAST_EXPECT(data.makeLedgers(env)))
583 using namespace test::jtx;
594 if (!BEAST_EXPECT(data.makeLedgers(env)))
607 if (!BEAST_EXPECT(data.makeLedgers(env)))
623 using namespace test::jtx;
633 if (!BEAST_EXPECT(data.makeLedgers(env)))
643 if (!BEAST_EXPECT(n && *n >= 1 && *n <=
nTestShards))
645 bitMask |= 1ll << *n;
655 using namespace test::jtx;
664 if (!BEAST_EXPECT(data.makeLedgers(env)))
673 if (bitMask & (1ll << n))
676 bitMask &= ~(1ll << n);
703 if (!BEAST_EXPECT(n && *n >= 1 && *n <=
nTestShards))
705 bitMask2 |= 1ll << *n;
708 BEAST_EXPECT((bitMask & bitMask2) == 0);
709 if ((bitMask | bitMask2) == ((1ll <<
nTestShards) - 1) << 1)
724 using namespace test::jtx;
736 if (!BEAST_EXPECT(data.makeLedgers(env)))
745 data.ledgers_.clear();
748 boost::filesystem::path importPath(importDir.
path());
757 if (!BEAST_EXPECT(data.makeLedgers(env)))
767 if (!BEAST_EXPECT(n && *n == 1))
780 using namespace test::jtx;
789 "corruptedDatabase", backendType, shardDir.
path())};
793 if (!BEAST_EXPECT(data.makeLedgers(env)))
801 boost::filesystem::path path = shardDir.
path();
803 path /= backendType +
".dat";
805 FILE* f = fopen(path.string().c_str(),
"r+b");
806 if (!BEAST_EXPECT(f))
810 BEAST_EXPECT(fwrite(buf, 1, 256, f) == 256);
819 if (!BEAST_EXPECT(data.makeLedgers(env)))
837 using namespace test::jtx;
839 for (
int i = 0; i < 5; ++i)
846 (i == 0 ?
"illegalFinalKey" :
""),
853 if (!BEAST_EXPECT(data.makeLedgers(env)))
856 int shardNumber = -1;
860 if (!BEAST_EXPECT(ind != boost::none))
865 BEAST_EXPECT(
saveLedger(*db, *data.ledgers_[arrInd]));
874 data.ledgers_[arrInd - (i == 4)]
891 boost::filesystem::path path(shardDir.
path());
893 boost::system::error_code ec;
897 boost::filesystem::exists(path, ec))
914 if (!BEAST_EXPECT(data.makeLedgers(env)))
936 using namespace test::jtx;
944 "import", backendType, shardDir.
path(), nodeDir.
path())};
946 Database& ndb = env.app().getNodeStore();
950 if (!BEAST_EXPECT(data.makeLedgers(env)))
954 BEAST_EXPECT(
saveLedger(ndb, *data.ledgers_[i]));
968 if (!BEAST_EXPECT(data.makeLedgers(env)))
1006 #if RIPPLE_ROCKSDB_AVAILABLE
1010 #if RIPPLE_ENABLE_SQLITE_BACKEND_TESTS