diff --git a/src/test/blockmanager_tests.cpp b/src/test/blockmanager_tests.cpp index d3b58143719..f06665d3055 100644 --- a/src/test/blockmanager_tests.cpp +++ b/src/test/blockmanager_tests.cpp @@ -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)