chore: Enable clang-tidy misc checks (#6655)

This commit is contained in:
Alex Kremer
2026-03-31 18:29:45 +01:00
committed by GitHub
parent c3fae847f3
commit 2502befb42
469 changed files with 3915 additions and 3965 deletions

View File

@@ -261,7 +261,7 @@ class NegativeUNL_test : public beast::unit_test::suite
{
BEAST_EXPECT(l->validatorToDisable() == publicKeys[0]);
//++ first ToDisable Tx in ledger's TxSet
uint256 txID = txDisable_0.getTransactionID();
uint256 const txID = txDisable_0.getTransactionID();
BEAST_EXPECT(l->txExists(txID));
}
}
@@ -628,7 +628,7 @@ struct NetworkHistory
walkHistoryAndAddValidations(NeedValidation&& needVal)
{
std::uint32_t curr = 0;
std::size_t need = 256 + 1;
std::size_t const need = 256 + 1;
// only last 256 + 1 ledgers need validations
if (history.size() > need)
curr = history.size() - need;
@@ -702,14 +702,14 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
testcase("Create UNLModify Tx");
jtx::Env env(*this);
NodeID myId(0xA0);
NodeID const myId(0xA0);
NegativeUNLVote vote(myId, env.journal);
// one add, one remove
auto txSet = std::make_shared<SHAMap>(SHAMapType::TRANSACTION, env.app().getNodeFamily());
PublicKey toDisableKey(derivePublicKey(KeyType::ed25519, randomSecretKey()));
PublicKey toReEnableKey(derivePublicKey(KeyType::ed25519, randomSecretKey()));
LedgerIndex seq(1234);
PublicKey const toDisableKey(derivePublicKey(KeyType::ed25519, randomSecretKey()));
PublicKey const toReEnableKey(derivePublicKey(KeyType::ed25519, randomSecretKey()));
LedgerIndex const seq(1234);
BEAST_EXPECT(countTx(txSet) == 0);
vote.addTx(seq, toDisableKey, NegativeUNLVote::ToDisable, txSet);
BEAST_EXPECT(countTx(txSet) == 1);
@@ -723,16 +723,16 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
testPickOneCandidate()
{
testcase("Pick One Candidate");
jtx::Env env(*this);
jtx::Env const env(*this);
NodeID myId(0xA0);
NegativeUNLVote vote(myId, env.journal);
NodeID const myId(0xA0);
NegativeUNLVote const vote(myId, env.journal);
uint256 pad_0(0);
uint256 pad_f = ~pad_0;
NodeID n_1(1);
NodeID n_2(2);
NodeID n_3(3);
uint256 const pad_0(0);
uint256 const pad_f = ~pad_0;
NodeID const n_1(1);
NodeID const n_2(2);
NodeID const n_3(3);
std::vector<NodeID> candidates({n_1});
BEAST_EXPECT(vote.choose(pad_0, candidates) == n_1);
BEAST_EXPECT(vote.choose(pad_f, candidates) == n_1);
@@ -803,7 +803,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
// 5. local node had enough validations but on a wrong chain
NetworkHistory history = {*this, {10, 0, false, false, 256 + 2}};
// We need two chains for these tests
bool wrongChainSuccess = history.goodHistory;
bool const wrongChainSuccess = history.goodHistory;
BEAST_EXPECT(wrongChainSuccess);
NetworkHistory::LedgerHistory wrongChain = std::move(history.history);
// Create a new chain and use it as the one that majority of nodes
@@ -814,7 +814,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
if (history.goodHistory && wrongChainSuccess)
{
NodeID myId = history.UNLNodeIDs[3];
NodeID badNode = history.UNLNodeIDs[4];
NodeID const badNode = history.UNLNodeIDs[4];
history.walkHistoryAndAddValidations(
[&](std::shared_ptr<Ledger const> const& l, std::size_t idx) -> bool {
// everyone but me
@@ -825,9 +825,9 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
// a node double validates
for (auto& l : wrongChain)
{
RCLValidation v1(history.createSTVal(l, myId));
RCLValidation const v1(history.createSTVal(l, myId));
history.validations.add(myId, v1);
RCLValidation v2(history.createSTVal(l, badNode));
RCLValidation const v2(history.createSTVal(l, badNode));
history.validations.add(badNode, v2);
}
@@ -909,8 +909,8 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
{
auto [disableCandidates, reEnableCandidates] =
vote.findAllCandidates(unl, negUnl, scoreTable);
bool rightDisable = disableCandidates.size() == numDisable;
bool rightReEnable = reEnableCandidates.size() == numReEnable;
bool const rightDisable = disableCandidates.size() == numDisable;
bool const rightReEnable = reEnableCandidates.size() == numReEnable;
return rightDisable && rightReEnable;
};
@@ -1009,9 +1009,9 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
{
// 2 new validators
NodeID new_1(0xbead);
NodeID new_2(0xbeef);
hash_set<NodeID> nowTrusted = {new_1, new_2};
NodeID const new_1(0xbead);
NodeID const new_2(0xbeef);
hash_set<NodeID> const nowTrusted = {new_1, new_2};
hash_set<NodeID> UNL_temp = history.UNLNodeIDSet;
UNL_temp.insert(new_1);
UNL_temp.insert(new_2);
@@ -1065,13 +1065,13 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
* negativeUNLMinLocalValsToVote
*/
jtx::Env env(*this);
jtx::Env const env(*this);
NodeID myId(0xA0);
NodeID const myId(0xA0);
NegativeUNLVote vote(myId, env.journal);
std::array<std::uint32_t, 3> unlSizes = {34, 35, 80};
std::array<std::uint32_t, 3> nUnlPercent = {0, 50, 100};
std::array<std::uint32_t, 3> const unlSizes = {34, 35, 80};
std::array<std::uint32_t, 3> const nUnlPercent = {0, 50, 100};
std::array<std::uint32_t, 8> scores = {
0,
NegativeUNLVote::negativeUNLLowWaterMark - 1,
@@ -1091,7 +1091,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
hash_set<NodeID>& negUnl,
hash_map<NodeID, std::uint32_t>& scoreTable) {
std::vector<NodeID> nodeIDs;
std::vector<PublicKey> keys = createPublicKeys(unl_size);
std::vector<PublicKey> const keys = createPublicKeys(unl_size);
for (auto const& k : keys)
{
nodeIDs.emplace_back(calcNodeID(k));
@@ -1153,7 +1153,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
hash_set<NodeID>& negUnl,
hash_map<NodeID, std::uint32_t>& scoreTable) {
std::vector<NodeID> nodeIDs;
std::vector<PublicKey> keys = createPublicKeys(unl_size);
std::vector<PublicKey> const keys = createPublicKeys(unl_size);
for (auto const& k : keys)
{
nodeIDs.emplace_back(calcNodeID(k));
@@ -1221,9 +1221,9 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
testNewValidators()
{
testcase("New Validators");
jtx::Env env(*this);
jtx::Env const env(*this);
NodeID myId(0xA0);
NodeID const myId(0xA0);
NegativeUNLVote vote(myId, env.journal);
// test cases:
@@ -1232,9 +1232,9 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
// add a new one and some already added
// purge and see some are expired
NodeID n1(0xA1);
NodeID n2(0xA2);
NodeID n3(0xA3);
NodeID const n1(0xA1);
NodeID const n2(0xA2);
NodeID const n3(0xA3);
vote.newValidators(2, {n1});
BEAST_EXPECT(vote.newValidators_.size() == 1);
@@ -1301,7 +1301,7 @@ class NegativeUNLVoteScoreTable_test : public beast::unit_test::suite
* -- unl size: 10, 34, 35, 50
* -- score pattern: all 0, all 50%, all 100%, two 0% two 50% rest 100%
*/
std::array<std::uint32_t, 4> unlSizes = {10, 34, 35, 50};
std::array<std::uint32_t, 4> const unlSizes = {10, 34, 35, 50};
std::array<std::array<std::uint32_t, 3>, 4> scorePattern = {
{{{0, 0, 0}}, {{50, 50, 50}}, {{100, 100, 100}}, {{0, 50, 100}}}};
@@ -1330,9 +1330,9 @@ class NegativeUNLVoteScoreTable_test : public beast::unit_test::suite
k = 2;
}
bool add_50 = scorePattern[sp][k] == 50 && l->seq() % 2 == 0;
bool add_100 = scorePattern[sp][k] == 100;
bool add_me = history.UNLNodeIDs[idx] == myId;
bool const add_50 = scorePattern[sp][k] == 50 && l->seq() % 2 == 0;
bool const add_100 = scorePattern[sp][k] == 100;
bool const add_me = history.UNLNodeIDs[idx] == myId;
return add_50 || add_100 || add_me;
});
@@ -1698,8 +1698,8 @@ class NegativeUNLVoteFilterValidations_test : public beast::unit_test::suite
};
// create keys and validations
std::uint32_t numNodes = 10;
std::uint32_t negUnlSize = 3;
std::uint32_t const numNodes = 10;
std::uint32_t const negUnlSize = 3;
std::vector<std::string> cfgKeys;
hash_set<NodeID> activeValidators;
hash_set<PublicKey> nUnlKeys;
@@ -1719,7 +1719,7 @@ class NegativeUNLVoteFilterValidations_test : public beast::unit_test::suite
// setup the ValidatorList
auto& validators = env.app().getValidators();
auto& local = *nUnlKeys.begin();
std::vector<std::string> cfgPublishers;
std::vector<std::string> const cfgPublishers;
validators.load(local, cfgKeys, cfgPublishers);
validators.updateTrusted(
activeValidators,
@@ -1765,9 +1765,9 @@ negUnlSizeTest(
bool hasToDisable,
bool hasToReEnable)
{
bool sameSize = l->negativeUNL().size() == size;
bool sameToDisable = (l->validatorToDisable() != std::nullopt) == hasToDisable;
bool sameToReEnable = (l->validatorToReEnable() != std::nullopt) == hasToReEnable;
bool const sameSize = l->negativeUNL().size() == size;
bool const sameToDisable = (l->validatorToDisable() != std::nullopt) == hasToDisable;
bool const sameToReEnable = (l->validatorToReEnable() != std::nullopt) == hasToReEnable;
return sameSize && sameToDisable && sameToReEnable;
}
@@ -1809,7 +1809,7 @@ VerifyPubKeyAndSeq(
auto s = makeSlice(d);
if (!publicKeyType(s))
return false;
PublicKey pk(s);
PublicKey const pk(s);
auto it = nUnlLedgerSeq.find(pk);
if (it == nUnlLedgerSeq.end())
return false;
@@ -1835,13 +1835,13 @@ std::vector<PublicKey>
createPublicKeys(std::size_t n)
{
std::vector<PublicKey> keys;
std::size_t ss = 33;
std::size_t const ss = 33;
std::vector<uint8_t> data(ss, 0);
data[0] = 0xED;
for (int i = 0; i < n; ++i)
{
data[1]++;
Slice s(data.data(), ss);
Slice const s(data.data(), ss);
keys.emplace_back(s);
}
return keys;