@@ -70,14 +70,18 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
70
70
BOOST_FIXTURE_TEST_CASE (chainstate_update_tip, TestChain100Setup)
71
71
{
72
72
ChainstateManager& chainman = *Assert (m_node.chainman );
73
- uint256 curr_tip = m_node.notifications ->m_tip_block ;
73
+ const auto get_notify_tip{[&]() {
74
+ LOCK (m_node.notifications ->m_tip_block_mutex );
75
+ return m_node.notifications ->m_tip_block ;
76
+ }};
77
+ uint256 curr_tip = get_notify_tip ();
74
78
75
79
// Mine 10 more blocks, putting at us height 110 where a valid assumeutxo value can
76
80
// be found.
77
81
mineBlocks (10 );
78
82
79
83
// After adding some blocks to the tip, best block should have changed.
80
- BOOST_CHECK (m_node. notifications -> m_tip_block != curr_tip);
84
+ BOOST_CHECK (get_notify_tip () != curr_tip);
81
85
82
86
// Grab block 1 from disk; we'll add it to the background chain later.
83
87
std::shared_ptr<CBlock> pblockone = std::make_shared<CBlock>();
@@ -92,15 +96,15 @@ BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
92
96
// Ensure our active chain is the snapshot chainstate.
93
97
BOOST_CHECK (WITH_LOCK (::cs_main, return chainman.IsSnapshotActive ()));
94
98
95
- curr_tip = m_node. notifications -> m_tip_block ;
99
+ curr_tip = get_notify_tip () ;
96
100
97
101
// Mine a new block on top of the activated snapshot chainstate.
98
102
mineBlocks (1 ); // Defined in TestChain100Setup.
99
103
100
104
// After adding some blocks to the snapshot tip, best block should have changed.
101
- BOOST_CHECK (m_node. notifications -> m_tip_block != curr_tip);
105
+ BOOST_CHECK (get_notify_tip () != curr_tip);
102
106
103
- curr_tip = m_node. notifications -> m_tip_block ;
107
+ curr_tip = get_notify_tip () ;
104
108
105
109
BOOST_CHECK_EQUAL (chainman.GetAll ().size (), 2 );
106
110
@@ -136,10 +140,10 @@ BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
136
140
// Ensure tip is as expected
137
141
BOOST_CHECK_EQUAL (background_cs.m_chain .Tip ()->GetBlockHash (), pblockone->GetHash ());
138
142
139
- // g_best_block should be unchanged after adding a block to the background
143
+ // get_notify_tip() should be unchanged after adding a block to the background
140
144
// validation chain.
141
145
BOOST_CHECK (block_added);
142
- BOOST_CHECK_EQUAL (curr_tip, m_node. notifications -> m_tip_block );
146
+ BOOST_CHECK_EQUAL (curr_tip, get_notify_tip () );
143
147
}
144
148
145
149
BOOST_AUTO_TEST_SUITE_END ()
0 commit comments