| 440 | }; // struct BlockVersionTest |
| 441 | |
| 442 | BOOST_FIXTURE_TEST_CASE(versionbits_computeblockversion, BlockVersionTest) |
| 443 | { |
| 444 | VersionBitsCache vbcache; |
| 445 | |
| 446 | // check that any deployment on any chain can conceivably reach both |
| 447 | // ACTIVE and FAILED states in roughly the way we expect |
| 448 | for (const auto& chain_type: {ChainType::MAIN, ChainType::TESTNET, ChainType::TESTNET4, ChainType::SIGNET, ChainType::REGTEST}) { |
| 449 | const auto chainParams = CreateChainParams(*m_node.args, chain_type); |
| 450 | uint32_t chain_all_vbits{0}; |
| 451 | for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) { |
| 452 | const auto dep = static_cast<Consensus::DeploymentPos>(i); |
| 453 | // Check that no bits are reused (within the same chain). This is |
| 454 | // disallowed because the transition to FAILED (on timeout) does |
| 455 | // not take precedence over STARTED/LOCKED_IN. So all softforks on |
| 456 | // the same bit might overlap, even when non-overlapping start-end |
| 457 | // times are picked. |
| 458 | const auto& dep_info = chainParams->GetConsensus().vDeployments[dep]; |
| 459 | const uint32_t dep_mask{uint32_t{1} << dep_info.bit}; |
| 460 | BOOST_CHECK(!(chain_all_vbits & dep_mask)); |
| 461 | chain_all_vbits |= dep_mask; |
| 462 | BOOST_CHECK(0 <= dep_info.bit && dep_info.bit < VERSIONBITS_MAX_NUM_BITS); |
| 463 | if (chain_type != ChainType::REGTEST) { |
| 464 | if (dep == Consensus::DEPLOYMENT_TESTDUMMY) { |
| 465 | BOOST_CHECK_EQUAL(dep_info.nStartTime, Consensus::BIP9Deployment::NEVER_ACTIVE); |
| 466 | BOOST_CHECK_EQUAL(dep_info.nTimeout, Consensus::BIP9Deployment::NO_TIMEOUT); |
| 467 | } else { |
| 468 | BOOST_CHECK(dep_info.bit < VERSIONBITS_NUM_BITS); |
| 469 | } |
| 470 | } |
| 471 | check_computeblockversion(vbcache, chainParams->GetConsensus(), dep); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | { |
| 476 | // Use regtest/testdummy to ensure we always exercise some |
| 477 | // deployment that's not always/never active |
| 478 | ArgsManager args; |
| 479 | args.ForceSetArg("-vbparams", "testdummy:1199145601:1230767999"); // January 1, 2008 - December 31, 2008 |
| 480 | const auto chainParams = CreateChainParams(args, ChainType::REGTEST); |
| 481 | check_computeblockversion(vbcache, chainParams->GetConsensus(), Consensus::DEPLOYMENT_TESTDUMMY); |
| 482 | } |
| 483 | |
| 484 | { |
| 485 | // Use regtest/testdummy to ensure we always exercise the |
| 486 | // min_activation_height test, even if we're not using that in a |
| 487 | // live deployment |
| 488 | ArgsManager args; |
| 489 | args.ForceSetArg("-vbparams", "testdummy:1199145601:1230767999:403200"); // January 1, 2008 - December 31, 2008, min act height 403200 |
| 490 | const auto chainParams = CreateChainParams(args, ChainType::REGTEST); |
| 491 | check_computeblockversion(vbcache, chainParams->GetConsensus(), Consensus::DEPLOYMENT_TESTDUMMY); |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | BOOST_AUTO_TEST_SUITE_END() |
nothing calls this directly
no test coverage detected