1#include <xrpl/nodestore/Database.h>
3#include <xrpl/basics/ByteUtilities.h>
4#include <xrpl/basics/FileUtilities.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/beast/xor_shift_engine.h>
7#include <xrpl/config/BasicConfig.h>
8#include <xrpl/nodestore/DummyScheduler.h>
9#include <xrpl/nodestore/Manager.h>
10#include <xrpl/nodestore/Types.h>
11#include <xrpl/protocol/SystemParameters.h>
13#include <gtest/gtest.h>
14#include <helpers/TestSink.h>
15#include <nodestore/TestBase.h>
27std::vector<std::string>
30#if XRPL_ROCKSDB_AVAILABLE
31 return {
"memory",
"nudb",
"rocksdb"};
33 return {
"memory",
"nudb"};
37std::vector<std::string>
40 std::vector<std::string> types{
"nudb"};
41#if XRPL_ROCKSDB_AVAILABLE
47std::vector<std::string>
50 std::vector<std::string> types{
"nudb"};
51#if XRPL_ROCKSDB_AVAILABLE
54#ifdef XRPL_ENABLE_SQLITE_BACKEND_TESTS
100 auto db = makeDatabase();
105 SCOPED_TRACE(
"read in original order");
107 EXPECT_EQ(batch_, copy);
111 SCOPED_TRACE(
"read in shuffled order");
115 EXPECT_EQ(batch_, copy);
122 auto db = makeDatabase();
127 auto db = makeDatabase();
132 EXPECT_EQ(batch_, copy);
139 auto db = makeDatabase();
148 ::testing::ValuesIn(allBackends()),
149 [](::testing::TestParamInfo<std::string>
const& info) {
return info.param; });
154 ::testing::ValuesIn(persistentBackends()),
155 [](::testing::TestParamInfo<std::string>
const& info) {
return info.param; });
157TEST(NodeStoreDatabase, memory_earliest_seq)
162 nodeParams.
set(
"type",
"memory");
163 nodeParams.
set(
"path", nodeDb.
path());
175 nodeParams.
set(
"earliest_seq",
"0");
180 FAIL() <<
"expected runtime_error for earliest_seq=0";
184 EXPECT_STREQ(e.
what(),
"Invalid earliest_seq");
190 nodeParams.
set(
"earliest_seq",
"1");
192 EXPECT_EQ(db->earliestLedgerSeq(), 1u);
202 auto const type = GetParam();
209 srcParams.
set(
"type", type);
210 srcParams.
set(
"path", srcDir.
path());
227 destParams.
set(
"type", type);
228 destParams.
set(
"path", destDir.
path());
233 dest->importDatabase(*src);
239 EXPECT_EQ(batch, copy);
245 ::testing::ValuesIn(importBackends()),
246 [](::testing::TestParamInfo<std::string>
const& info) {
return info.param; });
A generic endpoint for log messages.
Holds a collection of configuration values.
void set(std::string const &key, std::string const &value)
Set a key/value pair.
RAII temporary directory.
std::string path() const
Get the native path for the temporary directory.
static TestSink & instance()
Simple NodeStore Scheduler that just performs the tasks synchronously.
virtual std::unique_ptr< Database > makeDatabase(std::size_t burstSize, Scheduler &scheduler, int readThreads, Section const &backendParameters, beast::Journal journal)=0
Construct a NodeStore database.
static Manager & instance()
Returns the instance of the manager singleton.
std::unique_ptr< Database > makeDatabase()
beast::Journal const journal_
DummyScheduler scheduler_
T emplace_back(T... args)
detail::XorShiftEngine<> xor_shift_engine
XOR-shift Generator.
constexpr std::uint64_t kSeedValue
TEST_P(BackendTypeTest, store_and_fetch)
INSTANTIATE_TEST_SUITE_P(BackendTypes, BackendTypeTest, ::testing::ValuesIn(backendTypes()), [](::testing::TestParamInfo< std::string > const &info) { return info.param;})
TEST(NodeStoreBasics, predictable_batches)
std::vector< std::shared_ptr< NodeObject > > Batch
A batch of NodeObjects to write at once.
Batch createPredictableBatch(std::size_t numObjects, std::uint64_t seed)
constexpr int kNumObjects
void storeBatch(Backend &backend, Batch const &batch)
void fetchMissing(Backend &backend, Batch const &batch)
Batch fetchCopyOfBatch(Backend &backend, Batch const &batch)
constexpr auto megabytes(T value) noexcept
static constexpr std::uint32_t kXrpLedgerEarliestSeq
The XRP ledger network's earliest allowed sequence.