@@ -255,25 +255,6 @@ BOOST_AUTO_TEST_CASE(versionbits_test)
255
255
}
256
256
}
257
257
258
- BOOST_AUTO_TEST_CASE (versionbits_sanity)
259
- {
260
- // Sanity checks of version bit deployments
261
- const auto chainParams = CreateChainParams (*m_node.args , CBaseChainParams::MAIN);
262
- const Consensus::Params &mainnetParams = chainParams->GetConsensus ();
263
- for (int i=0 ; i<(int ) Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) {
264
- uint32_t bitmask = VersionBitsMask (mainnetParams, static_cast <Consensus::DeploymentPos>(i));
265
- // Make sure that no deployment tries to set an invalid bit.
266
- BOOST_CHECK_EQUAL (bitmask & ~(uint32_t )VERSIONBITS_TOP_MASK, bitmask);
267
-
268
- // Check min_activation_height is on a retarget boundary
269
- BOOST_CHECK_EQUAL (mainnetParams.vDeployments [i].min_activation_height % mainnetParams.nMinerConfirmationWindow , 0 );
270
- // Check min_activation_height is 0 for ALWAYS_ACTIVE and never active deployments
271
- if (mainnetParams.vDeployments [i].nStartTime == Consensus::BIP9Deployment::ALWAYS_ACTIVE || mainnetParams.vDeployments [i].nStartTime == Consensus::BIP9Deployment::NEVER_ACTIVE) {
272
- BOOST_CHECK_EQUAL (mainnetParams.vDeployments [i].min_activation_height , 0 );
273
- }
274
- }
275
- }
276
-
277
258
/* * Check that ComputeBlockVersion will set the appropriate bit correctly */
278
259
static void check_computeblockversion (const Consensus::Params& params, Consensus::DeploymentPos dep)
279
260
{
@@ -289,17 +270,26 @@ static void check_computeblockversion(const Consensus::Params& params, Consensus
289
270
BOOST_CHECK_EQUAL (ComputeBlockVersion (nullptr , params), VERSIONBITS_TOP_BITS);
290
271
291
272
// always/never active deployments shouldn't need to be tested further
292
- if (nStartTime == Consensus::BIP9Deployment::ALWAYS_ACTIVE) return ;
293
- if (nStartTime == Consensus::BIP9Deployment::NEVER_ACTIVE) return ;
273
+ if (nStartTime == Consensus::BIP9Deployment::ALWAYS_ACTIVE ||
274
+ nStartTime == Consensus::BIP9Deployment::NEVER_ACTIVE)
275
+ {
276
+ BOOST_CHECK_EQUAL (min_activation_height, 0 );
277
+ return ;
278
+ }
294
279
295
280
BOOST_REQUIRE (nStartTime < nTimeout);
296
281
BOOST_REQUIRE (nStartTime >= 0 );
297
282
BOOST_REQUIRE (nTimeout <= std::numeric_limits<uint32_t >::max () || nTimeout == Consensus::BIP9Deployment::NO_TIMEOUT);
298
283
BOOST_REQUIRE (0 <= bit && bit < 32 );
284
+ // Make sure that no deployment tries to set an invalid bit.
299
285
BOOST_REQUIRE (((1 << bit) & VERSIONBITS_TOP_MASK) == 0 );
300
286
BOOST_REQUIRE (min_activation_height >= 0 );
287
+ // Check min_activation_height is on a retarget boundary
301
288
BOOST_REQUIRE_EQUAL (min_activation_height % params.nMinerConfirmationWindow , 0U );
302
289
290
+ const uint32_t bitmask{VersionBitsMask (params, dep)};
291
+ BOOST_CHECK_EQUAL (bitmask, uint32_t {1 } << bit);
292
+
303
293
// In the first chain, test that the bit is set by CBV until it has failed.
304
294
// In the second chain, test the bit is set by CBV while STARTED and
305
295
// LOCKED-IN, and then no longer set while ACTIVE.
0 commit comments