Skip to content

Commit 89f41fa

Browse files
kwvgPastaPastaPasta
authored andcommitted
refactor: dereference CDeterministicMNManager instance before use
1 parent d3dfdf3 commit 89f41fa

File tree

2 files changed

+79
-70
lines changed

2 files changed

+79
-70
lines changed

src/test/block_reward_reallocation_tests.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ BOOST_AUTO_TEST_SUITE(block_reward_reallocation_tests)
146146

147147
BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationSetup)
148148
{
149+
auto& dmnman = *Assert(m_node.dmnman);
149150
const auto& consensus_params = Params().GetConsensus();
150151

151152
CScript coinbasePubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
@@ -163,9 +164,9 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS
163164
{
164165
LOCK(cs_main);
165166
const CBlockIndex* const tip{m_node.chainman->ActiveChain().Tip()};
166-
deterministicMNManager->UpdatedBlockTip(tip);
167+
dmnman.UpdatedBlockTip(tip);
167168

168-
BOOST_ASSERT(deterministicMNManager->GetListAtChainTip().HasMN(tx.GetHash()));
169+
BOOST_ASSERT(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
169170

170171
BOOST_CHECK_EQUAL(tip->nHeight, 498);
171172
BOOST_CHECK(tip->nHeight < Params().GetConsensus().BRRHeight);
@@ -177,16 +178,16 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS
177178
LOCK(cs_main);
178179
const CBlockIndex* const tip{m_node.chainman->ActiveChain().Tip()};
179180
BOOST_CHECK_EQUAL(tip->nHeight, 499);
180-
deterministicMNManager->UpdatedBlockTip(tip);
181-
BOOST_ASSERT(deterministicMNManager->GetListAtChainTip().HasMN(tx.GetHash()));
181+
dmnman.UpdatedBlockTip(tip);
182+
BOOST_ASSERT(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
182183
BOOST_CHECK(tip->nHeight < Params().GetConsensus().BRRHeight);
183184
// Creating blocks by different ways
184185
const auto pblocktemplate = BlockAssembler(*sporkManager, *governance, *m_node.llmq_ctx, *m_node.evodb, m_node.chainman->ActiveChainstate(), *m_node.mempool, Params()).CreateNewBlock(coinbasePubKey);
185186
}
186187
for ([[maybe_unused]] auto _ : irange::range(1999)) {
187188
CreateAndProcessBlock({}, coinbaseKey);
188189
LOCK(cs_main);
189-
deterministicMNManager->UpdatedBlockTip(m_node.chainman->ActiveChain().Tip());
190+
dmnman.UpdatedBlockTip(m_node.chainman->ActiveChain().Tip());
190191
}
191192
BOOST_CHECK(m_node.chainman->ActiveChain().Height() < Params().GetConsensus().BRRHeight);
192193
CreateAndProcessBlock({}, coinbaseKey);
@@ -196,8 +197,8 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS
196197
LOCK(cs_main);
197198
const CBlockIndex* const tip{m_node.chainman->ActiveChain().Tip()};
198199
BOOST_CHECK_EQUAL(tip->nHeight, Params().GetConsensus().BRRHeight - 1);
199-
deterministicMNManager->UpdatedBlockTip(tip);
200-
BOOST_ASSERT(deterministicMNManager->GetListAtChainTip().HasMN(tx.GetHash()));
200+
dmnman.UpdatedBlockTip(tip);
201+
BOOST_ASSERT(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
201202
}
202203

203204
{
@@ -207,8 +208,8 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS
207208
LOCK(cs_main);
208209
const CBlockIndex* const tip{m_node.chainman->ActiveChain().Tip()};
209210
const bool isV20Active{DeploymentActiveAfter(tip, consensus_params, Consensus::DEPLOYMENT_V20)};
210-
deterministicMNManager->UpdatedBlockTip(tip);
211-
BOOST_ASSERT(deterministicMNManager->GetListAtChainTip().HasMN(tx.GetHash()));
211+
dmnman.UpdatedBlockTip(tip);
212+
BOOST_ASSERT(dmnman.GetListAtChainTip().HasMN(tx.GetHash()));
212213
const CAmount block_subsidy = GetBlockSubsidyInner(tip->nBits, tip->nHeight, consensus_params, isV20Active);
213214
const CAmount masternode_payment = GetMasternodePayment(tip->nHeight, block_subsidy, isV20Active);
214215
const auto pblocktemplate = BlockAssembler(*sporkManager, *governance, *m_node.llmq_ctx, *m_node.evodb, m_node.chainman->ActiveChainstate(), *m_node.mempool, Params()).CreateNewBlock(coinbasePubKey);

0 commit comments

Comments
 (0)