1#include <test/nodestore/TestBase.h> 
    2#include <test/unit_test/SuiteJournal.h> 
    4#include <xrpl/basics/BasicConfig.h> 
    5#include <xrpl/basics/ByteUtilities.h> 
    6#include <xrpl/beast/utility/temp_dir.h> 
    7#include <xrpl/nodestore/DummyScheduler.h> 
    8#include <xrpl/nodestore/Manager.h> 
   24        params.
set(
"type", 
"nudb");
 
   25        params.
set(
"path", path);
 
   26        if (!blockSize.empty())
 
   27            params.
set(
"nudb_block_size", blockSize);
 
 
   43                params, 
megabytes(4), scheduler, journal);
 
   45            if (!BEAST_EXPECT(backend))
 
   48            if (!BEAST_EXPECT(backend->getBlockSize() == expectedBlocksize))
 
   53            if (!BEAST_EXPECT(backend->isOpen()))
 
 
   85            params, 
megabytes(4), scheduler, journal);
 
   88        BEAST_EXPECT(logOutput.
find(expectedMessage) != std::string::npos);
 
 
  103            params, 
megabytes(4), scheduler, journal);
 
  107            logOutput.
find(
"Invalid nudb_block_size") != std::string::npos;
 
  109        BEAST_EXPECT(hasWarning == !shouldWork);
 
 
  116        testcase(
"Default block size (no nudb_block_size specified)");
 
 
  132        for (
auto const& size : validSizes)
 
 
  167        for (
auto const& size : invalidSizes)
 
  182        for (
auto const& size : whitespaceInvalidSizes)
 
 
  195        testcase(
"Log message verification");
 
  205                "Using custom NuDB block size: 8192");
 
  220                    params, 
megabytes(4), scheduler, journal);
 
  227                    logOutput.find(
"Invalid nudb_block_size: 5000") !=
 
  231                        "Must be power of 2 between 4096 and 32768") !=
 
  248                    params, 
megabytes(4), scheduler, journal);
 
  256                    logOutput.find(
"Invalid nudb_block_size value: invalid") !=
 
 
  265        testcase(
"Power of 2 validation logic");
 
  280        for (
auto const& [size, shouldWork] : testCases)
 
  294                    params, 
megabytes(4), scheduler, journal);
 
  295                BEAST_EXPECT(shouldWork);
 
  301                    logOutput.find(
"Invalid nudb_block_size") !=
 
 
  310        testcase(
"Both constructor variants work with custom block size");
 
  321                params, 
megabytes(4), scheduler, journal);
 
  322            BEAST_EXPECT(backend1 != 
nullptr);
 
 
  335        testcase(
"Configuration parsing edge cases");
 
  352        for (
auto const& format : validFormats)
 
  362                params, 
megabytes(4), scheduler, journal);
 
  366            bool hasSuccessMessage =
 
  367                logOutput.
find(
"Using custom NuDB block size") !=
 
  369            BEAST_EXPECT(hasSuccessMessage);
 
  374        for (
auto const& format : whitespaceFormats)
 
  387                    params, 
megabytes(4), scheduler, journal);
 
 
  401        testcase(
"Data persistence with different block sizes");
 
  404            "4096", 
"8192", 
"16384", 
"32768"};
 
  406        for (
auto const& size : blockSizes)
 
  420                    params, 
megabytes(4), scheduler, journal);
 
  429                    params, 
megabytes(4), scheduler, journal);
 
 
 
A generic endpoint for log messages.
 
RAII temporary directory.
 
std::string path() const
Get the native path for the temporary directory.
 
testcase_t testcase
Memberspace for declaring test cases.
 
void fail(String const &reason, char const *file, int line)
Record a failure.
 
Simple NodeStore Scheduler that just peforms the tasks synchronously.
 
virtual std::unique_ptr< Backend > make_Backend(Section const ¶meters, std::size_t burstSize, Scheduler &scheduler, beast::Journal journal)=0
Create a backend.
 
static Manager & instance()
Returns the instance of the manager singleton.
 
void testBothConstructorVariants()
 
void testInvalidBlockSizes()
 
Section createSection(std::string const &path, std::string const &blockSize="")
 
void testDefaultBlockSize()
 
void testPowerOfTwoValidation()
 
void testLogMessage(Section const ¶ms, beast::severities::Severity level, std::string const &expectedMessage)
 
void run() override
Runs the suite.
 
void testPowerOfTwoValidation(std::string const &size, bool shouldWork)
 
void testConfigurationParsing()
 
bool testBackendFunctionality(Section const ¶ms, std::size_t expectedBlocksize)
 
void testDataPersistence()
 
void testValidBlockSizes()
 
static Batch createPredictableBatch(int numObjects, std::uint64_t seed)
 
static bool areBatchesEqual(Batch const &lhs, Batch const &rhs)
 
void fetchCopyOfBatch(Backend &backend, Batch *pCopy, Batch const &batch)
 
void storeBatch(Backend &backend, Batch const &batch)
 
Holds a collection of configuration values.
 
void set(std::string const &key, std::string const &value)
Set a key/value pair.
 
std::stringstream const & messages() const
 
Severity
Severity level / threshold of a Journal message.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
constexpr auto megabytes(T value) noexcept
 
std::string to_string(base_uint< Bits, Tag > const &a)