mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Format first-party source according to .clang-format
This commit is contained in:
committed by
manojsdoshi
parent
65dfc5d19e
commit
50760c6935
@@ -33,8 +33,7 @@ class SHAMapStore_test : public beast::unit_test::suite
|
||||
{
|
||||
static auto const deleteInterval = 8;
|
||||
|
||||
static
|
||||
auto
|
||||
static auto
|
||||
onlineDelete(std::unique_ptr<Config> cfg)
|
||||
{
|
||||
cfg->LEDGER_HISTORY = deleteInterval;
|
||||
@@ -43,22 +42,24 @@ class SHAMapStore_test : public beast::unit_test::suite
|
||||
return cfg;
|
||||
}
|
||||
|
||||
static
|
||||
auto
|
||||
static auto
|
||||
advisoryDelete(std::unique_ptr<Config> cfg)
|
||||
{
|
||||
cfg = onlineDelete(std::move(cfg));
|
||||
cfg->section(ConfigSection::nodeDatabase())
|
||||
.set("advisory_delete", "1");
|
||||
cfg->section(ConfigSection::nodeDatabase()).set("advisory_delete", "1");
|
||||
return cfg;
|
||||
}
|
||||
|
||||
bool goodLedger(jtx::Env& env, Json::Value const& json,
|
||||
std::string ledgerID, bool checkDB = false)
|
||||
bool
|
||||
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])
|
||||
&& json[jss::result][jss::ledger][jss::ledger_index] == ledgerID;
|
||||
auto good = json.isMember(jss::result) &&
|
||||
!RPC::contains_error(json[jss::result]) &&
|
||||
json[jss::result][jss::ledger][jss::ledger_index] == ledgerID;
|
||||
if (!good || !checkDB)
|
||||
return good;
|
||||
|
||||
@@ -78,97 +79,95 @@ class SHAMapStore_test : public beast::unit_test::suite
|
||||
auto db = env.app().getLedgerDB().checkoutDb();
|
||||
|
||||
*db << "SELECT LedgerHash,LedgerSeq,PrevHash,TotalCoins, "
|
||||
"ClosingTime,PrevClosingTime,CloseTimeRes,CloseFlags, "
|
||||
"AccountSetHash,TransSetHash "
|
||||
"FROM Ledgers "
|
||||
"WHERE LedgerSeq = :seq",
|
||||
soci::use(seq),
|
||||
soci::into(outHash),
|
||||
soci::into(outSeq),
|
||||
soci::into(outParentHash),
|
||||
soci::into(outDrops),
|
||||
soci::into(outCloseTime),
|
||||
soci::into(outParentCloseTime),
|
||||
soci::into(outCloseTimeResolution),
|
||||
soci::into(outCloseFlags),
|
||||
soci::into(outAccountHash),
|
||||
soci::into(outTxHash);
|
||||
"ClosingTime,PrevClosingTime,CloseTimeRes,CloseFlags, "
|
||||
"AccountSetHash,TransSetHash "
|
||||
"FROM Ledgers "
|
||||
"WHERE LedgerSeq = :seq",
|
||||
soci::use(seq), soci::into(outHash), soci::into(outSeq),
|
||||
soci::into(outParentHash), soci::into(outDrops),
|
||||
soci::into(outCloseTime), soci::into(outParentCloseTime),
|
||||
soci::into(outCloseTimeResolution), soci::into(outCloseFlags),
|
||||
soci::into(outAccountHash), soci::into(outTxHash);
|
||||
}
|
||||
|
||||
auto const& ledger = json[jss::result][jss::ledger];
|
||||
return outHash == ledger[jss::hash].asString() &&
|
||||
outSeq == seq &&
|
||||
return outHash == ledger[jss::hash].asString() && outSeq == seq &&
|
||||
outParentHash == ledger[jss::parent_hash].asString() &&
|
||||
outDrops == ledger[jss::total_coins].asString() &&
|
||||
outCloseTime == ledger[jss::close_time].asUInt() &&
|
||||
outParentCloseTime == ledger[jss::parent_close_time].asUInt() &&
|
||||
outCloseTimeResolution == ledger[jss::close_time_resolution].asUInt() &&
|
||||
outCloseTimeResolution ==
|
||||
ledger[jss::close_time_resolution].asUInt() &&
|
||||
outCloseFlags == ledger[jss::close_flags].asUInt() &&
|
||||
outAccountHash == ledger[jss::account_hash].asString() &&
|
||||
outTxHash == ledger[jss::transaction_hash].asString();
|
||||
}
|
||||
|
||||
bool bad(Json::Value const& json, error_code_i error = rpcLGR_NOT_FOUND)
|
||||
bool
|
||||
bad(Json::Value const& json, error_code_i error = rpcLGR_NOT_FOUND)
|
||||
{
|
||||
return json.isMember(jss::result)
|
||||
&& RPC::contains_error(json[jss::result])
|
||||
&& json[jss::result][jss::error_code] == error;
|
||||
return json.isMember(jss::result) &&
|
||||
RPC::contains_error(json[jss::result]) &&
|
||||
json[jss::result][jss::error_code] == error;
|
||||
}
|
||||
|
||||
std::string getHash(Json::Value const& json)
|
||||
std::string
|
||||
getHash(Json::Value const& json)
|
||||
{
|
||||
BEAST_EXPECT(json.isMember(jss::result) &&
|
||||
BEAST_EXPECT(
|
||||
json.isMember(jss::result) &&
|
||||
json[jss::result].isMember(jss::ledger) &&
|
||||
json[jss::result][jss::ledger].isMember(jss::hash) &&
|
||||
json[jss::result][jss::ledger][jss::hash].isString());
|
||||
return json[jss::result][jss::ledger][jss::hash].asString();
|
||||
}
|
||||
|
||||
void ledgerCheck(jtx::Env& env, int const rows,
|
||||
int const first)
|
||||
void
|
||||
ledgerCheck(jtx::Env& env, int const rows, int const first)
|
||||
{
|
||||
auto db = env.app().getLedgerDB().checkoutDb();
|
||||
|
||||
int actualRows, actualFirst, actualLast;
|
||||
*db << "SELECT count(*) AS rows, "
|
||||
"min(LedgerSeq) as first, "
|
||||
"max(LedgerSeq) as last "
|
||||
"FROM Ledgers;",
|
||||
soci::into(actualRows),
|
||||
soci::into(actualFirst),
|
||||
"min(LedgerSeq) as first, "
|
||||
"max(LedgerSeq) as last "
|
||||
"FROM Ledgers;",
|
||||
soci::into(actualRows), soci::into(actualFirst),
|
||||
soci::into(actualLast);
|
||||
|
||||
BEAST_EXPECT(actualRows == rows);
|
||||
BEAST_EXPECT(actualFirst == first);
|
||||
BEAST_EXPECT(actualLast == first + rows - 1);
|
||||
|
||||
}
|
||||
|
||||
void transactionCheck(jtx::Env& env, int const rows)
|
||||
void
|
||||
transactionCheck(jtx::Env& env, int const rows)
|
||||
{
|
||||
auto db = env.app().getTxnDB().checkoutDb();
|
||||
|
||||
int actualRows;
|
||||
*db << "SELECT count(*) AS rows "
|
||||
"FROM Transactions;",
|
||||
"FROM Transactions;",
|
||||
soci::into(actualRows);
|
||||
|
||||
BEAST_EXPECT(actualRows == rows);
|
||||
}
|
||||
|
||||
void accountTransactionCheck(jtx::Env& env, int const rows)
|
||||
void
|
||||
accountTransactionCheck(jtx::Env& env, int const rows)
|
||||
{
|
||||
auto db = env.app().getTxnDB().checkoutDb();
|
||||
|
||||
int actualRows;
|
||||
*db << "SELECT count(*) AS rows "
|
||||
"FROM AccountTransactions;",
|
||||
"FROM AccountTransactions;",
|
||||
soci::into(actualRows);
|
||||
|
||||
BEAST_EXPECT(actualRows == rows);
|
||||
}
|
||||
|
||||
int waitForReady(jtx::Env& env)
|
||||
int
|
||||
waitForReady(jtx::Env& env)
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@@ -189,7 +188,8 @@ class SHAMapStore_test : public beast::unit_test::suite
|
||||
}
|
||||
|
||||
public:
|
||||
void testClear()
|
||||
void
|
||||
testClear()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@@ -242,7 +242,8 @@ public:
|
||||
{
|
||||
ledgers.emplace(
|
||||
std::make_pair(i, env.rpc("ledger", std::to_string(i))));
|
||||
BEAST_EXPECT(goodLedger(env, ledgers[i], std::to_string(i), true) &&
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledgers[i], std::to_string(i), true) &&
|
||||
getHash(ledgers[i]).length());
|
||||
}
|
||||
|
||||
@@ -255,7 +256,8 @@ public:
|
||||
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(deleteInterval + 4)));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -270,7 +272,8 @@ public:
|
||||
accountTransactionCheck(env, 2 * deleteInterval);
|
||||
|
||||
// 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 + deleteInterval - 1;
|
||||
++i)
|
||||
{
|
||||
env.close();
|
||||
|
||||
@@ -279,9 +282,11 @@ public:
|
||||
|
||||
ledgers.emplace(
|
||||
std::make_pair(i, env.rpc("ledger", std::to_string(i))));
|
||||
BEAST_EXPECT(store.getLastRotated() == lastRotated ||
|
||||
BEAST_EXPECT(
|
||||
store.getLastRotated() == lastRotated ||
|
||||
i == lastRotated + deleteInterval - 2);
|
||||
BEAST_EXPECT(goodLedger(env, ledgers[i], std::to_string(i), true) &&
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledgers[i], std::to_string(i), true) &&
|
||||
getHash(ledgers[i]).length());
|
||||
}
|
||||
|
||||
@@ -292,10 +297,10 @@ public:
|
||||
ledgerCheck(env, deleteInterval + 1, lastRotated);
|
||||
transactionCheck(env, 0);
|
||||
accountTransactionCheck(env, 0);
|
||||
|
||||
}
|
||||
|
||||
void testAutomatic()
|
||||
void
|
||||
testAutomatic()
|
||||
{
|
||||
testcase("automatic online_delete");
|
||||
using namespace jtx;
|
||||
@@ -320,7 +325,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -335,7 +341,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -351,7 +358,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -360,7 +368,8 @@ public:
|
||||
BEAST_EXPECT(lastRotated != store.getLastRotated());
|
||||
}
|
||||
|
||||
void testCanDelete()
|
||||
void
|
||||
testCanDelete()
|
||||
{
|
||||
testcase("online_delete with advisory_delete");
|
||||
using namespace jtx;
|
||||
@@ -389,7 +398,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -398,10 +408,11 @@ public:
|
||||
BEAST_EXPECT(lastRotated == store.getLastRotated());
|
||||
|
||||
// This does not kick off a cleanup
|
||||
canDelete = env.rpc("can_delete", std::to_string(
|
||||
ledgerSeq + deleteInterval / 2));
|
||||
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] ==
|
||||
BEAST_EXPECT(
|
||||
canDelete[jss::result][jss::can_delete] ==
|
||||
ledgerSeq + deleteInterval / 2);
|
||||
|
||||
store.rendezvous();
|
||||
@@ -414,7 +425,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -430,7 +442,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -442,7 +455,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -455,8 +469,9 @@ public:
|
||||
// This does not kick off a cleanup
|
||||
canDelete = env.rpc("can_delete", "always");
|
||||
BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result]));
|
||||
BEAST_EXPECT(canDelete[jss::result][jss::can_delete] ==
|
||||
std::numeric_limits <unsigned int>::max());
|
||||
BEAST_EXPECT(
|
||||
canDelete[jss::result][jss::can_delete] ==
|
||||
std::numeric_limits<unsigned int>::max());
|
||||
|
||||
for (; ledgerSeq < lastRotated + deleteInterval; ++ledgerSeq)
|
||||
{
|
||||
@@ -464,7 +479,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -476,7 +492,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -497,7 +514,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -509,7 +527,8 @@ public:
|
||||
env.close();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
BEAST_EXPECT(
|
||||
goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
}
|
||||
|
||||
store.rendezvous();
|
||||
@@ -520,7 +539,8 @@ public:
|
||||
lastRotated = ledgerSeq - 1;
|
||||
}
|
||||
|
||||
void run() override
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testClear();
|
||||
testAutomatic();
|
||||
@@ -529,7 +549,7 @@ public:
|
||||
};
|
||||
|
||||
// VFALCO This test fails because of thread asynchronous issues
|
||||
BEAST_DEFINE_TESTSUITE(SHAMapStore,app,ripple);
|
||||
BEAST_DEFINE_TESTSUITE(SHAMapStore, app, ripple);
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user