From 8c3ca4483522c57c5da5e29f8cc4b9338666db76 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 6 Nov 2026 04:14:44 +0700 Subject: [PATCH 1/8] refactor: name CQuorumDataRequestKey's parameter we_requested, as its callers do Every caller marks the argument as /*we_requested=*/, matching the parameter of the functions that take the same flag, but the constructor called it _m_we_requested. clang-tidy's bugprone-argument-comment, which now checks the unit tests, fails on the mismatch in llmq_qgetdata_tests.cpp. --- src/llmq/quorums.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/llmq/quorums.h b/src/llmq/quorums.h index a712454d5469..6f6d403da91b 100644 --- a/src/llmq/quorums.h +++ b/src/llmq/quorums.h @@ -56,9 +56,9 @@ struct CQuorumDataRequestKey uint256 quorumHash; Consensus::LLMQType llmqType; - CQuorumDataRequestKey(const uint256& proRegTxIn, const bool _m_we_requested, const uint256& quorumHashIn, const Consensus::LLMQType llmqTypeIn) : + CQuorumDataRequestKey(const uint256& proRegTxIn, const bool we_requested, const uint256& quorumHashIn, const Consensus::LLMQType llmqTypeIn) : proRegTx(proRegTxIn), - m_we_requested(_m_we_requested), + m_we_requested(we_requested), quorumHash(quorumHashIn), llmqType(llmqTypeIn) {} From 5a58e9f099bdb139e1f5d23c46816d400e8fe79d Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 6 Nov 2026 04:14:54 +0700 Subject: [PATCH 2/8] test: match argument comments to the parameter names clang-tidy's bugprone-argument-comment now checks the unit tests and fails where a /*name=*/ comment does not match the parameter it annotates: CGovernanceObject's nRevisionIn and strDataHexIn, COutPoint's nIn, CTxIn's nSequenceIn, CKey::MakeNewKey's fCompressed, the specificLegacyScheme of the BLS signing and key-setting functions, and CTxMemPoolEntry's sigops_count, which Dash renamed from upstream's sigops_cost. --- src/test/coinjoin_inouts_tests.cpp | 2 +- src/test/evo_deterministicmns_tests.cpp | 2 +- src/test/evo_trivialvalidation.cpp | 2 +- src/test/governance_collateral_tests.cpp | 2 +- src/test/governance_inv_tests.cpp | 8 ++++---- src/test/governance_vote_processing_tests.cpp | 4 ++-- src/test/governance_vote_sync_tests.cpp | 14 +++++++------- src/test/util/setup_common.cpp | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/test/coinjoin_inouts_tests.cpp b/src/test/coinjoin_inouts_tests.cpp index c5dea2930c42..1aa32a8f1f45 100644 --- a/src/test/coinjoin_inouts_tests.cpp +++ b/src/test/coinjoin_inouts_tests.cpp @@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(entry_addscriptsig_matches_and_rejects) // Right prevout but wrong sequence -> rejected (guards against malleated nSequence). { - CTxIn badseq_in(op1, scriptSig0, /*nSequence=*/seq1 ^ 0xffU); + CTxIn badseq_in(op1, scriptSig0, /*nSequenceIn=*/seq1 ^ 0xffU); BOOST_CHECK(!entry.AddScriptSig(badseq_in)); BOOST_CHECK(!entry.vecTxDSIn[1].fHasSig); BOOST_CHECK(entry.vecTxDSIn[1].scriptSig.empty()); diff --git a/src/test/evo_deterministicmns_tests.cpp b/src/test/evo_deterministicmns_tests.cpp index 6b51efa721a9..2da07254ffaa 100644 --- a/src/test/evo_deterministicmns_tests.cpp +++ b/src/test/evo_deterministicmns_tests.cpp @@ -462,7 +462,7 @@ void FuncProUpRegTxVersionHandlingBeforeV24(TestChainSetup& setup) CProUpRegTx proTxLegacy; proTxLegacy.nVersion = ProTxVersion::LegacyBLS; proTxLegacy.proTxHash = proTxHash; - proTxLegacy.pubKeyOperator.Set(operator_key_legacy.GetPublicKey(), /*legacy=*/true); + proTxLegacy.pubKeyOperator.Set(operator_key_legacy.GetPublicKey(), /*specificLegacyScheme=*/true); proTxLegacy.keyIDVoting = owner_key.GetPubKey().GetID(); proTxLegacy.scriptPayout = payoutScript3; diff --git a/src/test/evo_trivialvalidation.cpp b/src/test/evo_trivialvalidation.cpp index a7e9a77c54d9..992760282b97 100644 --- a/src/test/evo_trivialvalidation.cpp +++ b/src/test/evo_trivialvalidation.cpp @@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(proupserv_rejects_invalid_ntype) proReg.scriptPayout = NewP2PKHScript(payout_key); CBLSSecretKey operator_key; operator_key.MakeNewKey(); - proReg.pubKeyOperator.Set(operator_key.GetPublicKey(), /*legacy=*/false); + proReg.pubKeyOperator.Set(operator_key.GetPublicKey(), /*specificLegacyScheme=*/false); TxValidationState state; BOOST_CHECK(!proReg.IsTriviallyValid(state)); diff --git a/src/test/governance_collateral_tests.cpp b/src/test/governance_collateral_tests.cpp index 3e6c30f71592..8ae366b5e950 100644 --- a/src/test/governance_collateral_tests.cpp +++ b/src/test/governance_collateral_tests.cpp @@ -98,7 +98,7 @@ struct CollateralSetup : public TestChain100Setup { const std::string data{ R"({"type":1,"name":"proposal","start_epoch":1700000000,"end_epoch":1700100000,"payment_amount":1.0,"payment_address":")" + payment_address + R"(","url":"https://dash.org"})"}; - return CGovernanceObject{uint256{}, /*revision=*/1, /*nTime=*/1700000000, collateral_hash, HexStr(data)}; + return CGovernanceObject{uint256{}, /*nRevisionIn=*/1, /*nTime=*/1700000000, collateral_hash, HexStr(data)}; } bool IsCollateralValid(const CGovernanceObject& govobj, std::string& error) const diff --git a/src/test/governance_inv_tests.cpp b/src/test/governance_inv_tests.cpp index c93aa6881e82..a53b84ba0a1b 100644 --- a/src/test/governance_inv_tests.cpp +++ b/src/test/governance_inv_tests.cpp @@ -166,7 +166,7 @@ CGovernanceObject MakeGovernanceObject(int64_t creation_time, const uint256& col { const std::string data{ R"({"type":1,"name":"proposal","start_epoch":1700000000,"end_epoch":1700100000,"payment_amount":1.0,"payment_address":"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwV","url":"https://dash.org"})"}; - return CGovernanceObject{uint256{}, /*revision=*/1, creation_time, collateral_hash, HexStr(data)}; + return CGovernanceObject{uint256{}, /*nRevisionIn=*/1, creation_time, collateral_hash, HexStr(data)}; } void ProcessGovernanceObject(NetGovernance& net_gov, CNode& peer, const CGovernanceObject& govobj) @@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(per_object_vote_sync_is_fulfilled_request_limited) BOOST_CHECK_EQUAL(MisbehaviorScore(*m_node.peerman, *peer), 0); const CBloomFilter vote_filter{1, 0.001, 0, BLOOM_UPDATE_NONE}; - CGovernanceObject postponed_object{uint256(), /*revision=*/1, GetTime(), uint256::ONE, /*data=*/{}}; + CGovernanceObject postponed_object{uint256(), /*nRevisionIn=*/1, GetTime(), uint256::ONE, /*strDataHexIn=*/{}}; m_node.govman->AddPostponedObject(postponed_object); const uint256 postponed_object_hash{postponed_object.GetHash()}; @@ -235,7 +235,7 @@ BOOST_AUTO_TEST_CASE(per_object_vote_sync_is_fulfilled_request_limited) BOOST_CHECK_EQUAL(MisbehaviorScore(*m_node.peerman, *peer), 0); - CGovernanceObject syncable_object{uint256(), /*revision=*/1, GetTime() + 1, uint256S("02"), /*data=*/{}}; + CGovernanceObject syncable_object{uint256(), /*nRevisionIn=*/1, GetTime() + 1, uint256S("02"), /*strDataHexIn=*/{}}; m_node.govman->AddGovernanceObjectForTesting(syncable_object); const uint256 syncable_object_hash{syncable_object.GetHash()}; @@ -275,7 +275,7 @@ BOOST_AUTO_TEST_CASE(per_object_vote_sync_is_fulfilled_request_limited) BOOST_CHECK_EQUAL(MisbehaviorScore(*m_node.peerman, *peer), 20); connman.FlushSendBuffer(*peer); - CGovernanceObject empty_filter_object{uint256(), /*revision=*/1, GetTime() + 2, uint256S("03"), /*data=*/{}}; + CGovernanceObject empty_filter_object{uint256(), /*nRevisionIn=*/1, GetTime() + 2, uint256S("03"), /*strDataHexIn=*/{}}; m_node.govman->AddPostponedObject(empty_filter_object); const uint256 empty_filter_object_hash{empty_filter_object.GetHash()}; const std::string empty_filter_vote_request{strprintf("%s-votes-%s", NetMsgType::MNGOVERNANCESYNC, diff --git a/src/test/governance_vote_processing_tests.cpp b/src/test/governance_vote_processing_tests.cpp index 357e7e0e1789..171c0708be78 100644 --- a/src/test/governance_vote_processing_tests.cpp +++ b/src/test/governance_vote_processing_tests.cpp @@ -66,7 +66,7 @@ CGovernanceObject MakeFailedTrigger(const COutPoint& mn_collateral, const CBLSSe int64_t creation_time, int salt) { const std::string data{strprintf(R"({"type":2,"salt":%d})", salt)}; - CGovernanceObject govobj{uint256{}, /*revision=*/1, creation_time, uint256{}, HexStr(data)}; + CGovernanceObject govobj{uint256{}, /*nRevisionIn=*/1, creation_time, uint256{}, HexStr(data)}; BOOST_REQUIRE(govobj.GetObjectType() == GovernanceObject::TRIGGER); govobj.SetMasternodeOutpoint(mn_collateral); govobj.SetSignature(operator_key.Sign(govobj.GetSignatureHash(), /*specificLegacyScheme=*/false) @@ -188,7 +188,7 @@ struct GovernanceVoteSetup : public TestChainSetup { const std::string data{ strprintf("{\"type\":1,\"name\":\"test-proposal\",\"start_epoch\":%d,\"end_epoch\":%d,\"payment_amount\":1.0,\"payment_address\":\"%s\",\"url\":\"https://dash.org\"}", proposal_time, proposal_time + 100000, proposal_payment_address)}; - return CGovernanceObject{uint256{}, /*revision=*/1, proposal_time, collateral_hash, HexStr(data)}; + return CGovernanceObject{uint256{}, /*nRevisionIn=*/1, proposal_time, collateral_hash, HexStr(data)}; } //! Burns the proposal fee to an OP_RETURN committing to the object hash, the way diff --git a/src/test/governance_vote_sync_tests.cpp b/src/test/governance_vote_sync_tests.cpp index ac69392786f8..3729efc24f7f 100644 --- a/src/test/governance_vote_sync_tests.cpp +++ b/src/test/governance_vote_sync_tests.cpp @@ -28,7 +28,7 @@ CGovernanceVote MakeSignedVote(const CBLSSecretKey& sk, const COutPoint& outpoin { CGovernanceVote vote{outpoint, parent, signal, VOTE_OUTCOME_YES}; vote.SetTime(time); - vote.SetSignature(sk.Sign(vote.GetSignatureHash(), /*legacy_scheme=*/false).ToByteVector(/*legacy=*/false)); + vote.SetSignature(sk.Sign(vote.GetSignatureHash(), /*specificLegacyScheme=*/false).ToByteVector(/*specificLegacyScheme=*/false)); return vote; } } // namespace @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(vote_signature_verification_is_cached) sk.MakeNewKey(); const CBLSPublicKey pk{sk.GetPublicKey()}; - CGovernanceVote vote{MakeSignedVote(sk, COutPoint{uint256S("01"), /*n=*/0}, uint256S("02"), VOTE_SIGNAL_VALID, + CGovernanceVote vote{MakeSignedVote(sk, COutPoint{uint256S("01"), /*nIn=*/0}, uint256S("02"), VOTE_SIGNAL_VALID, 1'700'000'000)}; // Nothing memoised yet, so the first check has to run the pairing. @@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE(stored_vote_file_reuses_signature_cache) sk.MakeNewKey(); const CBLSPublicKey pk{sk.GetPublicKey()}; - CGovernanceVote vote{MakeSignedVote(sk, COutPoint{uint256S("11"), /*n=*/1}, uint256S("22"), VOTE_SIGNAL_DELETE, + CGovernanceVote vote{MakeSignedVote(sk, COutPoint{uint256S("11"), /*nIn=*/1}, uint256S("22"), VOTE_SIGNAL_DELETE, 1'700'000'100)}; CGovernanceObjectVoteFile file; @@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE(copy_assigned_vote_file_indexes_its_own_votes) CBLSSecretKey sk; sk.MakeNewKey(); const CGovernanceVote vote{ - MakeSignedVote(sk, COutPoint{uint256S("11"), /*n=*/1}, uint256S("22"), VOTE_SIGNAL_FUNDING, 1'700'000'100)}; + MakeSignedVote(sk, COutPoint{uint256S("11"), /*nIn=*/1}, uint256S("22"), VOTE_SIGNAL_FUNDING, 1'700'000'100)}; CGovernanceObjectVoteFile copy; { @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(signature_cache_invalidated_by_signed_field_mutation) sk.MakeNewKey(); const CBLSPublicKey pk{sk.GetPublicKey()}; - CGovernanceVote vote{MakeSignedVote(sk, COutPoint{uint256S("33"), /*n=*/2}, uint256S("44"), VOTE_SIGNAL_FUNDING, + CGovernanceVote vote{MakeSignedVote(sk, COutPoint{uint256S("33"), /*nIn=*/2}, uint256S("44"), VOTE_SIGNAL_FUNDING, 1'700'000'200)}; BOOST_REQUIRE(vote.CheckSignature(pk)); @@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(signature_cache_does_not_confuse_key_types) sk.MakeNewKey(); const CBLSPublicKey pk{sk.GetPublicKey()}; - CGovernanceVote vote{MakeSignedVote(sk, COutPoint{uint256S("55"), /*n=*/3}, uint256S("66"), VOTE_SIGNAL_VALID, + CGovernanceVote vote{MakeSignedVote(sk, COutPoint{uint256S("55"), /*nIn=*/3}, uint256S("66"), VOTE_SIGNAL_VALID, 1'700'000'300)}; // Warm the memo with a *valid* BLS verdict. @@ -212,7 +212,7 @@ BOOST_AUTO_TEST_CASE(signature_cache_does_not_confuse_key_types) // signature for any CKeyID, so this must re-verify and reject rather than // inherit the cached "valid". CKey ecdsa_key; - ecdsa_key.MakeNewKey(/*fCompressedIn=*/true); + ecdsa_key.MakeNewKey(/*fCompressed=*/true); const CKeyID keyid{ecdsa_key.GetPubKey().GetID()}; BOOST_CHECK_MESSAGE(!vote.GetMemoisedVerdict(keyid).has_value(), diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index c4e5f965a834..d50805fabf68 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -772,7 +772,7 @@ std::vector TestChainSetup::PopulateMempool(FastRandomContext& LockPoints lp; m_node.mempool->addUnchecked(CTxMemPoolEntry(ptx, /*fee=*/(total_in - num_outputs * amount_per_output), /*time=*/0, /*entry_height=*/1, - /*spends_coinbase=*/false, /*sigops_cost=*/4, lp)); + /*spends_coinbase=*/false, /*sigops_count=*/4, lp)); } --num_transactions; } From d3032d159e447c73f3cecddcdef103a79f5bd1a4 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 6 Nov 2026 04:15:10 +0700 Subject: [PATCH 3/8] test: fix clang-tidy performance and modernize errors in Dash tests clang-tidy now checks the unit tests with src/.clang-tidy, and fails on Dash test code that: - fills a vector in a loop without reserving it (performance-inefficient-vector-operation), - passes a temporary to push_back or emplace_back (modernize-use-emplace), - moves into a CDeterministicMNList, which has no move assignment (performance-move-const-arg). Reserve the vectors, construct the elements in place and copy instead of the ineffective move. coinjoin_queue_tests.cpp tests that a copy of a queue equals the original, so its copy stays, with a NOLINT for performance-unnecessary-copy-initialization. --- src/test/coinjoin_inouts_tests.cpp | 21 ++++++++++++++++++--- src/test/coinjoin_queue_tests.cpp | 2 +- src/test/evo_deterministicmns_tests.cpp | 1 + src/test/evo_simplifiedmns_tests.cpp | 1 + src/test/evo_snapshot_tests.cpp | 2 +- src/test/governance_inv_tests.cpp | 1 + src/test/llmq_snapshot_tests.cpp | 1 + src/test/quorum_proofs_tests.cpp | 4 ++++ src/test/validation_block_tests.cpp | 14 ++++++-------- 9 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/test/coinjoin_inouts_tests.cpp b/src/test/coinjoin_inouts_tests.cpp index 1aa32a8f1f45..862131aec085 100644 --- a/src/test/coinjoin_inouts_tests.cpp +++ b/src/test/coinjoin_inouts_tests.cpp @@ -639,6 +639,7 @@ BOOST_AUTO_TEST_CASE(validate_promotion_entry_valid) BOOST_CHECK(CoinJoin::IsValidDenomination(nLargerDenom)); // Create 10 inputs of smaller denomination + vecTxIn.reserve(CoinJoin::PROMOTION_RATIO); for (int i = 0; i < CoinJoin::PROMOTION_RATIO; ++i) { vecTxIn.push_back(MakeDenomInput(static_cast(i))); } @@ -661,6 +662,7 @@ BOOST_AUTO_TEST_CASE(validate_promotion_entry_wrong_input_count) const CAmount nLargerAmount = CoinJoin::DenominationToAmount(nLargerDenom); // Create only 9 inputs + vecTxIn.reserve(CoinJoin::PROMOTION_RATIO - 1); for (int i = 0; i < CoinJoin::PROMOTION_RATIO - 1; ++i) { vecTxIn.push_back(MakeDenomInput(static_cast(i))); } @@ -681,6 +683,7 @@ BOOST_AUTO_TEST_CASE(validate_promotion_entry_wrong_output_count) const int nLargerDenom = 1 << 1; const CAmount nLargerAmount = CoinJoin::DenominationToAmount(nLargerDenom); + vecTxIn.reserve(CoinJoin::PROMOTION_RATIO); for (int i = 0; i < CoinJoin::PROMOTION_RATIO; ++i) { vecTxIn.push_back(MakeDenomInput(static_cast(i))); } @@ -703,6 +706,7 @@ BOOST_AUTO_TEST_CASE(validate_promotion_entry_non_adjacent_denoms) const int nLargerDenom = 1 << 1; // 1.0 DASH (not adjacent to 0.01) const CAmount nLargerAmount = CoinJoin::DenominationToAmount(nLargerDenom); + vecTxIn.reserve(CoinJoin::PROMOTION_RATIO); for (int i = 0; i < CoinJoin::PROMOTION_RATIO; ++i) { vecTxIn.push_back(MakeDenomInput(static_cast(i))); } @@ -731,6 +735,7 @@ BOOST_AUTO_TEST_CASE(validate_demotion_entry_valid) vecTxIn.push_back(MakeDenomInput(0)); // 10 outputs of smaller denomination + vecTxOut.reserve(CoinJoin::PROMOTION_RATIO); for (int i = 0; i < CoinJoin::PROMOTION_RATIO; ++i) { vecTxOut.push_back(MakeDenomOutput(nSmallerAmount, static_cast(i))); } @@ -752,6 +757,7 @@ BOOST_AUTO_TEST_CASE(validate_demotion_entry_wrong_input_count) vecTxIn.push_back(MakeDenomInput(0)); vecTxIn.push_back(MakeDenomInput(1)); + vecTxOut.reserve(CoinJoin::PROMOTION_RATIO); for (int i = 0; i < CoinJoin::PROMOTION_RATIO; ++i) { vecTxOut.push_back(MakeDenomOutput(nSmallerAmount, static_cast(i))); } @@ -772,6 +778,7 @@ BOOST_AUTO_TEST_CASE(validate_demotion_entry_wrong_output_count) vecTxIn.push_back(MakeDenomInput(0)); // Only 9 outputs + vecTxOut.reserve(CoinJoin::PROMOTION_RATIO - 1); for (int i = 0; i < CoinJoin::PROMOTION_RATIO - 1; ++i) { vecTxOut.push_back(MakeDenomOutput(nSmallerAmount, static_cast(i))); } @@ -792,6 +799,7 @@ BOOST_AUTO_TEST_CASE(validate_demotion_entry_largest_denom_has_no_source) vecTxIn.push_back(MakeDenomInput(0)); + vecTxOut.reserve(CoinJoin::PROMOTION_RATIO); for (int i = 0; i < CoinJoin::PROMOTION_RATIO; ++i) { vecTxOut.push_back(MakeDenomOutput(nLargestAmount, static_cast(i))); } @@ -1007,7 +1015,7 @@ BOOST_AUTO_TEST_CASE(output_limit_postfork) mtx.vin.push_back(in); } for (size_t i = 0; i < nOutputs; ++i) { - mtx.vout.push_back(CTxOut{nSmallestDenom, P2PKHScript(static_cast(i % 256))}); + mtx.vout.emplace_back(nSmallestDenom, P2PKHScript(static_cast(i % 256))); } dstx.tx = MakeTransactionRef(mtx); dstx.m_protxHash = uint256::ONE; @@ -1111,7 +1119,7 @@ BOOST_AUTO_TEST_CASE(isvalidstructure_mixed_session_postfork) CTxIn in; in.prevout = COutPoint(uint256::ONE, static_cast(i)); mtx.vin.push_back(in); - mtx.vout.push_back(CTxOut{nSmallestDenom, P2PKHScript(static_cast(i))}); + mtx.vout.emplace_back(nSmallestDenom, P2PKHScript(static_cast(i))); } // Promotion participant (10 inputs -> 1 output) @@ -1121,7 +1129,7 @@ BOOST_AUTO_TEST_CASE(isvalidstructure_mixed_session_postfork) mtx.vin.push_back(in); } // One output for the promotion (larger denom) - mtx.vout.push_back(CTxOut{nSecondSmallest, P2PKHScript(0x0D)}); + mtx.vout.emplace_back(nSecondSmallest, P2PKHScript(0x0D)); mixed.tx = MakeTransactionRef(mtx); mixed.m_protxHash = uint256::ONE; @@ -1191,6 +1199,7 @@ BOOST_AUTO_TEST_CASE(validate_entry_session_denom_consistency) // Create a valid promotion entry structure std::vector promoVin; std::vector promoVout; + promoVin.reserve(CoinJoin::PROMOTION_RATIO); for (int i = 0; i < CoinJoin::PROMOTION_RATIO; ++i) { promoVin.push_back(MakeDenomInput(static_cast(i))); } @@ -1209,6 +1218,7 @@ BOOST_AUTO_TEST_CASE(validate_entry_session_denom_consistency) std::vector demoVin; std::vector demoVout; demoVin.push_back(MakeDenomInput(0)); + demoVout.reserve(CoinJoin::PROMOTION_RATIO); for (int i = 0; i < CoinJoin::PROMOTION_RATIO; ++i) { demoVout.push_back(MakeDenomOutput(CoinJoin::DenominationToAmount(nSessionDenom), static_cast(i))); } @@ -1561,6 +1571,7 @@ BOOST_AUTO_TEST_CASE(validate_promotion_entry_edge_cases) // Valid case: exactly 10 inputs, 1 output of correct larger denom std::vector validVin; std::vector validVout; + validVin.reserve(CoinJoin::PROMOTION_RATIO); for (int i = 0; i < CoinJoin::PROMOTION_RATIO; ++i) { validVin.push_back(MakeDenomInput(static_cast(i))); } @@ -1571,6 +1582,7 @@ BOOST_AUTO_TEST_CASE(validate_promotion_entry_edge_cases) // Invalid: 9 inputs (wrong count) std::vector wrongCountVin; + wrongCountVin.reserve(9); for (int i = 0; i < 9; ++i) { wrongCountVin.push_back(MakeDenomInput(static_cast(i))); } @@ -1579,6 +1591,7 @@ BOOST_AUTO_TEST_CASE(validate_promotion_entry_edge_cases) // Invalid: 11 inputs (wrong count) std::vector tooManyVin; + tooManyVin.reserve(11); for (int i = 0; i < 11; ++i) { tooManyVin.push_back(MakeDenomInput(static_cast(i))); } @@ -1614,6 +1627,7 @@ BOOST_AUTO_TEST_CASE(validate_demotion_entry_edge_cases) validVin.push_back(MakeDenomInput(0)); std::vector validVout; + validVout.reserve(CoinJoin::PROMOTION_RATIO); for (int i = 0; i < CoinJoin::PROMOTION_RATIO; ++i) { validVout.push_back(MakeDenomOutput(nSessionAmount, static_cast(i))); } @@ -1630,6 +1644,7 @@ BOOST_AUTO_TEST_CASE(validate_demotion_entry_edge_cases) // Invalid: 9 outputs (wrong count) std::vector nineOutputs; + nineOutputs.reserve(9); for (int i = 0; i < 9; ++i) { nineOutputs.push_back(MakeDenomOutput(nSessionAmount, static_cast(i))); } diff --git a/src/test/coinjoin_queue_tests.cpp b/src/test/coinjoin_queue_tests.cpp index 3440c8a1fd36..65c5c04da889 100644 --- a/src/test/coinjoin_queue_tests.cpp +++ b/src/test/coinjoin_queue_tests.cpp @@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(queue_hashes_and_equality) { const auto a{MakeQueue(CoinJoin::AmountToDenomination(CoinJoin::GetSmallestDenomination()), GetAdjustedTime(), /*fReady=*/true, COutPoint{uint256S("bb"), 2})}; - const auto b{a}; + const auto b{a}; // NOLINT(performance-unnecessary-copy-initialization): the copy is under test BOOST_CHECK(a == b); BOOST_CHECK(a.GetHash() == b.GetHash()); diff --git a/src/test/evo_deterministicmns_tests.cpp b/src/test/evo_deterministicmns_tests.cpp index 2da07254ffaa..90c6c6644744 100644 --- a/src/test/evo_deterministicmns_tests.cpp +++ b/src/test/evo_deterministicmns_tests.cpp @@ -2311,6 +2311,7 @@ void FuncTestMinerKeyChangeNotHeldBackByOtherKeyChange(TestChainSetup& setup) size(tx_serv_b) + 1}; BOOST_REQUIRE_GT(size(serv_a[1]) + size(serv_a[2]) + size(serv_a[3]), size(tx_key_change_b) + size(tx_serv_b) + 1); std::vector> txs; + txs.reserve(serv_a.size() + 3); for (const auto& tx : serv_a) { txs.emplace_back(tx, low_fee); } diff --git a/src/test/evo_simplifiedmns_tests.cpp b/src/test/evo_simplifiedmns_tests.cpp index 7b3aca07009b..8fcde74470c9 100644 --- a/src/test/evo_simplifiedmns_tests.cpp +++ b/src/test/evo_simplifiedmns_tests.cpp @@ -59,6 +59,7 @@ BOOST_AUTO_TEST_CASE(simplifiedmns_merkleroots) "67798d40a2196f446114c68d86445fe088750515a96eb65392c6bcfac8f3be9b" }; std::vector calculatedHashes; + calculatedHashes.reserve(entries.size()); for (auto& smle : entries) { calculatedHashes.emplace_back(smle->CalcHash().ToString()); diff --git a/src/test/evo_snapshot_tests.cpp b/src/test/evo_snapshot_tests.cpp index 8c38d0677ff4..4ec96ff76702 100644 --- a/src/test/evo_snapshot_tests.cpp +++ b/src/test/evo_snapshot_tests.cpp @@ -193,7 +193,7 @@ evo::EvoSnapshot SyntheticSnapshot(bool reverse_representation = false) list.GetTotalRegisteredCount(), evo::CanonicalMNListHash(list), previous.BuildDiff(list)}); previous_hash = work_hash; - previous = std::move(list); + previous = list; } for (const auto& [type, work_hash] : modifier_keys) { snapshot.quorum_modifiers.push_back({type, work_hash, H(static_cast(150 + snapshot.quorum_modifiers.size()))}); diff --git a/src/test/governance_inv_tests.cpp b/src/test/governance_inv_tests.cpp index a53b84ba0a1b..f1b21d04775f 100644 --- a/src/test/governance_inv_tests.cpp +++ b/src/test/governance_inv_tests.cpp @@ -423,6 +423,7 @@ BOOST_AUTO_TEST_CASE(governance_objects_wait_for_the_collateral_index) // The peer's transaction announcements take up all the announcements it may have pending // (MAX_PEER_OBJECT_ANNOUNCEMENTS) std::vector tx_invs; + tx_invs.reserve(2 * MAX_INV_SZ); for (uint64_t i = 0; i < 2 * MAX_INV_SZ; ++i) { tx_invs.emplace_back(MSG_TX, ArithToUint256(arith_uint256{i})); } diff --git a/src/test/llmq_snapshot_tests.cpp b/src/test/llmq_snapshot_tests.cpp index bfdb62c6374d..3b6fefd0527b 100644 --- a/src/test/llmq_snapshot_tests.cpp +++ b/src/test/llmq_snapshot_tests.cpp @@ -104,6 +104,7 @@ BOOST_AUTO_TEST_CASE(quorum_snapshot_large_data_test) // Create large skip list std::vector largeSkipList; + largeSkipList.reserve(100); for (int i = 0; i < 100; i++) { largeSkipList.push_back(i * 4); } diff --git a/src/test/quorum_proofs_tests.cpp b/src/test/quorum_proofs_tests.cpp index 5b3993fc5d1c..7aab713dcd3b 100644 --- a/src/test/quorum_proofs_tests.cpp +++ b/src/test/quorum_proofs_tests.cpp @@ -396,6 +396,7 @@ BOOST_FIXTURE_TEST_CASE(rotating_commitment_scan_resumes_below_cached_cycles, Qu const auto* start = chain[checkpoint_height]; const auto hashes = [](const std::vector& scanned) { std::vector result; + result.reserve(scanned.size()); for (const auto& qc : scanned) result.push_back(qc.quorumHash); return result; @@ -447,6 +448,7 @@ BOOST_FIXTURE_TEST_CASE(consensus_valid_envelopes_are_provable, QuorumProofGener // hash to the block's own quorum root. const auto active = builder.ActiveCommitments(checkpoint); std::vector active_leaves; + active_leaves.reserve(active.size()); for (const auto& commitment : active) active_leaves.push_back(::SerializeHash(commitment)); BOOST_CHECK(std::is_sorted(active_leaves.begin(), active_leaves.end())); @@ -457,6 +459,7 @@ BOOST_FIXTURE_TEST_CASE(consensus_valid_envelopes_are_provable, QuorumProofGener const auto target_set = builder.ActiveCommitments(chain[state.height]); BOOST_REQUIRE(!target_set.empty()); std::vector leaves; + leaves.reserve(target_set.size()); for (const auto& commitment : target_set) leaves.push_back(::SerializeHash(commitment)); CDataStream raw(SER_NETWORK, PROTOCOL_VERSION); @@ -588,6 +591,7 @@ BOOST_AUTO_TEST_CASE(v20_checkpoint_height_is_supported) BOOST_AUTO_TEST_CASE(concurrent_proof_cache_requests) { std::vector> requests; + requests.reserve(8); for (int i = 0; i < 8; ++i) { requests.push_back(std::async(std::launch::async, [] { // Each request owns its BLS objects; only the caches are shared. diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index e6b37b7f5549..55ac8aae359a 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -278,16 +278,14 @@ BOOST_AUTO_TEST_CASE(mempool_locks_reorg) std::vector txs; for (int num_txs = 22; num_txs > 0; --num_txs) { CMutableTransaction mtx; - mtx.vin.push_back( - CTxIn(COutPoint(last_mined->vtx[0]->GetHash(), 1), - CScript() << ToByteVector(CScript() << OP_TRUE))); + mtx.vin.emplace_back(COutPoint(last_mined->vtx[0]->GetHash(), 1), + CScript() << ToByteVector(CScript() << OP_TRUE)); // Two outputs to make sure the transaction is larger than 100 bytes for (int i = 1; i < 3; ++i) { - mtx.vout.emplace_back( - CTxOut(50000, - CScript() << OP_DUP << OP_HASH160 - << ToByteVector(CScriptID(CScript() << i)) - << OP_EQUALVERIFY << OP_CHECKSIG)); + mtx.vout.emplace_back(50000, + CScript() << OP_DUP << OP_HASH160 + << ToByteVector(CScriptID(CScript() << i)) + << OP_EQUALVERIFY << OP_CHECKSIG); } txs.push_back(MakeTransactionRef(mtx)); From 8d2773c64725b926900f395b046bdfe358a40260 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 6 Nov 2026 04:15:17 +0700 Subject: [PATCH 4/8] fix: add test hunks missing from the bitcoin#26642, #28583 and #31305 backports clang-tidy now checks the unit and fuzz tests with src/.clang-tidy, and fails on test code that upstream fixed in these PRs but whose hunks the backports did not carry: - bitcoin#26642 (7e975e6cf8): reserve request_order in txrequest_tests.cpp. - bitcoin#28583 (fa05a726c2): emplace the options RPCArg in rpc_tests.cpp instead of constructing a temporary. - bitcoin#31305 (11f3bc229c): reserve outpoints and tx_mut.vin in the txorphan fuzz target. --- src/test/fuzz/txorphan.cpp | 2 ++ src/test/rpc_tests.cpp | 2 +- src/test/txrequest_tests.cpp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/fuzz/txorphan.cpp b/src/test/fuzz/txorphan.cpp index 5d030fe84b83..8e250a486832 100644 --- a/src/test/fuzz/txorphan.cpp +++ b/src/test/fuzz/txorphan.cpp @@ -40,6 +40,7 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage) TxOrphanage orphanage; std::vector outpoints; + outpoints.reserve(200'000); // initial outpoints used to construct transactions later for (uint8_t i = 0; i < 4; i++) { outpoints.emplace_back(uint256{i}, 0); @@ -55,6 +56,7 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage) const auto num_in = fuzzed_data_provider.ConsumeIntegralInRange(1, outpoints.size()); const auto num_out = fuzzed_data_provider.ConsumeIntegralInRange(1, outpoints.size()); // pick unique outpoints from outpoints as input + tx_mut.vin.reserve(num_in); for (uint32_t i = 0; i < num_in; i++) { auto& prevout = PickValue(fuzzed_data_provider, outpoints); tx_mut.vin.emplace_back(prevout); diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index 8d1bf52e001a..19593b66d9e6 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -516,7 +516,7 @@ BOOST_AUTO_TEST_CASE(check_dup_param_names) auto make_rpc = [](std::vector> param_names) { std::vector params; std::vector options; - auto push_options = [&] { if (!options.empty()) params.emplace_back(RPCArg{strprintf("options%i", params.size()), RPCArg::Type::OBJ_NAMED_PARAMS, RPCArg::Optional::OMITTED, "", std::move(options)}); }; + auto push_options = [&] { if (!options.empty()) params.emplace_back(strprintf("options%i", params.size()), RPCArg::Type::OBJ_NAMED_PARAMS, RPCArg::Optional::OMITTED, "", std::move(options)); }; for (auto& [param_name, param_type] : param_names) { if (param_type == POSITIONAL) { push_options(); diff --git a/src/test/txrequest_tests.cpp b/src/test/txrequest_tests.cpp index 816391165be9..c20c9fe72986 100644 --- a/src/test/txrequest_tests.cpp +++ b/src/test/txrequest_tests.cpp @@ -407,6 +407,7 @@ void BuildBigPriorityTest(Scenario& scenario, int peers) } // Make a list of all peers, in order of intended request order (concatenation of pref_peers and npref_peers). std::vector request_order; + request_order.reserve(num_pref + num_npref); for (int i = 0; i < num_pref; ++i) request_order.push_back(pref_peers[i]); for (int i = 0; i < num_npref; ++i) request_order.push_back(npref_peers[i]); From 3b0029d9c165026be0032142abfe38089a5f4509 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 6 Nov 2026 03:30:57 +0700 Subject: [PATCH 5/8] fix: partially revert partial bitcoin#33445: Update Clang in "tidy" job Upstream generates src/test/.clang-tidy into the build directory, where it only covers the capnp-generated IPC test sources. Linked into the source tree, it replaced src/.clang-tidy for every unit test with clang-tidy's defaults, running the static analyzer over them and printing hundreds of clang-analyzer warnings. Dash has no generated sources in src/test, so drop the file. Without it thousands of lines of useless warnings are generated for src/test directory with default clang-tidy config --- configure.ac | 1 - src/test/.clang-tidy | 3 --- 2 files changed, 4 deletions(-) delete mode 100644 src/test/.clang-tidy diff --git a/configure.ac b/configure.ac index de88e4c1dfdb..065725610543 100644 --- a/configure.ac +++ b/configure.ac @@ -2048,7 +2048,6 @@ AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py]) AC_CONFIG_LINKS([src/.bear-tidy-config:src/.bear-tidy-config]) AC_CONFIG_LINKS([src/.clang-tidy:src/.clang-tidy]) AC_CONFIG_LINKS([src/ipc/.clang-tidy:src/ipc/.clang-tidy]) -AC_CONFIG_LINKS([src/test/.clang-tidy:src/test/.clang-tidy]) AC_CONFIG_LINKS([test/functional/test_runner.py:test/functional/test_runner.py]) AC_CONFIG_LINKS([test/fuzz/test_runner.py:test/fuzz/test_runner.py]) AC_CONFIG_LINKS([test/util/test_runner.py:test/util/test_runner.py]) diff --git a/src/test/.clang-tidy b/src/test/.clang-tidy deleted file mode 100644 index 92d24f6f660a..000000000000 --- a/src/test/.clang-tidy +++ /dev/null @@ -1,3 +0,0 @@ -Checks: - # See: https://github.com/capnproto/capnproto/pull/2417. - - "-clang-analyzer-security.ArrayBound" From 70cfcd087a467290586f6997863094fc6f7d5416 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 6 Nov 2026 01:52:41 +0700 Subject: [PATCH 6/8] ci: skip Qt moc and qrc files in clang-tidy, as upstream does lint-tidy.sh removed the generated moc_*.cpp and qrc_*.cpp files from the compilation database only after clang-tidy had run, so the filter applied to IWYU alone, and clang-tidy spent time on code that nobody edits. Upstream filters these files before running clang-tidy. Apply the filter before both tools. --- ci/dash/lint-tidy.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ci/dash/lint-tidy.sh b/ci/dash/lint-tidy.sh index 3dbb26c16050..3fdf465125a4 100755 --- a/ci/dash/lint-tidy.sh +++ b/ci/dash/lint-tidy.sh @@ -66,6 +66,14 @@ python3 "${CLANG_TIDY_CACHE_PY}" --zero-stats 2>&1 || true cd "${BASE_ROOT_DIR}/build-ci/dashcore-${BUILD_TARGET}/src" +# Filter out files by regex here, because regex may not be +# accepted in src/.bear-tidy-config +# Filter out: +# * qt qrc and moc generated files +# * secp256k1 +jq 'map(select(.file | test("src/qt/qrc_.*\\.cpp$|/moc_.*\\.cpp$|src/secp256k1/src/") | not))' ../compile_commands.json > tmp.json +mv tmp.json ../compile_commands.json + CAST_LINT_DB="${PWD}/../cstyle-cast-compile-db" python3 "${BASE_ROOT_DIR}/ci/dash/lint-cstyle-casts.py" prepare \ --input "${PWD}/../compile_commands.json" \ @@ -94,14 +102,6 @@ python3 "${CLANG_TIDY_CACHE_PY}" --show-stats 2>&1 || true cleanup_ctcache "${CTCACHE_DIR}" "${CTCACHE_MAXSIZE_MB}" echo "==========================" -# Filter out files by regex here, because regex may not be -# accepted in src/.bear-tidy-config -# Filter out: -# * qt qrc and moc generated files -# * secp256k1 -jq 'map(select(.file | test("src/qt/qrc_.*\\.cpp$|/moc_.*\\.cpp$|src/secp256k1/src/") | not))' ../compile_commands.json > tmp.json -mv tmp.json ../compile_commands.json - cd "${BASE_ROOT_DIR}/build-ci/dashcore-${BUILD_TARGET}" iwyu_tool.py \ -p . "${MAKEJOBS}" \ From f4581845786dd7721a29d14d315676ce8e3dd44a Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 6 Nov 2026 03:38:49 +0700 Subject: [PATCH 7/8] ci: show IWYU's suggested changes instead of its raw output fix_includes.py edits the files named in IWYU's output relative to its working directory. lint-tidy.sh ran it in the make distdir copy in build-ci/dashcore-*/src, which git does not track, so the git diff that follows was always empty and the 40-minute IWYU step showed nothing but several MB of raw output. Upstream runs fix_includes.py in the checkout. Run it in src/ of the checkout, so git diff shows the suggested changes, and keep IWYU's raw output out of the log. If iwyu_tool.py fails, print its errors, or the end of its output if there are none, as the clang-tidy step does. --- ci/dash/lint-tidy.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ci/dash/lint-tidy.sh b/ci/dash/lint-tidy.sh index 3fdf465125a4..3d2da88e538b 100755 --- a/ci/dash/lint-tidy.sh +++ b/ci/dash/lint-tidy.sh @@ -103,12 +103,17 @@ cleanup_ctcache "${CTCACHE_DIR}" "${CTCACHE_MAXSIZE_MB}" echo "==========================" cd "${BASE_ROOT_DIR}/build-ci/dashcore-${BUILD_TARGET}" -iwyu_tool.py \ +if ! iwyu_tool.py \ -p . "${MAKEJOBS}" \ -- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \ -Xiwyu --max_line_length=160 \ - 2>&1 | tee "/tmp/iwyu_ci.out" + > "/tmp/iwyu_ci.out" 2>&1; then + grep -E -C5 "error: |Traceback" /tmp/iwyu_ci.out || tail -n 50 /tmp/iwyu_ci.out + echo "^^^ ⚠️ Failure generated from IWYU" + false +fi -cd "${BASE_ROOT_DIR}/build-ci/dashcore-${BUILD_TARGET}/src" +# Fix the tracked sources rather than the untracked build copy, so that git diff shows the result +cd "${BASE_ROOT_DIR}/src" fix_includes.py --nosafe_headers < /tmp/iwyu_ci.out git --no-pager diff From b3f46f3e0616ac8533ab8c22297021ee374e90f2 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 6 Nov 2026 17:52:00 +0700 Subject: [PATCH 8/8] ci: add capnp to iwyu exception as well This files are auto-generated and it causes failure of iwyu when running on CI: ... >>> Fixing #includes in 'script/interpreter.cpp' >>> Fixing #includes in 'util/string.h' sys.exit(main(sys.argv)) File "/usr/local/bin/fix_includes.py", line 2461, in main ProcessIWYUOutput(sys.stdin, files_to_modify, flags, cwd=os.getcwd()) File "/usr/local/bin/fix_includes.py", line 2318, in ProcessIWYUOutput return FixManyFiles(contentful_records, flags) File "/usr/local/bin/fix_includes.py", line 2225, in FixManyFiles fileinfo = FileInfo.parse(iwyu_record.filename) File "/usr/local/bin/fix_includes.py", line 538, in parse with open(filename, 'rb') as f: FileNotFoundError: [Errno 2] No such file or directory: 'ipc/capnp/echo.capnp.h' --- ci/dash/lint-tidy.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ci/dash/lint-tidy.sh b/ci/dash/lint-tidy.sh index 3d2da88e538b..be2639e1d5ab 100755 --- a/ci/dash/lint-tidy.sh +++ b/ci/dash/lint-tidy.sh @@ -113,7 +113,8 @@ if ! iwyu_tool.py \ false fi -# Fix the tracked sources rather than the untracked build copy, so that git diff shows the result +# Fix the tracked sources rather than the untracked build copy, so that git diff shows the result. +# The generated capnp files exist only in the build directory. cd "${BASE_ROOT_DIR}/src" -fix_includes.py --nosafe_headers < /tmp/iwyu_ci.out +fix_includes.py --nosafe_headers --ignore_re='\.capnp\.' < /tmp/iwyu_ci.out git --no-pager diff