mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Format first-party source according to .clang-format
This commit is contained in:
committed by
manojsdoshi
parent
65dfc5d19e
commit
50760c6935
@@ -17,13 +17,13 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/unity/rocksdb.h>
|
||||
#include <ripple/beast/utility/temp_dir.h>
|
||||
#include <ripple/nodestore/DummyScheduler.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <ripple/beast/utility/temp_dir.h>
|
||||
#include <ripple/unity/rocksdb.h>
|
||||
#include <algorithm>
|
||||
#include <test/nodestore/TestBase.h>
|
||||
#include <test/unit_test/SuiteJournal.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
@@ -33,93 +33,90 @@ namespace NodeStore {
|
||||
class Backend_test : public TestBase
|
||||
{
|
||||
public:
|
||||
void testBackend (
|
||||
void
|
||||
testBackend(
|
||||
std::string const& type,
|
||||
std::uint64_t const seedValue,
|
||||
int numObjsToTest = 2000)
|
||||
{
|
||||
DummyScheduler scheduler;
|
||||
|
||||
testcase ("Backend type=" + type);
|
||||
testcase("Backend type=" + type);
|
||||
|
||||
Section params;
|
||||
beast::temp_dir tempDir;
|
||||
params.set ("type", type);
|
||||
params.set ("path", tempDir.path());
|
||||
params.set("type", type);
|
||||
params.set("path", tempDir.path());
|
||||
|
||||
beast::xor_shift_engine rng (seedValue);
|
||||
beast::xor_shift_engine rng(seedValue);
|
||||
|
||||
// Create a batch
|
||||
auto batch = createPredictableBatch (
|
||||
numObjsToTest, rng());
|
||||
auto batch = createPredictableBatch(numObjsToTest, rng());
|
||||
|
||||
using namespace beast::severities;
|
||||
test::SuiteJournal journal ("Backend_test", *this);
|
||||
test::SuiteJournal journal("Backend_test", *this);
|
||||
|
||||
{
|
||||
// Open the backend
|
||||
std::unique_ptr <Backend> backend =
|
||||
Manager::instance().make_Backend (
|
||||
params, scheduler, journal);
|
||||
std::unique_ptr<Backend> backend =
|
||||
Manager::instance().make_Backend(params, scheduler, journal);
|
||||
backend->open();
|
||||
|
||||
// Write the batch
|
||||
storeBatch (*backend, batch);
|
||||
storeBatch(*backend, batch);
|
||||
|
||||
{
|
||||
// Read it back in
|
||||
Batch copy;
|
||||
fetchCopyOfBatch (*backend, ©, batch);
|
||||
BEAST_EXPECT(areBatchesEqual (batch, copy));
|
||||
fetchCopyOfBatch(*backend, ©, batch);
|
||||
BEAST_EXPECT(areBatchesEqual(batch, copy));
|
||||
}
|
||||
|
||||
{
|
||||
// Reorder and read the copy again
|
||||
std::shuffle (
|
||||
batch.begin(),
|
||||
batch.end(),
|
||||
rng);
|
||||
std::shuffle(batch.begin(), batch.end(), rng);
|
||||
Batch copy;
|
||||
fetchCopyOfBatch (*backend, ©, batch);
|
||||
BEAST_EXPECT(areBatchesEqual (batch, copy));
|
||||
fetchCopyOfBatch(*backend, ©, batch);
|
||||
BEAST_EXPECT(areBatchesEqual(batch, copy));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// Re-open the backend
|
||||
std::unique_ptr <Backend> backend = Manager::instance().make_Backend (
|
||||
params, scheduler, journal);
|
||||
std::unique_ptr<Backend> backend =
|
||||
Manager::instance().make_Backend(params, scheduler, journal);
|
||||
backend->open();
|
||||
|
||||
// Read it back in
|
||||
Batch copy;
|
||||
fetchCopyOfBatch (*backend, ©, batch);
|
||||
fetchCopyOfBatch(*backend, ©, batch);
|
||||
// Canonicalize the source and destination batches
|
||||
std::sort (batch.begin (), batch.end (), LessThan{});
|
||||
std::sort (copy.begin (), copy.end (), LessThan{});
|
||||
BEAST_EXPECT(areBatchesEqual (batch, copy));
|
||||
std::sort(batch.begin(), batch.end(), LessThan{});
|
||||
std::sort(copy.begin(), copy.end(), LessThan{});
|
||||
BEAST_EXPECT(areBatchesEqual(batch, copy));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void run () override
|
||||
void
|
||||
run() override
|
||||
{
|
||||
std::uint64_t const seedValue = 50;
|
||||
|
||||
testBackend ("nudb", seedValue);
|
||||
testBackend("nudb", seedValue);
|
||||
|
||||
#if RIPPLE_ROCKSDB_AVAILABLE
|
||||
testBackend ("rocksdb", seedValue);
|
||||
#endif
|
||||
#if RIPPLE_ROCKSDB_AVAILABLE
|
||||
testBackend("rocksdb", seedValue);
|
||||
#endif
|
||||
|
||||
#ifdef RIPPLE_ENABLE_SQLITE_BACKEND_TESTS
|
||||
testBackend ("sqlite", seedValue);
|
||||
#endif
|
||||
#ifdef RIPPLE_ENABLE_SQLITE_BACKEND_TESTS
|
||||
testBackend("sqlite", seedValue);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(Backend,ripple_core,ripple);
|
||||
BEAST_DEFINE_TESTSUITE(Backend, ripple_core, ripple);
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user