mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +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 <net.h>
|
||||
#include <signet.h>
|
||||
#include <uint256.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <test/util/setup_common.h>
|
||||
@@ -41,7 +42,7 @@ static void TestBlockSubsidyHalvings(int nSubsidyHalvingInterval)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(block_subsidy_test)
|
||||
{
|
||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
||||
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||
TestBlockSubsidyHalvings(chainParams->GetConsensus()); // As in main
|
||||
TestBlockSubsidyHalvings(150); // As in regtest
|
||||
TestBlockSubsidyHalvings(1000); // Just another interval
|
||||
@@ -49,7 +50,7 @@ BOOST_AUTO_TEST_CASE(block_subsidy_test)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(subsidy_limit_test)
|
||||
{
|
||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
||||
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||
CAmount nSum = 0;
|
||||
for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) {
|
||||
CAmount nSubsidy = GetBlockSubsidy(nHeight, chainParams->GetConsensus());
|
||||
@@ -64,7 +65,7 @@ BOOST_AUTO_TEST_CASE(signet_parse_tests)
|
||||
{
|
||||
ArgsManager signet_argsman;
|
||||
signet_argsman.ForceSetArg("-signetchallenge", "51"); // set challenge to OP_TRUE
|
||||
const auto signet_params = CreateChainParams(signet_argsman, CBaseChainParams::SIGNET);
|
||||
const auto signet_params = CreateChainParams(signet_argsman, ChainType::SIGNET);
|
||||
CBlock block;
|
||||
BOOST_CHECK(signet_params->GetConsensus().signet_challenge == std::vector<uint8_t>{OP_TRUE});
|
||||
CScript challenge{OP_TRUE};
|
||||
@@ -124,7 +125,7 @@ BOOST_AUTO_TEST_CASE(signet_parse_tests)
|
||||
//! Test retrieval of valid assumeutxo values.
|
||||
BOOST_AUTO_TEST_CASE(test_assumeutxo)
|
||||
{
|
||||
const auto params = CreateChainParams(*m_node.args, CBaseChainParams::REGTEST);
|
||||
const auto params = CreateChainParams(*m_node.args, ChainType::REGTEST);
|
||||
|
||||
// These heights don't have assumeutxo configurations associated, per the contents
|
||||
// of kernel/chainparams.cpp.
|
||||
|
||||
Reference in New Issue
Block a user