mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
refactor: Replace string chain name constants with ChainTypes
This commit effectively moves the definition of these constants out of the chainparamsbase to their own file. Using the ChainType enums provides better type safety compared to passing around strings. The commit is part of an ongoing effort to decouple the libbitcoinkernel library from the ArgsManager and other functionality that should not be part of the kernel library.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <consensus/params.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <versionbits.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
@@ -418,8 +419,8 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
|
||||
|
||||
// check that any deployment on any chain can conceivably reach both
|
||||
// ACTIVE and FAILED states in roughly the way we expect
|
||||
for (const auto& chain_name : {CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::SIGNET, CBaseChainParams::REGTEST}) {
|
||||
const auto chainParams = CreateChainParams(*m_node.args, chain_name);
|
||||
for (const auto& chain_type: {ChainType::MAIN, ChainType::TESTNET, ChainType::SIGNET, ChainType::REGTEST}) {
|
||||
const auto chainParams = CreateChainParams(*m_node.args, chain_type);
|
||||
uint32_t chain_all_vbits{0};
|
||||
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) {
|
||||
const auto dep = static_cast<Consensus::DeploymentPos>(i);
|
||||
@@ -440,7 +441,7 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
|
||||
// deployment that's not always/never active
|
||||
ArgsManager args;
|
||||
args.ForceSetArg("-vbparams", "testdummy:1199145601:1230767999"); // January 1, 2008 - December 31, 2008
|
||||
const auto chainParams = CreateChainParams(args, CBaseChainParams::REGTEST);
|
||||
const auto chainParams = CreateChainParams(args, ChainType::REGTEST);
|
||||
check_computeblockversion(vbcache, chainParams->GetConsensus(), Consensus::DEPLOYMENT_TESTDUMMY);
|
||||
}
|
||||
|
||||
@@ -450,7 +451,7 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
|
||||
// live deployment
|
||||
ArgsManager args;
|
||||
args.ForceSetArg("-vbparams", "testdummy:1199145601:1230767999:403200"); // January 1, 2008 - December 31, 2008, min act height 403200
|
||||
const auto chainParams = CreateChainParams(args, CBaseChainParams::REGTEST);
|
||||
const auto chainParams = CreateChainParams(args, ChainType::REGTEST);
|
||||
check_computeblockversion(vbcache, chainParams->GetConsensus(), Consensus::DEPLOYMENT_TESTDUMMY);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user