Skip to content

Commit

Permalink
partial merge bitcoin#27783: Add public Boost headers explicitly
Browse files Browse the repository at this point in the history
2484cac Add public Boost headers explicitly (Hennadii Stepanov)
fade2ad test: Avoid `BOOST_ASSERT` macro (Hennadii Stepanov)

Pull request description:

  To check symbols in the code base, run:
  ```
  git grep boost::multi_index::identity
  git grep boost::multi_index::indexed_by
  git grep boost::multi_index::tag
  git grep boost::make_tuple
  ```

  Hoping on the absence of conflicts with top-prio PRs :)

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 2484cac
  TheCharlatan:
    ACK 2484cac

Tree-SHA512: d122ab028eee76ee1c4609ed51ec8db0c8c768edcc2ff2c0e420a48e051aa71e99748cdb5d22985ae6d97c808c77c1a27561f0715f77b256f74c1c310b37694c
  • Loading branch information
fanquake authored and PastaPastaPasta committed Oct 7, 2024
1 parent 49fcd4a commit c0154c0
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 81 deletions.
5 changes: 4 additions & 1 deletion src/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
#include <optional>
#include <stdint.h>

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/indexed_by.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/tag.hpp>
#include <boost/multi_index_container.hpp>

class BlockManager;
class CBlockIndex;
Expand Down
17 changes: 9 additions & 8 deletions src/test/block_reward_reallocation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static std::vector<COutPoint> SelectUTXOs(const CChain& active_chain, SimpleUTXO
utoxs.erase(it);
break;
}
BOOST_ASSERT(found);
BOOST_REQUIRE(found);
if (selectedAmount >= amount) {
changeRet = selectedAmount - amount;
break;
Expand Down Expand Up @@ -102,8 +102,8 @@ static void SignTransaction(const CTxMemPool& mempool, CMutableTransaction& tx,
for (auto [i, input] : enumerate(tx.vin)) {
uint256 hashBlock;
CTransactionRef txFrom = GetTransaction(/* block_index */ nullptr, &mempool, input.prevout.hash, Params().GetConsensus(), hashBlock);
BOOST_ASSERT(txFrom);
BOOST_ASSERT(SignSignature(tempKeystore, *txFrom, tx, i, SIGHASH_ALL));
BOOST_REQUIRE(txFrom);
BOOST_REQUIRE(SignSignature(tempKeystore, *txFrom, tx, i, SIGHASH_ALL));
}
}

Expand Down Expand Up @@ -148,7 +148,8 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS

CScript coinbasePubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;

BOOST_ASSERT(DeploymentDIP0003Enforced(WITH_LOCK(cs_main, return m_node.chainman->ActiveChain().Height()), consensus_params));
BOOST_REQUIRE(DeploymentDIP0003Enforced(WITH_LOCK(cs_main, return m_node.chainman->ActiveChain().Height()),
consensus_params));

// Register one MN
CKey ownerKey;
Expand All @@ -163,7 +164,7 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS
const CBlockIndex* const tip{m_node.chainman->ActiveChain().Tip()};
dmnman.UpdatedBlockTip(tip);

BOOST_ASSERT(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
BOOST_REQUIRE(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));

BOOST_CHECK_EQUAL(tip->nHeight, 498);
BOOST_CHECK(tip->nHeight < Params().GetConsensus().BRRHeight);
Expand All @@ -176,7 +177,7 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS
const CBlockIndex* const tip{m_node.chainman->ActiveChain().Tip()};
BOOST_CHECK_EQUAL(tip->nHeight, 499);
dmnman.UpdatedBlockTip(tip);
BOOST_ASSERT(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
BOOST_REQUIRE(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
BOOST_CHECK(tip->nHeight < Params().GetConsensus().BRRHeight);
// Creating blocks by different ways
const auto pblocktemplate = BlockAssembler(m_node.chainman->ActiveChainstate(), m_node, *m_node.mempool, Params()).CreateNewBlock(coinbasePubKey);
Expand All @@ -195,7 +196,7 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS
const CBlockIndex* const tip{m_node.chainman->ActiveChain().Tip()};
BOOST_CHECK_EQUAL(tip->nHeight, Params().GetConsensus().BRRHeight - 1);
dmnman.UpdatedBlockTip(tip);
BOOST_ASSERT(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
BOOST_REQUIRE(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
}

{
Expand All @@ -206,7 +207,7 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS
const CBlockIndex* const tip{m_node.chainman->ActiveChain().Tip()};
const bool isV20Active{DeploymentActiveAfter(tip, consensus_params, Consensus::DEPLOYMENT_V20)};
dmnman.UpdatedBlockTip(tip);
BOOST_ASSERT(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
BOOST_REQUIRE(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
const CAmount block_subsidy = GetBlockSubsidyInner(tip->nBits, tip->nHeight, consensus_params, isV20Active);
const CAmount masternode_payment = GetMasternodePayment(tip->nHeight, block_subsidy, isV20Active);
const auto pblocktemplate = BlockAssembler(m_node.chainman->ActiveChainstate(), m_node, *m_node.mempool, Params()).CreateNewBlock(coinbasePubKey);
Expand Down
132 changes: 69 additions & 63 deletions src/test/evo_deterministicmns_tests.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/test/evo_simplifiedmns_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ BOOST_AUTO_TEST_CASE(simplifiedmns_merkleroots)
if (auto service = Lookup(ip, i, false); service.has_value()) {
smle.service = service.value();
} else {
BOOST_ASSERT(false);
BOOST_REQUIRE(false);
}

std::vector<unsigned char> vecBytes{static_cast<unsigned char>(i)};
Expand Down
8 changes: 4 additions & 4 deletions src/test/llmq_dkg_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ BOOST_AUTO_TEST_CASE(llmq_dkgerror)
{
using namespace llmq;
for (auto i : irange::range(ToUnderlying(llmq::DKGError::type::_COUNT))) {
BOOST_ASSERT(GetSimulatedErrorRate(llmq::DKGError::type(i)) == 0.0);
BOOST_REQUIRE(GetSimulatedErrorRate(llmq::DKGError::type(i)) == 0.0);
SetSimulatedDKGErrorRate(llmq::DKGError::type(i), 1.0);
BOOST_ASSERT(GetSimulatedErrorRate(llmq::DKGError::type(i)) == 1.0);
BOOST_REQUIRE(GetSimulatedErrorRate(llmq::DKGError::type(i)) == 1.0);
}
BOOST_ASSERT(GetSimulatedErrorRate(llmq::DKGError::type::_COUNT) == 0.0);
BOOST_REQUIRE(GetSimulatedErrorRate(llmq::DKGError::type::_COUNT) == 0.0);
SetSimulatedDKGErrorRate(llmq::DKGError::type::_COUNT, 1.0);
BOOST_ASSERT(GetSimulatedErrorRate(llmq::DKGError::type::_COUNT) == 0.0);
BOOST_REQUIRE(GetSimulatedErrorRate(llmq::DKGError::type::_COUNT) == 0.0);
}


Expand Down
6 changes: 3 additions & 3 deletions src/test/util/setup_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,13 @@ CBlock TestChainSetup::CreateBlock(
if (block.vtx[0]->nType == TRANSACTION_COINBASE) {
LOCK(cs_main);
auto cbTx = GetTxPayload<CCbTx>(*block.vtx[0]);
BOOST_ASSERT(cbTx.has_value());
Assert(cbTx.has_value());
BlockValidationState state;
if (!CalcCbTxMerkleRootMNList(block, chainstate.m_chain.Tip(), cbTx->merkleRootMNList, *m_node.dmnman, state, chainstate.CoinsTip())) {
BOOST_ASSERT(false);
Assert(false);
}
if (!CalcCbTxMerkleRootQuorums(block, chainstate.m_chain.Tip(), *m_node.llmq_ctx->quorum_block_processor, cbTx->merkleRootQuorums, state)) {
BOOST_ASSERT(false);
Assert(false);
}
CMutableTransaction tmpTx{*block.vtx[0]};
SetTxPayload(tmpTx, *cbTx);
Expand Down
3 changes: 3 additions & 0 deletions src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
#include <util/hasher.h>

#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/indexed_by.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/tag.hpp>
#include <boost/multi_index_container.hpp>

class CBlockIndex;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/test/coinjoin_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class CTransactionBuilderTestSetup : public TestChain100Setup
BOOST_FIXTURE_TEST_CASE(coinjoin_manager_start_stop_tests, CTransactionBuilderTestSetup)
{
CCoinJoinClientManager* cj_man = m_node.cj_ctx->walletman->Get("");
BOOST_ASSERT(cj_man != nullptr);
BOOST_REQUIRE(cj_man != nullptr);
BOOST_CHECK_EQUAL(cj_man->IsMixing(), false);
BOOST_CHECK_EQUAL(cj_man->StartMixing(), true);
BOOST_CHECK_EQUAL(cj_man->IsMixing(), true);
Expand Down
3 changes: 3 additions & 0 deletions test/lint/lint-includes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ fi
EXPECTED_BOOST_INCLUDES=(
boost/date_time/posix_time/posix_time.hpp
boost/multi_index/hashed_index.hpp
boost/multi_index/identity.hpp
boost/multi_index/indexed_by.hpp
boost/multi_index/ordered_index.hpp
boost/multi_index/sequenced_index.hpp
boost/multi_index/tag.hpp
boost/multi_index_container.hpp
boost/pool/pool_alloc.hpp
boost/process.hpp
Expand Down

0 comments on commit c0154c0

Please sign in to comment.