Files
rippled/src/tests/libxrpl/nodestore/Basics.cpp
Andrzej Budzanowski 29120dfcbd test: Migrate nodestore tests from Beast to GTest (#7292)
Co-authored-by: Marek Foss <marek.foss@neti-soft.com>
Co-authored-by: Alex Kremer <akremer@ripple.com>
2026-07-27 13:00:14 +00:00

42 lines
1.2 KiB
C++

#include <xrpl/nodestore/NodeObject.h>
#include <xrpl/nodestore/detail/DecodedBlob.h>
#include <xrpl/nodestore/detail/EncodedBlob.h>
#include <gtest/gtest.h>
#include <nodestore/TestBase.h>
#include <cstddef>
#include <memory>
#include <string>
namespace xrpl::node_store {
TEST(NodeStoreBasics, predictable_batches)
{
auto const batch1 = createPredictableBatch(kNumObjectsToTest, kSeedValue);
auto const batch2 = createPredictableBatch(kNumObjectsToTest, kSeedValue);
EXPECT_EQ(batch1, batch2);
auto const batch3 = createPredictableBatch(kNumObjectsToTest, kSeedValue + 1);
EXPECT_NE(batch1, batch3);
}
TEST(NodeStoreBasics, blob_encoding)
{
auto const batch = createPredictableBatch(kNumObjectsToTest, kSeedValue);
for (std::size_t i = 0; i < batch.size(); ++i)
{
SCOPED_TRACE("blob index=" + std::to_string(i));
EncodedBlob const encoded(batch[i]);
DecodedBlob decoded(encoded.getKey(), encoded.getData(), encoded.getSize());
EXPECT_TRUE(decoded.wasOk());
if (decoded.wasOk())
{
std::shared_ptr<NodeObject> const object(decoded.createObject());
EXPECT_TRUE(isSame(batch[i], object));
}
}
}
} // namespace xrpl::node_store