3#include <xrpl/basics/StringUtilities.h>
4#include <xrpl/basics/random.h>
5#include <xrpl/beast/unit_test.h>
6#include <xrpl/beast/utility/rngfill.h>
7#include <xrpl/beast/xor_shift_engine.h>
8#include <xrpl/nodestore/Backend.h>
9#include <xrpl/nodestore/Database.h>
10#include <xrpl/nodestore/Types.h>
12#include <boost/algorithm/string.hpp>
31 return lhs->getHash() < rhs->getHash();
39 return (lhs->getType() == rhs->getType()) && (lhs->getHash() == rhs->getHash()) &&
40 (lhs->getData() == rhs->getData());
64 for (
int i = 0; i < numObjects; ++i)
101 for (
int i = 0; i < lhs.
size(); ++i)
103 if (!
isSame(lhs[i], rhs[i]))
122 for (
int i = 0; i < batch.
size(); ++i)
124 backend.
store(batch[i]);
135 for (
int i = 0; i < batch.
size(); ++i)
139 Status const status = backend.
fetch(batch[i]->getHash(), &
object);
145 BEAST_EXPECT(
object !=
nullptr);
155 for (
int i = 0; i < batch.
size(); ++i)
159 Status const status = backend.
fetch(batch[i]->getHash(), &
object);
169 for (
int i = 0; i < batch.
size(); ++i)
173 Blob data(object->getData());
186 for (
int i = 0; i < batch.
size(); ++i)
190 if (
object !=
nullptr)
static constexpr std::size_t size()
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
A backend used for the NodeStore.
virtual void store(std::shared_ptr< NodeObject > const &object)=0
Store a single object.
virtual Status fetch(uint256 const &hash, std::shared_ptr< NodeObject > *pObject)=0
Fetch a single object.
Persistency layer for NodeObject.
std::uint32_t earliestLedgerSeq() const noexcept
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t ledgerSeq=0, FetchType fetchType=FetchType::Synchronous, bool duplicate=false)
Fetch a node object.
virtual void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t ledgerSeq)=0
Store the object.
static bool areBatchesEqual(Batch const &lhs, Batch const &rhs)
static std::size_t const kMinPayloadBytes
void fetchCopyOfBatch(Backend &backend, Batch *pCopy, Batch const &batch)
static void storeBatch(Database &db, Batch const &batch)
void fetchMissing(Backend &backend, Batch const &batch)
static std::size_t const kMaxPayloadBytes
static void storeBatch(Backend &backend, Batch const &batch)
static void fetchCopyOfBatch(Database &db, Batch *pCopy, Batch const &batch)
static Batch createPredictableBatch(int numObjects, std::uint64_t seed)
static int const kNumObjectsToTest
detail::XorShiftEngine<> xor_shift_engine
XOR-shift Generator.
void rngfill(void *const buffer, std::size_t const bytes, Generator &g)
bool isSame(std::shared_ptr< NodeObject > const &lhs, std::shared_ptr< NodeObject > const &rhs)
Returns true if objects are identical.
Status
Return codes from Backend operations.
std::vector< std::shared_ptr< NodeObject > > Batch
A batch of NodeObjects to write at once.
std::enable_if_t< std::is_integral_v< Integral >, Integral > randInt()
NodeObjectType
The types of node objects.
std::vector< unsigned char > Blob
Storage for linear binary data.
Binary function that satisfies the strict-weak-ordering requirement.
bool operator()(std::shared_ptr< NodeObject > const &lhs, std::shared_ptr< NodeObject > const &rhs) const noexcept