mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-24 15:21:31 +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)
|
BOOST_FIXTURE_TEST_CASE(blockmanager_readblock_hash_mismatch, TestingSetup)
|
||||||
{
|
{
|
||||||
CBlockIndex* fake_index{WITH_LOCK(m_node.chainman->GetMutex(), return m_node.chainman->ActiveChain().Tip())};
|
CBlockIndex index;
|
||||||
fake_index->phashBlock = &uint256::ONE; // invalid block hash
|
{
|
||||||
|
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");
|
ASSERT_DEBUG_LOG("GetHash() doesn't match index");
|
||||||
CBlock dummy;
|
CBlock block;
|
||||||
BOOST_CHECK(!m_node.chainman->m_blockman.ReadBlock(dummy, *fake_index));
|
BOOST_CHECK(!m_node.chainman->m_blockman.ReadBlock(block, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(blockmanager_flush_block_file)
|
BOOST_AUTO_TEST_CASE(blockmanager_flush_block_file)
|
||||||
|
Reference in New Issue
Block a user