mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-07 10:47:05 +00:00
Merge remote-tracking branch 'XRPLF/develop' into ximinez/online-delete-gaps
* XRPLF/develop: ci: Rewrite clang-tidy workflow(s) in a reusable manner (7062) chore: Ignore identifier-naming update in git blame (7066) refactor: Enable clang-tidy `readability-identifier-naming` check (6571)
This commit is contained in:
@@ -39,15 +39,15 @@
|
||||
|
||||
namespace xrpl::test {
|
||||
|
||||
class SHAMapStore_test : public beast::unit_test::suite
|
||||
class SHAMapStore_test : public beast::unit_test::Suite
|
||||
{
|
||||
static auto const deleteInterval = 8;
|
||||
static auto const kDELETE_INTERVAL = 8;
|
||||
|
||||
static auto
|
||||
onlineDelete(std::unique_ptr<Config> cfg)
|
||||
{
|
||||
using namespace jtx;
|
||||
return online_delete(std::move(cfg), deleteInterval);
|
||||
return online_delete(std::move(cfg), kDELETE_INTERVAL);
|
||||
}
|
||||
|
||||
static auto
|
||||
@@ -59,9 +59,9 @@ class SHAMapStore_test : public beast::unit_test::suite
|
||||
}
|
||||
|
||||
static bool
|
||||
goodLedger(jtx::Env& env, Json::Value const& json, std::string ledgerID, bool checkDB = false)
|
||||
goodLedger(jtx::Env& env, json::Value const& json, std::string ledgerID, bool checkDB = false)
|
||||
{
|
||||
auto good = json.isMember(jss::result) && !RPC::contains_error(json[jss::result]) &&
|
||||
auto good = json.isMember(jss::result) && !RPC::containsError(json[jss::result]) &&
|
||||
json[jss::result][jss::ledger][jss::ledger_index] == ledgerID;
|
||||
if (!good || !checkDB)
|
||||
return good;
|
||||
@@ -98,14 +98,14 @@ class SHAMapStore_test : public beast::unit_test::suite
|
||||
}
|
||||
|
||||
static bool
|
||||
bad(Json::Value const& json, error_code_i error = rpcLGR_NOT_FOUND)
|
||||
bad(json::Value const& json, ErrorCodeI error = RpcLgrNotFound)
|
||||
{
|
||||
return json.isMember(jss::result) && RPC::contains_error(json[jss::result]) &&
|
||||
return json.isMember(jss::result) && RPC::containsError(json[jss::result]) &&
|
||||
json[jss::result][jss::error_code] == error;
|
||||
}
|
||||
|
||||
std::string
|
||||
getHash(Json::Value const& json)
|
||||
getHash(json::Value const& json)
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
json.isMember(jss::result) && json[jss::result].isMember(jss::ledger) &&
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
transactionCheck(env, 0);
|
||||
accountTransactionCheck(env, 0);
|
||||
|
||||
std::map<std::uint32_t, Json::Value const> ledgers;
|
||||
std::map<std::uint32_t, json::Value const> ledgers;
|
||||
|
||||
auto ledgerTmp = env.rpc("ledger", "0");
|
||||
BEAST_EXPECT(bad(ledgerTmp));
|
||||
@@ -199,7 +199,7 @@ public:
|
||||
auto const firstSeq = waitForReady(env);
|
||||
auto lastRotated = firstSeq - 1;
|
||||
|
||||
for (auto i = firstSeq + 1; i < deleteInterval + firstSeq; ++i)
|
||||
for (auto i = firstSeq + 1; i < kDELETE_INTERVAL + firstSeq; ++i)
|
||||
{
|
||||
env.fund(XRP(10000), noripple("test" + std::to_string(i)));
|
||||
env.close();
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
}
|
||||
BEAST_EXPECT(store.getLastRotated() == lastRotated);
|
||||
|
||||
for (auto i = 3; i < deleteInterval + lastRotated; ++i)
|
||||
for (auto i = 3; i < kDELETE_INTERVAL + lastRotated; ++i)
|
||||
{
|
||||
ledgers.emplace(i, env.rpc("ledger", std::to_string(i)));
|
||||
BEAST_EXPECT(
|
||||
@@ -217,31 +217,31 @@ public:
|
||||
!getHash(ledgers[i]).empty());
|
||||
}
|
||||
|
||||
ledgerCheck(env, deleteInterval + 1, 2);
|
||||
transactionCheck(env, deleteInterval);
|
||||
accountTransactionCheck(env, 2 * deleteInterval);
|
||||
ledgerCheck(env, kDELETE_INTERVAL + 1, 2);
|
||||
transactionCheck(env, kDELETE_INTERVAL);
|
||||
accountTransactionCheck(env, 2 * kDELETE_INTERVAL);
|
||||
|
||||
{
|
||||
// Closing one more ledger triggers a rotate
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "current");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(deleteInterval + 4)));
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(kDELETE_INTERVAL + 4)));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
|
||||
BEAST_EXPECT(store.getLastRotated() == deleteInterval + 3);
|
||||
BEAST_EXPECT(store.getLastRotated() == kDELETE_INTERVAL + 3);
|
||||
lastRotated = store.getLastRotated();
|
||||
BEAST_EXPECT(lastRotated == 11);
|
||||
|
||||
// That took care of the fake hashes
|
||||
ledgerCheck(env, deleteInterval + 1, 3);
|
||||
transactionCheck(env, deleteInterval);
|
||||
accountTransactionCheck(env, 2 * deleteInterval);
|
||||
ledgerCheck(env, kDELETE_INTERVAL + 1, 3);
|
||||
transactionCheck(env, kDELETE_INTERVAL);
|
||||
accountTransactionCheck(env, 2 * kDELETE_INTERVAL);
|
||||
|
||||
// The last iteration of this loop should trigger a rotate
|
||||
for (auto i = lastRotated - 1; i < lastRotated + deleteInterval - 1; ++i)
|
||||
for (auto i = lastRotated - 1; i < lastRotated + kDELETE_INTERVAL - 1; ++i)
|
||||
{
|
||||
env.close();
|
||||
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
|
||||
ledgers.emplace(i, env.rpc("ledger", std::to_string(i)));
|
||||
BEAST_EXPECT(
|
||||
store.getLastRotated() == lastRotated || i == lastRotated + deleteInterval - 2);
|
||||
store.getLastRotated() == lastRotated || i == lastRotated + kDELETE_INTERVAL - 2);
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledgers[i], std::to_string(i), true) &&
|
||||
!getHash(ledgers[i]).empty());
|
||||
@@ -258,9 +258,9 @@ public:
|
||||
|
||||
store.rendezvous();
|
||||
|
||||
BEAST_EXPECT(store.getLastRotated() == deleteInterval + lastRotated);
|
||||
BEAST_EXPECT(store.getLastRotated() == kDELETE_INTERVAL + lastRotated);
|
||||
|
||||
ledgerCheck(env, deleteInterval + 1, lastRotated);
|
||||
ledgerCheck(env, kDELETE_INTERVAL + 1, lastRotated);
|
||||
transactionCheck(env, 0);
|
||||
accountTransactionCheck(env, 0);
|
||||
}
|
||||
@@ -283,10 +283,10 @@ public:
|
||||
// Because advisory_delete is unset,
|
||||
// "can_delete" is disabled.
|
||||
auto const canDelete = env.rpc("can_delete");
|
||||
BEAST_EXPECT(bad(canDelete, rpcNOT_ENABLED));
|
||||
BEAST_EXPECT(bad(canDelete, RpcNotEnabled));
|
||||
|
||||
// Close ledgers without triggering a rotate
|
||||
for (; ledgerSeq < lastRotated + deleteInterval; ++ledgerSeq)
|
||||
for (; ledgerSeq < lastRotated + kDELETE_INTERVAL; ++ledgerSeq)
|
||||
{
|
||||
env.close();
|
||||
|
||||
@@ -317,7 +317,7 @@ public:
|
||||
lastRotated = store.getLastRotated();
|
||||
|
||||
// Close enough ledgers to trigger another rotate
|
||||
for (; ledgerSeq < lastRotated + deleteInterval + 1; ++ledgerSeq)
|
||||
for (; ledgerSeq < lastRotated + kDELETE_INTERVAL + 1; ++ledgerSeq)
|
||||
{
|
||||
env.close();
|
||||
|
||||
@@ -327,7 +327,7 @@ public:
|
||||
|
||||
store.rendezvous();
|
||||
|
||||
ledgerCheck(env, deleteInterval + 1, lastRotated);
|
||||
ledgerCheck(env, kDELETE_INTERVAL + 1, lastRotated);
|
||||
BEAST_EXPECT(lastRotated != store.getLastRotated());
|
||||
}
|
||||
|
||||
@@ -348,14 +348,14 @@ public:
|
||||
BEAST_EXPECT(lastRotated != 2);
|
||||
|
||||
auto canDelete = env.rpc("can_delete");
|
||||
BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result]));
|
||||
BEAST_EXPECT(!RPC::containsError(canDelete[jss::result]));
|
||||
BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == 0);
|
||||
|
||||
canDelete = env.rpc("can_delete", "never");
|
||||
BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result]));
|
||||
BEAST_EXPECT(!RPC::containsError(canDelete[jss::result]));
|
||||
BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == 0);
|
||||
|
||||
auto const firstBatch = deleteInterval + ledgerSeq;
|
||||
auto const firstBatch = kDELETE_INTERVAL + ledgerSeq;
|
||||
for (; ledgerSeq < firstBatch; ++ledgerSeq)
|
||||
{
|
||||
env.close();
|
||||
@@ -370,9 +370,9 @@ public:
|
||||
BEAST_EXPECT(lastRotated == store.getLastRotated());
|
||||
|
||||
// This does not kick off a cleanup
|
||||
canDelete = env.rpc("can_delete", std::to_string(ledgerSeq + (deleteInterval / 2)));
|
||||
BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result]));
|
||||
BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == ledgerSeq + (deleteInterval / 2));
|
||||
canDelete = env.rpc("can_delete", std::to_string(ledgerSeq + (kDELETE_INTERVAL / 2)));
|
||||
BEAST_EXPECT(!RPC::containsError(canDelete[jss::result]));
|
||||
BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == ledgerSeq + (kDELETE_INTERVAL / 2));
|
||||
|
||||
store.rendezvous();
|
||||
|
||||
@@ -394,7 +394,7 @@ public:
|
||||
BEAST_EXPECT(store.getLastRotated() == ledgerSeq - 1);
|
||||
lastRotated = ledgerSeq - 1;
|
||||
|
||||
for (; ledgerSeq < lastRotated + deleteInterval; ++ledgerSeq)
|
||||
for (; ledgerSeq < lastRotated + kDELETE_INTERVAL; ++ledgerSeq)
|
||||
{
|
||||
// No cleanups in this loop.
|
||||
env.close();
|
||||
@@ -424,11 +424,11 @@ public:
|
||||
|
||||
// This does not kick off a cleanup
|
||||
canDelete = env.rpc("can_delete", "always");
|
||||
BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result]));
|
||||
BEAST_EXPECT(!RPC::containsError(canDelete[jss::result]));
|
||||
BEAST_EXPECT(
|
||||
canDelete[jss::result][jss::can_delete] == std::numeric_limits<unsigned int>::max());
|
||||
|
||||
for (; ledgerSeq < lastRotated + deleteInterval; ++ledgerSeq)
|
||||
for (; ledgerSeq < lastRotated + kDELETE_INTERVAL; ++ledgerSeq)
|
||||
{
|
||||
// No cleanups in this loop.
|
||||
env.close();
|
||||
@@ -458,10 +458,10 @@ public:
|
||||
|
||||
// This does not kick off a cleanup
|
||||
canDelete = env.rpc("can_delete", "now");
|
||||
BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result]));
|
||||
BEAST_EXPECT(!RPC::containsError(canDelete[jss::result]));
|
||||
BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == ledgerSeq - 1);
|
||||
|
||||
for (; ledgerSeq < lastRotated + deleteInterval; ++ledgerSeq)
|
||||
for (; ledgerSeq < lastRotated + kDELETE_INTERVAL; ++ledgerSeq)
|
||||
{
|
||||
// No cleanups in this loop.
|
||||
env.close();
|
||||
@@ -501,9 +501,9 @@ public:
|
||||
newPath = path;
|
||||
section.set("path", newPath.string());
|
||||
|
||||
auto backend{NodeStore::Manager::instance().make_Backend(
|
||||
auto backend{NodeStore::Manager::instance().makeBackend(
|
||||
section,
|
||||
megabytes(env.app().config().getValueFor(SizedItem::burstSize, std::nullopt)),
|
||||
megabytes(env.app().config().getValueFor(SizedItem::BurstSize, std::nullopt)),
|
||||
scheduler,
|
||||
env.app().getJournal("NodeStoreTest"))};
|
||||
backend->open();
|
||||
@@ -530,11 +530,11 @@ public:
|
||||
auto writableBackend = makeBackendRotating(env, scheduler, writableDb);
|
||||
auto archiveBackend = makeBackendRotating(env, scheduler, archiveDb);
|
||||
|
||||
constexpr int readThreads = 4;
|
||||
constexpr int kREAD_THREADS = 4;
|
||||
auto nscfg = env.app().config().section(ConfigSection::nodeDatabase());
|
||||
auto dbr = std::make_unique<NodeStore::DatabaseRotatingImp>(
|
||||
scheduler,
|
||||
readThreads,
|
||||
kREAD_THREADS,
|
||||
std::move(writableBackend),
|
||||
std::move(archiveBackend),
|
||||
nscfg,
|
||||
@@ -637,7 +637,7 @@ public:
|
||||
|
||||
++maxSeq;
|
||||
|
||||
if (maxSeq + 1 == lastRotated + deleteInterval)
|
||||
if (maxSeq + 1 == lastRotated + kDELETE_INTERVAL)
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@@ -721,7 +721,7 @@ public:
|
||||
minSeq = lastRotated;
|
||||
lastRotated = deleteSeq + 1;
|
||||
}
|
||||
BEAST_EXPECT(maxSeq != lastRotated + deleteInterval);
|
||||
BEAST_EXPECT(maxSeq != lastRotated + kDELETE_INTERVAL);
|
||||
BEAST_EXPECTS(
|
||||
env.closed()->header().seq == maxSeq,
|
||||
failureMessage("maxSeq", maxSeq, env.closed()->header().seq));
|
||||
|
||||
Reference in New Issue
Block a user