mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
Merge bitcoin/bitcoin#33840: test: [refactor] Use reference over ptr to chainman
7a4901c902test, refactor: Fix `-Warray-bounds` warning (Hennadii Stepanov)faf2759c8ctest: [refactor] Use reference over ptr to chainman (MarcoFalke) Pull request description: Just some minor test-only refactor commits to fix GCC false positive warnings, along with making the test code easier to read and understand: * First change requested in https://github.com/bitcoin/bitcoin/pull/33785#discussion_r2510727269 * Second change requested in commit 3b135a8fc4451c93b3ea50b3f4621e0d19f35daf Those changes are required in a bunch of pulls touching the CI system, so merging them allows to drop them in all pulls. ACKs for top commit: l0rinc: ACK7a4901c902hebasto: ACK7a4901c902, I have reviewed the code and it looks OK. Tree-SHA512: 64dca52ec7b25078bf489e2d8b43e449f4968fbac14a09c66a60cdc75b513588403665f248368820694a6f72c4f7f465589d9306355239cffe35c38111929eff
This commit is contained in:
@@ -19,10 +19,7 @@ export GOAL="install"
|
||||
export CI_LIMIT_STACK_SIZE=1
|
||||
# -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1"
|
||||
# This could be removed once the ABI change warning does not show up by default
|
||||
#
|
||||
# -Wno-error=dangling-reference helps to work around a GCC 13.1 false-positive,
|
||||
# fixed in later versions.
|
||||
export BITCOIN_CONFIG=" \
|
||||
-DREDUCE_EXPORTS=ON \
|
||||
-DCMAKE_CXX_FLAGS='-Wno-psabi -Wno-error=dangling-reference -Wno-error=maybe-uninitialized' \
|
||||
-DCMAKE_CXX_FLAGS='-Wno-psabi -Wno-error=maybe-uninitialized' \
|
||||
"
|
||||
|
||||
@@ -13,8 +13,6 @@ export PACKAGES="g++-mingw-w64-x86-64-posix nsis"
|
||||
export RUN_UNIT_TESTS=false
|
||||
export RUN_FUNCTIONAL_TESTS=false
|
||||
export GOAL="deploy"
|
||||
# -Wno-error=dangling-reference helps to work around a GCC 13.1 false-positive,
|
||||
# fixed in later versions.
|
||||
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_GUI_TESTS=OFF -DBUILD_KERNEL_LIB=ON -DBUILD_KERNEL_TEST=ON \
|
||||
-DCMAKE_CXX_FLAGS='-Wno-error=dangling-reference -Wno-error=maybe-uninitialized' \
|
||||
-DCMAKE_CXX_FLAGS='-Wno-error=maybe-uninitialized' \
|
||||
"
|
||||
|
||||
@@ -60,16 +60,16 @@ BOOST_AUTO_TEST_CASE(blockmanager_find_block_pos)
|
||||
BOOST_FIXTURE_TEST_CASE(blockmanager_scan_unlink_already_pruned_files, TestChain100Setup)
|
||||
{
|
||||
// Cap last block file size, and mine new block in a new block file.
|
||||
const auto& chainman = Assert(m_node.chainman);
|
||||
auto& blockman = chainman->m_blockman;
|
||||
const CBlockIndex* old_tip{WITH_LOCK(chainman->GetMutex(), return chainman->ActiveChain().Tip())};
|
||||
WITH_LOCK(chainman->GetMutex(), blockman.GetBlockFileInfo(old_tip->GetBlockPos().nFile)->nSize = MAX_BLOCKFILE_SIZE);
|
||||
auto& chainman{*Assert(m_node.chainman)};
|
||||
auto& blockman{chainman.m_blockman};
|
||||
const CBlockIndex* old_tip{WITH_LOCK(chainman.GetMutex(), return chainman.ActiveChain().Tip())};
|
||||
WITH_LOCK(chainman.GetMutex(), blockman.GetBlockFileInfo(old_tip->GetBlockPos().nFile)->nSize = MAX_BLOCKFILE_SIZE);
|
||||
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
|
||||
|
||||
// Prune the older block file, but don't unlink it
|
||||
int file_number;
|
||||
{
|
||||
LOCK(chainman->GetMutex());
|
||||
LOCK(chainman.GetMutex());
|
||||
file_number = old_tip->GetBlockPos().nFile;
|
||||
blockman.PruneOneBlockFile(file_number);
|
||||
}
|
||||
@@ -78,22 +78,22 @@ BOOST_FIXTURE_TEST_CASE(blockmanager_scan_unlink_already_pruned_files, TestChain
|
||||
|
||||
// Check that the file is not unlinked after ScanAndUnlinkAlreadyPrunedFiles
|
||||
// if m_have_pruned is not yet set
|
||||
WITH_LOCK(chainman->GetMutex(), blockman.ScanAndUnlinkAlreadyPrunedFiles());
|
||||
WITH_LOCK(chainman.GetMutex(), blockman.ScanAndUnlinkAlreadyPrunedFiles());
|
||||
BOOST_CHECK(!blockman.OpenBlockFile(pos, true).IsNull());
|
||||
|
||||
// Check that the file is unlinked after ScanAndUnlinkAlreadyPrunedFiles
|
||||
// once m_have_pruned is set
|
||||
blockman.m_have_pruned = true;
|
||||
WITH_LOCK(chainman->GetMutex(), blockman.ScanAndUnlinkAlreadyPrunedFiles());
|
||||
WITH_LOCK(chainman.GetMutex(), blockman.ScanAndUnlinkAlreadyPrunedFiles());
|
||||
BOOST_CHECK(blockman.OpenBlockFile(pos, true).IsNull());
|
||||
|
||||
// Check that calling with already pruned files doesn't cause an error
|
||||
WITH_LOCK(chainman->GetMutex(), blockman.ScanAndUnlinkAlreadyPrunedFiles());
|
||||
WITH_LOCK(chainman.GetMutex(), blockman.ScanAndUnlinkAlreadyPrunedFiles());
|
||||
|
||||
// Check that the new tip file has not been removed
|
||||
const CBlockIndex* new_tip{WITH_LOCK(chainman->GetMutex(), return chainman->ActiveChain().Tip())};
|
||||
const CBlockIndex* new_tip{WITH_LOCK(chainman.GetMutex(), return chainman.ActiveChain().Tip())};
|
||||
BOOST_CHECK_NE(old_tip, new_tip);
|
||||
const int new_file_number{WITH_LOCK(chainman->GetMutex(), return new_tip->GetBlockPos().nFile)};
|
||||
const int new_file_number{WITH_LOCK(chainman.GetMutex(), return new_tip->GetBlockPos().nFile)};
|
||||
const FlatFilePos new_pos(new_file_number, 0);
|
||||
BOOST_CHECK(!blockman.OpenBlockFile(new_pos, true).IsNull());
|
||||
}
|
||||
|
||||
@@ -1301,7 +1301,7 @@ public:
|
||||
{
|
||||
// Construct contents consisting of 0x00 + 12-byte message type + payload.
|
||||
std::vector<uint8_t> contents(1 + CMessageHeader::MESSAGE_TYPE_SIZE + payload.size());
|
||||
std::copy(mtype.begin(), mtype.end(), reinterpret_cast<char*>(contents.data() + 1));
|
||||
std::copy(mtype.begin(), mtype.end(), contents.begin() + 1);
|
||||
std::copy(payload.begin(), payload.end(), contents.begin() + 1 + CMessageHeader::MESSAGE_TYPE_SIZE);
|
||||
// Send a packet with that as contents.
|
||||
SendPacket(contents);
|
||||
|
||||
Reference in New Issue
Block a user