mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-24 03:21:06 +02:00
test: use local CBlockIndex
in block read hash mismatch test to avoid data race
Co-authored-by: stickies-v <stickies-v@protonmail.com>
This commit is contained in:
@@ -139,12 +139,18 @@ BOOST_FIXTURE_TEST_CASE(blockmanager_block_data_availability, TestChain100Setup)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(blockmanager_readblock_hash_mismatch, TestingSetup)
|
||||
{
|
||||
CBlockIndex* fake_index{WITH_LOCK(m_node.chainman->GetMutex(), return m_node.chainman->ActiveChain().Tip())};
|
||||
fake_index->phashBlock = &uint256::ONE; // invalid block hash
|
||||
CBlockIndex index;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
const auto tip{m_node.chainman->ActiveTip()};
|
||||
index.nStatus = tip->nStatus;
|
||||
index.nDataPos = tip->nDataPos;
|
||||
index.phashBlock = &uint256::ONE; // mismatched block hash
|
||||
}
|
||||
|
||||
ASSERT_DEBUG_LOG("GetHash() doesn't match index");
|
||||
CBlock dummy;
|
||||
BOOST_CHECK(!m_node.chainman->m_blockman.ReadBlock(dummy, *fake_index));
|
||||
CBlock block;
|
||||
BOOST_CHECK(!m_node.chainman->m_blockman.ReadBlock(block, index));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(blockmanager_flush_block_file)
|
||||
|
Reference in New Issue
Block a user