Files
rippled/src/test/nodestore/Basics_test.cpp
Bart 1d42c4f6de refactor: Remove unnecessary copyright notices already covered by LICENSE.md (#5929)
Per XLS-0095, we are taking steps to rename ripple(d) to xrpl(d).

This change specifically removes all copyright notices referencing Ripple, XRPLF, and certain affiliated contributors upon mutual agreement, so the notice in the LICENSE.md file applies throughout. Copyright notices referencing external contributions remain as-is. Duplicate verbiage is also removed.
2025-11-04 08:33:42 +00:00

73 lines
1.7 KiB
C++

#include <test/nodestore/TestBase.h>
#include <xrpl/nodestore/detail/DecodedBlob.h>
#include <xrpl/nodestore/detail/EncodedBlob.h>
namespace ripple {
namespace NodeStore {
// Tests predictable batches, and NodeObject blob encoding
//
class NodeStoreBasic_test : public TestBase
{
public:
// Make sure predictable object generation works!
void
testBatches(std::uint64_t const seedValue)
{
testcase("batch");
auto batch1 = createPredictableBatch(numObjectsToTest, seedValue);
auto batch2 = createPredictableBatch(numObjectsToTest, seedValue);
BEAST_EXPECT(areBatchesEqual(batch1, batch2));
auto batch3 = createPredictableBatch(numObjectsToTest, seedValue + 1);
BEAST_EXPECT(!areBatchesEqual(batch1, batch3));
}
// Checks encoding/decoding blobs
void
testBlobs(std::uint64_t const seedValue)
{
testcase("encoding");
auto batch = createPredictableBatch(numObjectsToTest, seedValue);
for (int i = 0; i < batch.size(); ++i)
{
EncodedBlob encoded(batch[i]);
DecodedBlob decoded(
encoded.getKey(), encoded.getData(), encoded.getSize());
BEAST_EXPECT(decoded.wasOk());
if (decoded.wasOk())
{
std::shared_ptr<NodeObject> const object(
decoded.createObject());
BEAST_EXPECT(isSame(batch[i], object));
}
}
}
void
run() override
{
std::uint64_t const seedValue = 50;
testBatches(seedValue);
testBlobs(seedValue);
}
};
BEAST_DEFINE_TESTSUITE(NodeStoreBasic, nodestore, ripple);
} // namespace NodeStore
} // namespace ripple