mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04: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:
parent
401453df41
commit
ba8fc7d788
78 changed files with 288 additions and 229 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include <common/args.h>
|
#include <common/args.h>
|
||||||
#include <consensus/validation.h>
|
#include <consensus/validation.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
// These are the two major time-sinks which happen after we have fully received
|
// These are the two major time-sinks which happen after we have fully received
|
||||||
|
@ -36,7 +37,7 @@ static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
|
||||||
stream.write({&a, 1}); // Prevent compaction
|
stream.write({&a, 1}); // Prevent compaction
|
||||||
|
|
||||||
ArgsManager bench_args;
|
ArgsManager bench_args;
|
||||||
const auto chainParams = CreateChainParams(bench_args, CBaseChainParams::MAIN);
|
const auto chainParams = CreateChainParams(bench_args, ChainType::MAIN);
|
||||||
|
|
||||||
bench.unit("block").run([&] {
|
bench.unit("block").run([&] {
|
||||||
CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
|
CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <bench/data.h>
|
#include <bench/data.h>
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
static void LoadExternalBlockFile(benchmark::Bench& bench)
|
static void LoadExternalBlockFile(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN)};
|
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
|
||||||
|
|
||||||
// Create a single block as in the blocks files (magic bytes, block size,
|
// Create a single block as in the blocks files (magic bytes, block size,
|
||||||
// block data) as a stream object.
|
// block data) as a stream object.
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <bench/bench.h>
|
#include <bench/bench.h>
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
// All but 2 of the benchmarks should have roughly similar performance:
|
// All but 2 of the benchmarks should have roughly similar performance:
|
||||||
//
|
//
|
||||||
|
@ -18,7 +19,7 @@ static void Logging(benchmark::Bench& bench, const std::vector<const char*>& ext
|
||||||
LogInstance().DisableCategory(BCLog::LogFlags::ALL);
|
LogInstance().DisableCategory(BCLog::LogFlags::ALL);
|
||||||
|
|
||||||
TestingSetup test_setup{
|
TestingSetup test_setup{
|
||||||
CBaseChainParams::REGTEST,
|
ChainType::REGTEST,
|
||||||
extra_args,
|
extra_args,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <policy/policy.h>
|
#include <policy/policy.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -88,7 +89,7 @@ static void ComplexMemPool(benchmark::Bench& bench)
|
||||||
childTxs = static_cast<int>(bench.complexityN());
|
childTxs = static_cast<int>(bench.complexityN());
|
||||||
}
|
}
|
||||||
std::vector<CTransactionRef> ordered_coins = CreateOrderedCoins(det_rand, childTxs, /*min_ancestors=*/1);
|
std::vector<CTransactionRef> ordered_coins = CreateOrderedCoins(det_rand, childTxs, /*min_ancestors=*/1);
|
||||||
const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN);
|
const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN);
|
||||||
CTxMemPool& pool = *testing_setup.get()->m_node.mempool;
|
CTxMemPool& pool = *testing_setup.get()->m_node.mempool;
|
||||||
LOCK2(cs_main, pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
bench.run([&]() NO_THREAD_SAFETY_ANALYSIS {
|
bench.run([&]() NO_THREAD_SAFETY_ANALYSIS {
|
||||||
|
@ -103,7 +104,7 @@ static void ComplexMemPool(benchmark::Bench& bench)
|
||||||
static void MempoolCheck(benchmark::Bench& bench)
|
static void MempoolCheck(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
FastRandomContext det_rand{true};
|
FastRandomContext det_rand{true};
|
||||||
auto testing_setup = MakeNoLogFileContext<TestChain100Setup>(CBaseChainParams::REGTEST, {"-checkmempool=1"});
|
auto testing_setup = MakeNoLogFileContext<TestChain100Setup>(ChainType::REGTEST, {"-checkmempool=1"});
|
||||||
CTxMemPool& pool = *testing_setup.get()->m_node.mempool;
|
CTxMemPool& pool = *testing_setup.get()->m_node.mempool;
|
||||||
LOCK2(cs_main, pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
testing_setup->PopulateMempool(det_rand, 400, true);
|
testing_setup->PopulateMempool(det_rand, 400, true);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <rpc/blockchain.h>
|
#include <rpc/blockchain.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
@ -15,7 +16,7 @@
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct TestBlockAndIndex {
|
struct TestBlockAndIndex {
|
||||||
const std::unique_ptr<const TestingSetup> testing_setup{MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN)};
|
const std::unique_ptr<const TestingSetup> testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
|
||||||
CBlock block{};
|
CBlock block{};
|
||||||
uint256 blockHash{};
|
uint256 blockHash{};
|
||||||
CBlockIndex blockindex{};
|
CBlockIndex blockindex{};
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <rpc/mempool.h>
|
#include <rpc/mempool.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& poo
|
||||||
|
|
||||||
static void RpcMempool(benchmark::Bench& bench)
|
static void RpcMempool(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
const auto testing_setup = MakeNoLogFileContext<const ChainTestingSetup>(CBaseChainParams::MAIN);
|
const auto testing_setup = MakeNoLogFileContext<const ChainTestingSetup>(ChainType::MAIN);
|
||||||
CTxMemPool& pool = *Assert(testing_setup->m_node.mempool);
|
CTxMemPool& pool = *Assert(testing_setup->m_node.mempool);
|
||||||
LOCK2(cs_main, pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <node/chainstate.h>
|
#include <node/chainstate.h>
|
||||||
#include <scheduler.h>
|
#include <scheduler.h>
|
||||||
#include <script/sigcache.h>
|
#include <script/sigcache.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/thread.h>
|
#include <util/thread.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
|
@ -52,7 +53,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
|
|
||||||
// SETUP: Misc Globals
|
// SETUP: Misc Globals
|
||||||
SelectParams(CBaseChainParams::MAIN);
|
SelectParams(ChainType::MAIN);
|
||||||
auto chainparams = CChainParams::Main();
|
auto chainparams = CChainParams::Main();
|
||||||
|
|
||||||
kernel::Context kernel_context{};
|
kernel::Context kernel_context{};
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <rpc/request.h>
|
#include <rpc/request.h>
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/exception.h>
|
#include <util/exception.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
@ -73,10 +74,10 @@ static void SetupCliArgs(ArgsManager& argsman)
|
||||||
{
|
{
|
||||||
SetupHelpOptions(argsman);
|
SetupHelpOptions(argsman);
|
||||||
|
|
||||||
const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
|
const auto defaultBaseParams = CreateBaseChainParams(ChainType::MAIN);
|
||||||
const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET);
|
const auto testnetBaseParams = CreateBaseChainParams(ChainType::TESTNET);
|
||||||
const auto signetBaseParams = CreateBaseChainParams(CBaseChainParams::SIGNET);
|
const auto signetBaseParams = CreateBaseChainParams(ChainType::SIGNET);
|
||||||
const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST);
|
const auto regtestBaseParams = CreateBaseChainParams(ChainType::REGTEST);
|
||||||
|
|
||||||
argsman.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
argsman.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
argsman.AddArg("-conf=<file>", strprintf("Specify configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
argsman.AddArg("-conf=<file>", strprintf("Specify configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
|
@ -174,7 +175,7 @@ static int AppInitRPC(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
// Check for chain settings (BaseParams() calls are only valid after this clause)
|
// Check for chain settings (BaseParams() calls are only valid after this clause)
|
||||||
try {
|
try {
|
||||||
SelectBaseParams(gArgs.GetChainName());
|
SelectBaseParams(gArgs.GetChainType());
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
tfm::format(std::cerr, "Error: %s\n", e.what());
|
tfm::format(std::cerr, "Error: %s\n", e.what());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -426,10 +427,16 @@ private:
|
||||||
std::vector<Peer> m_peers;
|
std::vector<Peer> m_peers;
|
||||||
std::string ChainToString() const
|
std::string ChainToString() const
|
||||||
{
|
{
|
||||||
if (gArgs.GetChainName() == CBaseChainParams::TESTNET) return " testnet";
|
switch (gArgs.GetChainType()) {
|
||||||
if (gArgs.GetChainName() == CBaseChainParams::SIGNET) return " signet";
|
case ChainType::TESTNET:
|
||||||
if (gArgs.GetChainName() == CBaseChainParams::REGTEST) return " regtest";
|
return " testnet";
|
||||||
return "";
|
case ChainType::SIGNET:
|
||||||
|
return " signet";
|
||||||
|
case ChainType::REGTEST:
|
||||||
|
return " regtest";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::string PingTimeToString(double seconds) const
|
std::string PingTimeToString(double seconds) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,7 +91,7 @@ static int AppInitRawTx(int argc, char* argv[])
|
||||||
|
|
||||||
// Check for chain settings (Params() calls are only valid after this clause)
|
// Check for chain settings (Params() calls are only valid after this clause)
|
||||||
try {
|
try {
|
||||||
SelectParams(gArgs.GetChainName());
|
SelectParams(gArgs.GetChainType());
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
tfm::format(std::cerr, "Error: %s\n", e.what());
|
tfm::format(std::cerr, "Error: %s\n", e.what());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
|
@ -75,7 +75,7 @@ static int AppInitUtil(ArgsManager& args, int argc, char* argv[])
|
||||||
|
|
||||||
// Check for chain settings (Params() calls are only valid after this clause)
|
// Check for chain settings (Params() calls are only valid after this clause)
|
||||||
try {
|
try {
|
||||||
SelectParams(args.GetChainName());
|
SelectParams(args.GetChainType());
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
tfm::format(std::cerr, "Error: %s\n", e.what());
|
tfm::format(std::cerr, "Error: %s\n", e.what());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
|
@ -91,7 +91,7 @@ static std::optional<int> WalletAppInit(ArgsManager& args, int argc, char* argv[
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
// Check for chain settings (Params() calls are only valid after this clause)
|
// Check for chain settings (Params() calls are only valid after this clause)
|
||||||
SelectParams(args.GetChainName());
|
SelectParams(args.GetChainType());
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <hash.h> // for signet block challenge hash
|
#include <hash.h> // for signet block challenge hash
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <script/interpreter.h>
|
#include <script/interpreter.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -97,26 +98,29 @@ const CChainParams &Params() {
|
||||||
return *globalChainParams;
|
return *globalChainParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain)
|
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const ChainType chain)
|
||||||
{
|
{
|
||||||
if (chain == CBaseChainParams::MAIN) {
|
switch (chain) {
|
||||||
|
case ChainType::MAIN:
|
||||||
return CChainParams::Main();
|
return CChainParams::Main();
|
||||||
} else if (chain == CBaseChainParams::TESTNET) {
|
case ChainType::TESTNET:
|
||||||
return CChainParams::TestNet();
|
return CChainParams::TestNet();
|
||||||
} else if (chain == CBaseChainParams::SIGNET) {
|
case ChainType::SIGNET: {
|
||||||
auto opts = CChainParams::SigNetOptions{};
|
auto opts = CChainParams::SigNetOptions{};
|
||||||
ReadSigNetArgs(args, opts);
|
ReadSigNetArgs(args, opts);
|
||||||
return CChainParams::SigNet(opts);
|
return CChainParams::SigNet(opts);
|
||||||
} else if (chain == CBaseChainParams::REGTEST) {
|
}
|
||||||
|
case ChainType::REGTEST: {
|
||||||
auto opts = CChainParams::RegTestOptions{};
|
auto opts = CChainParams::RegTestOptions{};
|
||||||
ReadRegTestArgs(args, opts);
|
ReadRegTestArgs(args, opts);
|
||||||
return CChainParams::RegTest(opts);
|
return CChainParams::RegTest(opts);
|
||||||
}
|
}
|
||||||
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
}
|
||||||
|
throw std::invalid_argument(strprintf("%s: Invalid ChainType value", __func__));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectParams(const std::string& network)
|
void SelectParams(const ChainType chain)
|
||||||
{
|
{
|
||||||
SelectBaseParams(network);
|
SelectBaseParams(chain);
|
||||||
globalChainParams = CreateChainParams(gArgs, network);
|
globalChainParams = CreateChainParams(gArgs, chain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <netaddress.h>
|
#include <netaddress.h>
|
||||||
#include <primitives/block.h>
|
#include <primitives/block.h>
|
||||||
#include <protocol.h>
|
#include <protocol.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/hash_type.h>
|
#include <util/hash_type.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -26,7 +27,7 @@
|
||||||
* @returns a CChainParams* of the chosen chain.
|
* @returns a CChainParams* of the chosen chain.
|
||||||
* @throws a std::runtime_error if the chain is not supported.
|
* @throws a std::runtime_error if the chain is not supported.
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain);
|
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const ChainType chain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the currently selected parameters. This won't change after app
|
* Return the currently selected parameters. This won't change after app
|
||||||
|
@ -38,6 +39,6 @@ const CChainParams &Params();
|
||||||
* Sets the params returned by Params() to those for the given chain name.
|
* Sets the params returned by Params() to those for the given chain name.
|
||||||
* @throws std::runtime_error when the chain is not supported.
|
* @throws std::runtime_error when the chain is not supported.
|
||||||
*/
|
*/
|
||||||
void SelectParams(const std::string& chain);
|
void SelectParams(const ChainType chain);
|
||||||
|
|
||||||
#endif // BITCOIN_CHAINPARAMS_H
|
#endif // BITCOIN_CHAINPARAMS_H
|
||||||
|
|
|
@ -7,14 +7,10 @@
|
||||||
|
|
||||||
#include <common/args.h>
|
#include <common/args.h>
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
const std::string CBaseChainParams::MAIN = "main";
|
|
||||||
const std::string CBaseChainParams::TESTNET = "test";
|
|
||||||
const std::string CBaseChainParams::SIGNET = "signet";
|
|
||||||
const std::string CBaseChainParams::REGTEST = "regtest";
|
|
||||||
|
|
||||||
void SetupChainParamsBaseOptions(ArgsManager& argsman)
|
void SetupChainParamsBaseOptions(ArgsManager& argsman)
|
||||||
{
|
{
|
||||||
argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||||
|
@ -40,22 +36,23 @@ const CBaseChainParams& BaseParams()
|
||||||
* Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have
|
* Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have
|
||||||
* been chosen arbitrarily to keep ranges of used ports tight.
|
* been chosen arbitrarily to keep ranges of used ports tight.
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
|
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain)
|
||||||
{
|
{
|
||||||
if (chain == CBaseChainParams::MAIN) {
|
switch (chain) {
|
||||||
|
case ChainType::MAIN:
|
||||||
return std::make_unique<CBaseChainParams>("", 8332, 8334);
|
return std::make_unique<CBaseChainParams>("", 8332, 8334);
|
||||||
} else if (chain == CBaseChainParams::TESTNET) {
|
case ChainType::TESTNET:
|
||||||
return std::make_unique<CBaseChainParams>("testnet3", 18332, 18334);
|
return std::make_unique<CBaseChainParams>("testnet3", 18332, 18334);
|
||||||
} else if (chain == CBaseChainParams::SIGNET) {
|
case ChainType::SIGNET:
|
||||||
return std::make_unique<CBaseChainParams>("signet", 38332, 38334);
|
return std::make_unique<CBaseChainParams>("signet", 38332, 38334);
|
||||||
} else if (chain == CBaseChainParams::REGTEST) {
|
case ChainType::REGTEST:
|
||||||
return std::make_unique<CBaseChainParams>("regtest", 18443, 18445);
|
return std::make_unique<CBaseChainParams>("regtest", 18443, 18445);
|
||||||
}
|
}
|
||||||
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
throw std::invalid_argument(strprintf("%s: Invalid ChainType value", __func__));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectBaseParams(const std::string& chain)
|
void SelectBaseParams(const ChainType chain)
|
||||||
{
|
{
|
||||||
globalChainBaseParams = CreateBaseChainParams(chain);
|
globalChainBaseParams = CreateBaseChainParams(chain);
|
||||||
gArgs.SelectConfigNetwork(chain);
|
gArgs.SelectConfigNetwork(ChainTypeToString(chain));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#ifndef BITCOIN_CHAINPARAMSBASE_H
|
#ifndef BITCOIN_CHAINPARAMSBASE_H
|
||||||
#define BITCOIN_CHAINPARAMSBASE_H
|
#define BITCOIN_CHAINPARAMSBASE_H
|
||||||
|
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -17,14 +19,6 @@ class ArgsManager;
|
||||||
class CBaseChainParams
|
class CBaseChainParams
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///@{
|
|
||||||
/** Chain name strings */
|
|
||||||
static const std::string MAIN;
|
|
||||||
static const std::string TESTNET;
|
|
||||||
static const std::string SIGNET;
|
|
||||||
static const std::string REGTEST;
|
|
||||||
///@}
|
|
||||||
|
|
||||||
const std::string& DataDir() const { return strDataDir; }
|
const std::string& DataDir() const { return strDataDir; }
|
||||||
uint16_t RPCPort() const { return m_rpc_port; }
|
uint16_t RPCPort() const { return m_rpc_port; }
|
||||||
uint16_t OnionServiceTargetPort() const { return m_onion_service_target_port; }
|
uint16_t OnionServiceTargetPort() const { return m_onion_service_target_port; }
|
||||||
|
@ -44,7 +38,7 @@ private:
|
||||||
* @returns a CBaseChainParams* of the chosen chain.
|
* @returns a CBaseChainParams* of the chosen chain.
|
||||||
* @throws a std::runtime_error if the chain is not supported.
|
* @throws a std::runtime_error if the chain is not supported.
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain);
|
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*Set the arguments for chainparams
|
*Set the arguments for chainparams
|
||||||
|
@ -57,7 +51,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman);
|
||||||
*/
|
*/
|
||||||
const CBaseChainParams& BaseParams();
|
const CBaseChainParams& BaseParams();
|
||||||
|
|
||||||
/** Sets the params returned by Params() to those for the given network. */
|
/** Sets the params returned by Params() to those for the given chain. */
|
||||||
void SelectBaseParams(const std::string& chain);
|
void SelectBaseParams(const ChainType chain);
|
||||||
|
|
||||||
#endif // BITCOIN_CHAINPARAMSBASE_H
|
#endif // BITCOIN_CHAINPARAMSBASE_H
|
||||||
|
|
|
@ -143,7 +143,7 @@ std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const
|
||||||
if (m_network.empty()) return std::set<std::string> {};
|
if (m_network.empty()) return std::set<std::string> {};
|
||||||
|
|
||||||
// if it's okay to use the default section for this network, don't worry
|
// if it's okay to use the default section for this network, don't worry
|
||||||
if (m_network == CBaseChainParams::MAIN) return std::set<std::string> {};
|
if (m_network == ChainTypeToString(ChainType::MAIN)) return std::set<std::string> {};
|
||||||
|
|
||||||
for (const auto& arg : m_network_only_args) {
|
for (const auto& arg : m_network_only_args) {
|
||||||
if (OnlyHasDefaultSectionSetting(m_settings, m_network, SettingName(arg))) {
|
if (OnlyHasDefaultSectionSetting(m_settings, m_network, SettingName(arg))) {
|
||||||
|
@ -157,10 +157,10 @@ std::list<SectionInfo> ArgsManager::GetUnrecognizedSections() const
|
||||||
{
|
{
|
||||||
// Section names to be recognized in the config file.
|
// Section names to be recognized in the config file.
|
||||||
static const std::set<std::string> available_sections{
|
static const std::set<std::string> available_sections{
|
||||||
CBaseChainParams::REGTEST,
|
ChainTypeToString(ChainType::REGTEST),
|
||||||
CBaseChainParams::SIGNET,
|
ChainTypeToString(ChainType::SIGNET),
|
||||||
CBaseChainParams::TESTNET,
|
ChainTypeToString(ChainType::TESTNET),
|
||||||
CBaseChainParams::MAIN
|
ChainTypeToString(ChainType::MAIN),
|
||||||
};
|
};
|
||||||
|
|
||||||
LOCK(cs_args);
|
LOCK(cs_args);
|
||||||
|
@ -445,7 +445,7 @@ util::SettingsValue ArgsManager::GetPersistentSetting(const std::string& name) c
|
||||||
{
|
{
|
||||||
LOCK(cs_args);
|
LOCK(cs_args);
|
||||||
return util::GetSetting(m_settings, m_network, name, !UseDefaultSection("-" + name),
|
return util::GetSetting(m_settings, m_network, name, !UseDefaultSection("-" + name),
|
||||||
/*ignore_nonpersistent=*/true, /*get_chain_name=*/false);
|
/*ignore_nonpersistent=*/true, /*get_chain_type=*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArgsManager::IsArgNegated(const std::string& strArg) const
|
bool ArgsManager::IsArgNegated(const std::string& strArg) const
|
||||||
|
@ -726,7 +726,7 @@ ChainType ArgsManager::GetChainType() const
|
||||||
throw std::runtime_error(strprintf("Unknown chain %s.", std::get<std::string>(arg)));
|
throw std::runtime_error(strprintf("Unknown chain %s.", std::get<std::string>(arg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ArgsManager::GetChainName() const
|
std::string ArgsManager::GetChainTypeString() const
|
||||||
{
|
{
|
||||||
auto arg = GetChainArg();
|
auto arg = GetChainArg();
|
||||||
if (auto* parsed = std::get_if<ChainType>(&arg)) return ChainTypeToString(*parsed);
|
if (auto* parsed = std::get_if<ChainType>(&arg)) return ChainTypeToString(*parsed);
|
||||||
|
@ -740,7 +740,7 @@ std::variant<ChainType, std::string> ArgsManager::GetChainArg() const
|
||||||
util::SettingsValue value = util::GetSetting(m_settings, /* section= */ "", SettingName(arg),
|
util::SettingsValue value = util::GetSetting(m_settings, /* section= */ "", SettingName(arg),
|
||||||
/* ignore_default_section_config= */ false,
|
/* ignore_default_section_config= */ false,
|
||||||
/*ignore_nonpersistent=*/false,
|
/*ignore_nonpersistent=*/false,
|
||||||
/* get_chain_name= */ true);
|
/* get_chain_type= */ true);
|
||||||
return value.isNull() ? false : value.isBool() ? value.get_bool() : InterpretBool(value.get_str());
|
return value.isNull() ? false : value.isBool() ? value.get_bool() : InterpretBool(value.get_str());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -765,7 +765,7 @@ std::variant<ChainType, std::string> ArgsManager::GetChainArg() const
|
||||||
|
|
||||||
bool ArgsManager::UseDefaultSection(const std::string& arg) const
|
bool ArgsManager::UseDefaultSection(const std::string& arg) const
|
||||||
{
|
{
|
||||||
return m_network == CBaseChainParams::MAIN || m_network_only_args.count(arg) == 0;
|
return m_network == ChainTypeToString(ChainType::MAIN) || m_network_only_args.count(arg) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
util::SettingsValue ArgsManager::GetSetting(const std::string& arg) const
|
util::SettingsValue ArgsManager::GetSetting(const std::string& arg) const
|
||||||
|
@ -773,7 +773,7 @@ util::SettingsValue ArgsManager::GetSetting(const std::string& arg) const
|
||||||
LOCK(cs_args);
|
LOCK(cs_args);
|
||||||
return util::GetSetting(
|
return util::GetSetting(
|
||||||
m_settings, m_network, SettingName(arg), !UseDefaultSection(arg),
|
m_settings, m_network, SettingName(arg), !UseDefaultSection(arg),
|
||||||
/*ignore_nonpersistent=*/false, /*get_chain_name=*/false);
|
/*ignore_nonpersistent=*/false, /*get_chain_type=*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<util::SettingsValue> ArgsManager::GetSettingsList(const std::string& arg) const
|
std::vector<util::SettingsValue> ArgsManager::GetSettingsList(const std::string& arg) const
|
||||||
|
|
|
@ -336,7 +336,7 @@ protected:
|
||||||
* @return ChainType::MAIN string by default; raises runtime error if an
|
* @return ChainType::MAIN string by default; raises runtime error if an
|
||||||
* invalid combination is given.
|
* invalid combination is given.
|
||||||
*/
|
*/
|
||||||
std::string GetChainName() const;
|
std::string GetChainTypeString() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add argument
|
* Add argument
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
#include <util/settings.h>
|
#include <util/settings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
|
@ -152,7 +153,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (use_conf_file) {
|
if (use_conf_file) {
|
||||||
std::string chain_id = GetChainName();
|
std::string chain_id = GetChainTypeString();
|
||||||
std::vector<std::string> conf_file_names;
|
std::vector<std::string> conf_file_names;
|
||||||
|
|
||||||
auto add_includes = [&](const std::string& network, size_t skip = 0) {
|
auto add_includes = [&](const std::string& network, size_t skip = 0) {
|
||||||
|
@ -191,7 +192,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||||
conf_file_names.clear();
|
conf_file_names.clear();
|
||||||
add_includes(chain_id, /* skip= */ chain_includes);
|
add_includes(chain_id, /* skip= */ chain_includes);
|
||||||
add_includes({}, /* skip= */ default_includes);
|
add_includes({}, /* skip= */ default_includes);
|
||||||
std::string chain_id_final = GetChainName();
|
std::string chain_id_final = GetChainTypeString();
|
||||||
if (chain_id_final != chain_id) {
|
if (chain_id_final != chain_id) {
|
||||||
// Also warn about recursive includeconf for the chain that was specified in one of the includeconfs
|
// Also warn about recursive includeconf for the chain that was specified in one of the includeconfs
|
||||||
add_includes(chain_id_final);
|
add_includes(chain_id_final);
|
||||||
|
|
|
@ -26,7 +26,7 @@ std::optional<ConfigError> InitConfig(ArgsManager& args, SettingsAbortFn setting
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for chain settings (Params() calls are only valid after this clause)
|
// Check for chain settings (Params() calls are only valid after this clause)
|
||||||
SelectParams(args.GetChainName());
|
SelectParams(args.GetChainType());
|
||||||
|
|
||||||
// Create datadir if it does not exist.
|
// Create datadir if it does not exist.
|
||||||
const auto base_path{args.GetDataDirBase()};
|
const auto base_path{args.GetDataDirBase()};
|
||||||
|
|
25
src/init.cpp
25
src/init.cpp
|
@ -69,6 +69,7 @@
|
||||||
#include <txdb.h>
|
#include <txdb.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
#include <util/asmap.h>
|
#include <util/asmap.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
#include <util/fs_helpers.h>
|
#include <util/fs_helpers.h>
|
||||||
|
@ -408,14 +409,14 @@ void SetupServerArgs(ArgsManager& argsman)
|
||||||
|
|
||||||
init::AddLoggingArgs(argsman);
|
init::AddLoggingArgs(argsman);
|
||||||
|
|
||||||
const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
|
const auto defaultBaseParams = CreateBaseChainParams(ChainType::MAIN);
|
||||||
const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET);
|
const auto testnetBaseParams = CreateBaseChainParams(ChainType::TESTNET);
|
||||||
const auto signetBaseParams = CreateBaseChainParams(CBaseChainParams::SIGNET);
|
const auto signetBaseParams = CreateBaseChainParams(ChainType::SIGNET);
|
||||||
const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST);
|
const auto regtestBaseParams = CreateBaseChainParams(ChainType::REGTEST);
|
||||||
const auto defaultChainParams = CreateChainParams(argsman, CBaseChainParams::MAIN);
|
const auto defaultChainParams = CreateChainParams(argsman, ChainType::MAIN);
|
||||||
const auto testnetChainParams = CreateChainParams(argsman, CBaseChainParams::TESTNET);
|
const auto testnetChainParams = CreateChainParams(argsman, ChainType::TESTNET);
|
||||||
const auto signetChainParams = CreateChainParams(argsman, CBaseChainParams::SIGNET);
|
const auto signetChainParams = CreateChainParams(argsman, ChainType::SIGNET);
|
||||||
const auto regtestChainParams = CreateChainParams(argsman, CBaseChainParams::REGTEST);
|
const auto regtestChainParams = CreateChainParams(argsman, ChainType::REGTEST);
|
||||||
|
|
||||||
// Hidden Options
|
// Hidden Options
|
||||||
std::vector<std::string> hidden_args = {
|
std::vector<std::string> hidden_args = {
|
||||||
|
@ -844,14 +845,14 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
|
||||||
|
|
||||||
// Error if network-specific options (-addnode, -connect, etc) are
|
// Error if network-specific options (-addnode, -connect, etc) are
|
||||||
// specified in default section of config file, but not overridden
|
// specified in default section of config file, but not overridden
|
||||||
// on the command line or in this network's section of the config file.
|
// on the command line or in this chain's section of the config file.
|
||||||
std::string network = args.GetChainName();
|
ChainType chain = args.GetChainType();
|
||||||
if (network == CBaseChainParams::SIGNET) {
|
if (chain == ChainType::SIGNET) {
|
||||||
LogPrintf("Signet derived magic (message start): %s\n", HexStr(chainparams.MessageStart()));
|
LogPrintf("Signet derived magic (message start): %s\n", HexStr(chainparams.MessageStart()));
|
||||||
}
|
}
|
||||||
bilingual_str errors;
|
bilingual_str errors;
|
||||||
for (const auto& arg : args.GetUnsuitableSectionOnlyArgs()) {
|
for (const auto& arg : args.GetUnsuitableSectionOnlyArgs()) {
|
||||||
errors += strprintf(_("Config setting for %s only applied on %s network when in [%s] section.") + Untranslated("\n"), arg, network, network);
|
errors += strprintf(_("Config setting for %s only applied on %s network when in [%s] section.") + Untranslated("\n"), arg, ChainTypeToString(chain), ChainTypeToString(chain));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!errors.empty()) {
|
if (!errors.empty()) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <script/interpreter.h>
|
#include <script/interpreter.h>
|
||||||
#include <script/script.h>
|
#include <script/script.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -70,7 +71,7 @@ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits
|
||||||
class CMainParams : public CChainParams {
|
class CMainParams : public CChainParams {
|
||||||
public:
|
public:
|
||||||
CMainParams() {
|
CMainParams() {
|
||||||
strNetworkID = CBaseChainParams::MAIN;
|
m_chain_type = ChainType::MAIN;
|
||||||
consensus.signet_blocks = false;
|
consensus.signet_blocks = false;
|
||||||
consensus.signet_challenge.clear();
|
consensus.signet_challenge.clear();
|
||||||
consensus.nSubsidyHalvingInterval = 210000;
|
consensus.nSubsidyHalvingInterval = 210000;
|
||||||
|
@ -192,7 +193,7 @@ public:
|
||||||
class CTestNetParams : public CChainParams {
|
class CTestNetParams : public CChainParams {
|
||||||
public:
|
public:
|
||||||
CTestNetParams() {
|
CTestNetParams() {
|
||||||
strNetworkID = CBaseChainParams::TESTNET;
|
m_chain_type = ChainType::TESTNET;
|
||||||
consensus.signet_blocks = false;
|
consensus.signet_blocks = false;
|
||||||
consensus.signet_challenge.clear();
|
consensus.signet_challenge.clear();
|
||||||
consensus.nSubsidyHalvingInterval = 210000;
|
consensus.nSubsidyHalvingInterval = 210000;
|
||||||
|
@ -328,7 +329,7 @@ public:
|
||||||
vSeeds = *options.seeds;
|
vSeeds = *options.seeds;
|
||||||
}
|
}
|
||||||
|
|
||||||
strNetworkID = CBaseChainParams::SIGNET;
|
m_chain_type = ChainType::SIGNET;
|
||||||
consensus.signet_blocks = true;
|
consensus.signet_blocks = true;
|
||||||
consensus.signet_challenge.assign(bin.begin(), bin.end());
|
consensus.signet_challenge.assign(bin.begin(), bin.end());
|
||||||
consensus.nSubsidyHalvingInterval = 210000;
|
consensus.nSubsidyHalvingInterval = 210000;
|
||||||
|
@ -397,7 +398,7 @@ class CRegTestParams : public CChainParams
|
||||||
public:
|
public:
|
||||||
explicit CRegTestParams(const RegTestOptions& opts)
|
explicit CRegTestParams(const RegTestOptions& opts)
|
||||||
{
|
{
|
||||||
strNetworkID = CBaseChainParams::REGTEST;
|
m_chain_type = ChainType::REGTEST;
|
||||||
consensus.signet_blocks = false;
|
consensus.signet_blocks = false;
|
||||||
consensus.signet_challenge.clear();
|
consensus.signet_challenge.clear();
|
||||||
consensus.nSubsidyHalvingInterval = 150;
|
consensus.nSubsidyHalvingInterval = 150;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <primitives/block.h>
|
#include <primitives/block.h>
|
||||||
#include <protocol.h>
|
#include <protocol.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/hash_type.h>
|
#include <util/hash_type.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -114,8 +115,10 @@ public:
|
||||||
uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
|
uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
|
||||||
/** Whether it is possible to mine blocks on demand (no retargeting) */
|
/** Whether it is possible to mine blocks on demand (no retargeting) */
|
||||||
bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
|
bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
|
||||||
/** Return the network string */
|
/** Return the chain type string */
|
||||||
std::string NetworkIDString() const { return strNetworkID; }
|
std::string GetChainTypeString() const { return ChainTypeToString(m_chain_type); }
|
||||||
|
/** Return the chain type */
|
||||||
|
ChainType GetChainType() const { return m_chain_type; }
|
||||||
/** Return the list of hostnames to look up for DNS seeds */
|
/** Return the list of hostnames to look up for DNS seeds */
|
||||||
const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
|
const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
|
||||||
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
|
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
|
||||||
|
@ -172,7 +175,7 @@ protected:
|
||||||
std::vector<std::string> vSeeds;
|
std::vector<std::string> vSeeds;
|
||||||
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
||||||
std::string bech32_hrp;
|
std::string bech32_hrp;
|
||||||
std::string strNetworkID;
|
ChainType m_chain_type;
|
||||||
CBlock genesis;
|
CBlock genesis;
|
||||||
std::vector<uint8_t> vFixedSeeds;
|
std::vector<uint8_t> vFixedSeeds;
|
||||||
bool fDefaultConsistencyChecks;
|
bool fDefaultConsistencyChecks;
|
||||||
|
|
|
@ -239,7 +239,7 @@ public:
|
||||||
std::vector<ExternalSigner> signers = {};
|
std::vector<ExternalSigner> signers = {};
|
||||||
const std::string command = args().GetArg("-signer", "");
|
const std::string command = args().GetArg("-signer", "");
|
||||||
if (command == "") return {};
|
if (command == "") return {};
|
||||||
ExternalSigner::Enumerate(command, signers, Params().NetworkIDString());
|
ExternalSigner::Enumerate(command, signers, Params().GetChainTypeString());
|
||||||
std::vector<std::unique_ptr<interfaces::ExternalSigner>> result;
|
std::vector<std::unique_ptr<interfaces::ExternalSigner>> result;
|
||||||
result.reserve(signers.size());
|
result.reserve(signers.size());
|
||||||
for (auto& signer : signers) {
|
for (auto& signer : signers) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& argsman, con
|
||||||
|
|
||||||
mempool_opts.require_standard = !argsman.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
|
mempool_opts.require_standard = !argsman.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
|
||||||
if (!chainparams.IsTestChain() && !mempool_opts.require_standard) {
|
if (!chainparams.IsTestChain() && !mempool_opts.require_standard) {
|
||||||
return strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.NetworkIDString());
|
return strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.GetChainTypeString());
|
||||||
}
|
}
|
||||||
|
|
||||||
mempool_opts.full_rbf = argsman.GetBoolArg("-mempoolfullrbf", mempool_opts.full_rbf);
|
mempool_opts.full_rbf = argsman.GetBoolArg("-mempoolfullrbf", mempool_opts.full_rbf);
|
||||||
|
|
|
@ -601,7 +601,7 @@ int GuiMain(int argc, char* argv[])
|
||||||
PaymentServer::ipcParseCommandLine(argc, argv);
|
PaymentServer::ipcParseCommandLine(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(Params().NetworkIDString()));
|
QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(Params().GetChainType()));
|
||||||
assert(!networkStyle.isNull());
|
assert(!networkStyle.isNull());
|
||||||
// Allow for separate UI settings for testnets
|
// Allow for separate UI settings for testnets
|
||||||
QApplication::setApplicationName(networkStyle->getAppName());
|
QApplication::setApplicationName(networkStyle->getAppName());
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <protocol.h>
|
#include <protocol.h>
|
||||||
#include <script/script.h>
|
#include <script/script.h>
|
||||||
#include <script/standard.h>
|
#include <script/standard.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/exception.h>
|
#include <util/exception.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
#include <util/fs_helpers.h>
|
#include <util/fs_helpers.h>
|
||||||
|
@ -503,12 +504,12 @@ bool LabelOutOfFocusEventFilter::eventFilter(QObject* watched, QEvent* event)
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
fs::path static StartupShortcutPath()
|
fs::path static StartupShortcutPath()
|
||||||
{
|
{
|
||||||
std::string chain = gArgs.GetChainName();
|
ChainType chain = gArgs.GetChainType();
|
||||||
if (chain == CBaseChainParams::MAIN)
|
if (chain == ChainType::MAIN)
|
||||||
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk";
|
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk";
|
||||||
if (chain == CBaseChainParams::TESTNET) // Remove this special case when CBaseChainParams::TESTNET = "testnet4"
|
if (chain == ChainType::TESTNET) // Remove this special case when testnet CBaseChainParams::DataDir() is incremented to "testnet4"
|
||||||
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin (testnet).lnk";
|
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin (testnet).lnk";
|
||||||
return GetSpecialFolderPath(CSIDL_STARTUP) / fs::u8path(strprintf("Bitcoin (%s).lnk", chain));
|
return GetSpecialFolderPath(CSIDL_STARTUP) / fs::u8path(strprintf("Bitcoin (%s).lnk", ChainTypeToString(chain)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetStartOnSystemStartup()
|
bool GetStartOnSystemStartup()
|
||||||
|
@ -541,7 +542,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||||
// Start client minimized
|
// Start client minimized
|
||||||
QString strArgs = "-min";
|
QString strArgs = "-min";
|
||||||
// Set -testnet /-regtest options
|
// Set -testnet /-regtest options
|
||||||
strArgs += QString::fromStdString(strprintf(" -chain=%s", gArgs.GetChainName()));
|
strArgs += QString::fromStdString(strprintf(" -chain=%s", gArgs.GetChainTypeString()));
|
||||||
|
|
||||||
// Set the path to the shortcut target
|
// Set the path to the shortcut target
|
||||||
psl->SetPath(pszExePath);
|
psl->SetPath(pszExePath);
|
||||||
|
@ -586,10 +587,10 @@ fs::path static GetAutostartDir()
|
||||||
|
|
||||||
fs::path static GetAutostartFilePath()
|
fs::path static GetAutostartFilePath()
|
||||||
{
|
{
|
||||||
std::string chain = gArgs.GetChainName();
|
ChainType chain = gArgs.GetChainType();
|
||||||
if (chain == CBaseChainParams::MAIN)
|
if (chain == ChainType::MAIN)
|
||||||
return GetAutostartDir() / "bitcoin.desktop";
|
return GetAutostartDir() / "bitcoin.desktop";
|
||||||
return GetAutostartDir() / fs::u8path(strprintf("bitcoin-%s.desktop", chain));
|
return GetAutostartDir() / fs::u8path(strprintf("bitcoin-%s.desktop", ChainTypeToString(chain)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetStartOnSystemStartup()
|
bool GetStartOnSystemStartup()
|
||||||
|
@ -629,15 +630,15 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||||
std::ofstream optionFile{GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc};
|
std::ofstream optionFile{GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc};
|
||||||
if (!optionFile.good())
|
if (!optionFile.good())
|
||||||
return false;
|
return false;
|
||||||
std::string chain = gArgs.GetChainName();
|
ChainType chain = gArgs.GetChainType();
|
||||||
// Write a bitcoin.desktop file to the autostart directory:
|
// Write a bitcoin.desktop file to the autostart directory:
|
||||||
optionFile << "[Desktop Entry]\n";
|
optionFile << "[Desktop Entry]\n";
|
||||||
optionFile << "Type=Application\n";
|
optionFile << "Type=Application\n";
|
||||||
if (chain == CBaseChainParams::MAIN)
|
if (chain == ChainType::MAIN)
|
||||||
optionFile << "Name=Bitcoin\n";
|
optionFile << "Name=Bitcoin\n";
|
||||||
else
|
else
|
||||||
optionFile << strprintf("Name=Bitcoin (%s)\n", chain);
|
optionFile << strprintf("Name=Bitcoin (%s)\n", ChainTypeToString(chain));
|
||||||
optionFile << "Exec=" << pszExePath << strprintf(" -min -chain=%s\n", chain);
|
optionFile << "Exec=" << pszExePath << strprintf(" -min -chain=%s\n", ChainTypeToString(chain));
|
||||||
optionFile << "Terminal=false\n";
|
optionFile << "Terminal=false\n";
|
||||||
optionFile << "Hidden=false\n";
|
optionFile << "Hidden=false\n";
|
||||||
optionFile.close();
|
optionFile.close();
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <qt/intro.h>
|
#include <qt/intro.h>
|
||||||
#include <qt/forms/ui_intro.h>
|
#include <qt/forms/ui_intro.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
|
|
||||||
#include <qt/guiconstants.h>
|
#include <qt/guiconstants.h>
|
||||||
|
@ -219,7 +220,7 @@ bool Intro::showIfNeeded(bool& did_show_intro, int64_t& prune_MiB)
|
||||||
{
|
{
|
||||||
/* Use selectParams here to guarantee Params() can be used by node interface */
|
/* Use selectParams here to guarantee Params() can be used by node interface */
|
||||||
try {
|
try {
|
||||||
SelectParams(gArgs.GetChainName());
|
SelectParams(gArgs.GetChainType());
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,20 @@
|
||||||
|
|
||||||
#include <chainparamsbase.h>
|
#include <chainparamsbase.h>
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *networkId;
|
const ChainType networkId;
|
||||||
const char *appName;
|
const char *appName;
|
||||||
const int iconColorHueShift;
|
const int iconColorHueShift;
|
||||||
const int iconColorSaturationReduction;
|
const int iconColorSaturationReduction;
|
||||||
} network_styles[] = {
|
} network_styles[] = {
|
||||||
{"main", QAPP_APP_NAME_DEFAULT, 0, 0},
|
{ChainType::MAIN, QAPP_APP_NAME_DEFAULT, 0, 0},
|
||||||
{"test", QAPP_APP_NAME_TESTNET, 70, 30},
|
{ChainType::TESTNET, QAPP_APP_NAME_TESTNET, 70, 30},
|
||||||
{"signet", QAPP_APP_NAME_SIGNET, 35, 15},
|
{ChainType::SIGNET, QAPP_APP_NAME_SIGNET, 35, 15},
|
||||||
{"regtest", QAPP_APP_NAME_REGTEST, 160, 30},
|
{ChainType::REGTEST, QAPP_APP_NAME_REGTEST, 160, 30},
|
||||||
};
|
};
|
||||||
|
|
||||||
// titleAddText needs to be const char* for tr()
|
// titleAddText needs to be const char* for tr()
|
||||||
|
@ -77,9 +78,9 @@ NetworkStyle::NetworkStyle(const QString &_appName, const int iconColorHueShift,
|
||||||
trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256,256)));
|
trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256,256)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const NetworkStyle* NetworkStyle::instantiate(const std::string& networkId)
|
const NetworkStyle* NetworkStyle::instantiate(const ChainType networkId)
|
||||||
{
|
{
|
||||||
std::string titleAddText = networkId == CBaseChainParams::MAIN ? "" : strprintf("[%s]", networkId);
|
std::string titleAddText = networkId == ChainType::MAIN ? "" : strprintf("[%s]", ChainTypeToString(networkId));
|
||||||
for (const auto& network_style : network_styles) {
|
for (const auto& network_style : network_styles) {
|
||||||
if (networkId == network_style.networkId) {
|
if (networkId == network_style.networkId) {
|
||||||
return new NetworkStyle(
|
return new NetworkStyle(
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#ifndef BITCOIN_QT_NETWORKSTYLE_H
|
#ifndef BITCOIN_QT_NETWORKSTYLE_H
|
||||||
#define BITCOIN_QT_NETWORKSTYLE_H
|
#define BITCOIN_QT_NETWORKSTYLE_H
|
||||||
|
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -14,7 +16,7 @@ class NetworkStyle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Get style associated with provided network id, or 0 if not known */
|
/** Get style associated with provided network id, or 0 if not known */
|
||||||
static const NetworkStyle* instantiate(const std::string& networkId);
|
static const NetworkStyle* instantiate(const ChainType networkId);
|
||||||
|
|
||||||
const QString &getAppName() const { return appName; }
|
const QString &getAppName() const { return appName; }
|
||||||
const QIcon &getAppIcon() const { return appIcon; }
|
const QIcon &getAppIcon() const { return appIcon; }
|
||||||
|
|
|
@ -744,7 +744,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
|
||||||
ui->dataDir->setText(model->dataDir());
|
ui->dataDir->setText(model->dataDir());
|
||||||
ui->blocksDir->setText(model->blocksDir());
|
ui->blocksDir->setText(model->blocksDir());
|
||||||
ui->startupTime->setText(model->formatClientStartupTime());
|
ui->startupTime->setText(model->formatClientStartupTime());
|
||||||
ui->networkName->setText(QString::fromStdString(Params().NetworkIDString()));
|
ui->networkName->setText(QString::fromStdString(Params().GetChainTypeString()));
|
||||||
|
|
||||||
//Setup autocomplete and attach it
|
//Setup autocomplete and attach it
|
||||||
QStringList wordList;
|
QStringList wordList;
|
||||||
|
|
|
@ -73,7 +73,7 @@ void AppTests::appTests()
|
||||||
qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");
|
qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");
|
||||||
m_app.parameterSetup();
|
m_app.parameterSetup();
|
||||||
QVERIFY(m_app.createOptionsModel(/*resetSettings=*/true));
|
QVERIFY(m_app.createOptionsModel(/*resetSettings=*/true));
|
||||||
QScopedPointer<const NetworkStyle> style(NetworkStyle::instantiate(Params().NetworkIDString()));
|
QScopedPointer<const NetworkStyle> style(NetworkStyle::instantiate(Params().GetChainType()));
|
||||||
m_app.setupPlatformStyle();
|
m_app.setupPlatformStyle();
|
||||||
m_app.createWindow(style.data());
|
m_app.createWindow(style.data());
|
||||||
connect(&m_app, &BitcoinApplication::windowShown, this, &AppTests::guiTests);
|
connect(&m_app, &BitcoinApplication::windowShown, this, &AppTests::guiTests);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <qt/test/rpcnestedtests.h>
|
#include <qt/test/rpcnestedtests.h>
|
||||||
#include <qt/test/uritests.h>
|
#include <qt/test/uritests.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
#include <qt/test/addressbooktests.h>
|
#include <qt/test/addressbooktests.h>
|
||||||
|
@ -57,7 +58,7 @@ int main(int argc, char* argv[])
|
||||||
//
|
//
|
||||||
// All tests must use their own testing setup (if needed).
|
// All tests must use their own testing setup (if needed).
|
||||||
fs::create_directories([] {
|
fs::create_directories([] {
|
||||||
BasicTestingSetup dummy{CBaseChainParams::REGTEST};
|
BasicTestingSetup dummy{ChainType::REGTEST};
|
||||||
return gArgs.GetDataDirNet() / "blocks";
|
return gArgs.GetDataDirNet() / "blocks";
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|
|
@ -1256,7 +1256,7 @@ RPCHelpMan getblockchaininfo()
|
||||||
const CBlockIndex& tip{*CHECK_NONFATAL(active_chainstate.m_chain.Tip())};
|
const CBlockIndex& tip{*CHECK_NONFATAL(active_chainstate.m_chain.Tip())};
|
||||||
const int height{tip.nHeight};
|
const int height{tip.nHeight};
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("chain", chainman.GetParams().NetworkIDString());
|
obj.pushKV("chain", chainman.GetParams().GetChainTypeString());
|
||||||
obj.pushKV("blocks", height);
|
obj.pushKV("blocks", height);
|
||||||
obj.pushKV("headers", chainman.m_best_header ? chainman.m_best_header->nHeight : -1);
|
obj.pushKV("headers", chainman.m_best_header ? chainman.m_best_header->nHeight : -1);
|
||||||
obj.pushKV("bestblockhash", tip.GetBlockHash().GetHex());
|
obj.pushKV("bestblockhash", tip.GetBlockHash().GetHex());
|
||||||
|
|
|
@ -43,7 +43,7 @@ static RPCHelpMan enumeratesigners()
|
||||||
{
|
{
|
||||||
const std::string command = gArgs.GetArg("-signer", "");
|
const std::string command = gArgs.GetArg("-signer", "");
|
||||||
if (command == "") throw JSONRPCError(RPC_MISC_ERROR, "Error: restart bitcoind with -signer=<cmd>");
|
if (command == "") throw JSONRPCError(RPC_MISC_ERROR, "Error: restart bitcoind with -signer=<cmd>");
|
||||||
const std::string chain = gArgs.GetChainName();
|
const std::string chain = gArgs.GetChainTypeString();
|
||||||
UniValue signers_res = UniValue::VARR;
|
UniValue signers_res = UniValue::VARR;
|
||||||
try {
|
try {
|
||||||
std::vector<ExternalSigner> signers;
|
std::vector<ExternalSigner> signers;
|
||||||
|
|
|
@ -435,7 +435,7 @@ static RPCHelpMan getmininginfo()
|
||||||
obj.pushKV("difficulty", (double)GetDifficulty(active_chain.Tip()));
|
obj.pushKV("difficulty", (double)GetDifficulty(active_chain.Tip()));
|
||||||
obj.pushKV("networkhashps", getnetworkhashps().HandleRequest(request));
|
obj.pushKV("networkhashps", getnetworkhashps().HandleRequest(request));
|
||||||
obj.pushKV("pooledtx", (uint64_t)mempool.size());
|
obj.pushKV("pooledtx", (uint64_t)mempool.size());
|
||||||
obj.pushKV("chain", chainman.GetParams().NetworkIDString());
|
obj.pushKV("chain", chainman.GetParams().GetChainTypeString());
|
||||||
obj.pushKV("warnings", GetWarnings(false).original);
|
obj.pushKV("warnings", GetWarnings(false).original);
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <rpc/util.h>
|
#include <rpc/util.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <timedata.h>
|
#include <timedata.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
@ -354,7 +355,7 @@ static RPCHelpMan addconnection()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
if (Params().NetworkIDString() != CBaseChainParams::REGTEST) {
|
if (Params().GetChainType() != ChainType::REGTEST) {
|
||||||
throw std::runtime_error("addconnection is for regression testing (-regtest mode) only.");
|
throw std::runtime_error("addconnection is for regression testing (-regtest mode) only.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <test/util/str.h>
|
#include <test/util/str.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
|
|
||||||
|
@ -580,7 +581,7 @@ BOOST_AUTO_TEST_CASE(util_ReadConfigStream)
|
||||||
test_args.SetNetworkOnlyArg("-ccc");
|
test_args.SetNetworkOnlyArg("-ccc");
|
||||||
test_args.SetNetworkOnlyArg("-h");
|
test_args.SetNetworkOnlyArg("-h");
|
||||||
|
|
||||||
test_args.SelectConfigNetwork(CBaseChainParams::MAIN);
|
test_args.SelectConfigNetwork(ChainTypeToString(ChainType::MAIN));
|
||||||
BOOST_CHECK(test_args.GetArg("-d", "xxx") == "e");
|
BOOST_CHECK(test_args.GetArg("-d", "xxx") == "e");
|
||||||
BOOST_CHECK(test_args.GetArgs("-ccc").size() == 2);
|
BOOST_CHECK(test_args.GetArgs("-ccc").size() == 2);
|
||||||
BOOST_CHECK(test_args.GetArg("-h", "xxx") == "0");
|
BOOST_CHECK(test_args.GetArg("-h", "xxx") == "0");
|
||||||
|
@ -637,7 +638,7 @@ BOOST_AUTO_TEST_CASE(util_GetArg)
|
||||||
BOOST_CHECK_EQUAL(testArgs.GetArg("pritest4", "default"), "b");
|
BOOST_CHECK_EQUAL(testArgs.GetArg("pritest4", "default"), "b");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(util_GetChainName)
|
BOOST_AUTO_TEST_CASE(util_GetChainTypeString)
|
||||||
{
|
{
|
||||||
TestArgsManager test_args;
|
TestArgsManager test_args;
|
||||||
const auto testnet = std::make_pair("-testnet", ArgsManager::ALLOW_ANY);
|
const auto testnet = std::make_pair("-testnet", ArgsManager::ALLOW_ANY);
|
||||||
|
@ -655,39 +656,39 @@ BOOST_AUTO_TEST_CASE(util_GetChainName)
|
||||||
std::string error;
|
std::string error;
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(0, (char**)argv_testnet, error));
|
BOOST_CHECK(test_args.ParseParameters(0, (char**)argv_testnet, error));
|
||||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "main");
|
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "main");
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_testnet, error));
|
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_testnet, error));
|
||||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_regtest, error));
|
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_regtest, error));
|
||||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "regtest");
|
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "regtest");
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_test_no_reg, error));
|
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_test_no_reg, error));
|
||||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_both, error));
|
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_both, error));
|
||||||
BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error);
|
BOOST_CHECK_THROW(test_args.GetChainTypeString(), std::runtime_error);
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(0, (char**)argv_testnet, error));
|
BOOST_CHECK(test_args.ParseParameters(0, (char**)argv_testnet, error));
|
||||||
test_args.ReadConfigString(testnetconf);
|
test_args.ReadConfigString(testnetconf);
|
||||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_testnet, error));
|
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_testnet, error));
|
||||||
test_args.ReadConfigString(testnetconf);
|
test_args.ReadConfigString(testnetconf);
|
||||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_regtest, error));
|
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_regtest, error));
|
||||||
test_args.ReadConfigString(testnetconf);
|
test_args.ReadConfigString(testnetconf);
|
||||||
BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error);
|
BOOST_CHECK_THROW(test_args.GetChainTypeString(), std::runtime_error);
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_test_no_reg, error));
|
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_test_no_reg, error));
|
||||||
test_args.ReadConfigString(testnetconf);
|
test_args.ReadConfigString(testnetconf);
|
||||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_both, error));
|
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_both, error));
|
||||||
test_args.ReadConfigString(testnetconf);
|
test_args.ReadConfigString(testnetconf);
|
||||||
BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error);
|
BOOST_CHECK_THROW(test_args.GetChainTypeString(), std::runtime_error);
|
||||||
|
|
||||||
// check setting the network to test (and thus making
|
// check setting the network to test (and thus making
|
||||||
// [test] regtest=1 potentially relevant) doesn't break things
|
// [test] regtest=1 potentially relevant) doesn't break things
|
||||||
|
@ -695,23 +696,23 @@ BOOST_AUTO_TEST_CASE(util_GetChainName)
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(0, (char**)argv_testnet, error));
|
BOOST_CHECK(test_args.ParseParameters(0, (char**)argv_testnet, error));
|
||||||
test_args.ReadConfigString(testnetconf);
|
test_args.ReadConfigString(testnetconf);
|
||||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_testnet, error));
|
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_testnet, error));
|
||||||
test_args.ReadConfigString(testnetconf);
|
test_args.ReadConfigString(testnetconf);
|
||||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_regtest, error));
|
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_regtest, error));
|
||||||
test_args.ReadConfigString(testnetconf);
|
test_args.ReadConfigString(testnetconf);
|
||||||
BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error);
|
BOOST_CHECK_THROW(test_args.GetChainTypeString(), std::runtime_error);
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_test_no_reg, error));
|
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_test_no_reg, error));
|
||||||
test_args.ReadConfigString(testnetconf);
|
test_args.ReadConfigString(testnetconf);
|
||||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||||
|
|
||||||
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_both, error));
|
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_both, error));
|
||||||
test_args.ReadConfigString(testnetconf);
|
test_args.ReadConfigString(testnetconf);
|
||||||
BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error);
|
BOOST_CHECK_THROW(test_args.GetChainTypeString(), std::runtime_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test different ways settings can be merged, and verify results. This test can
|
// Test different ways settings can be merged, and verify results. This test can
|
||||||
|
@ -755,8 +756,8 @@ struct ArgsMergeTestingSetup : public BasicTestingSetup {
|
||||||
ForEachNoDup(conf_actions, SET, SECTION_NEGATE, [&] {
|
ForEachNoDup(conf_actions, SET, SECTION_NEGATE, [&] {
|
||||||
for (bool soft_set : {false, true}) {
|
for (bool soft_set : {false, true}) {
|
||||||
for (bool force_set : {false, true}) {
|
for (bool force_set : {false, true}) {
|
||||||
for (const std::string& section : {CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::SIGNET}) {
|
for (const std::string& section : {ChainTypeToString(ChainType::MAIN), ChainTypeToString(ChainType::TESTNET), ChainTypeToString(ChainType::SIGNET)}) {
|
||||||
for (const std::string& network : {CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::SIGNET}) {
|
for (const std::string& network : {ChainTypeToString(ChainType::MAIN), ChainTypeToString(ChainType::TESTNET), ChainTypeToString(ChainType::SIGNET)}) {
|
||||||
for (bool net_specific : {false, true}) {
|
for (bool net_specific : {false, true}) {
|
||||||
fn(arg_actions, conf_actions, soft_set, force_set, section, network, net_specific);
|
fn(arg_actions, conf_actions, soft_set, force_set, section, network, net_specific);
|
||||||
}
|
}
|
||||||
|
@ -913,7 +914,7 @@ BOOST_FIXTURE_TEST_CASE(util_ArgsMerge, ArgsMergeTestingSetup)
|
||||||
BOOST_CHECK_EQUAL(out_sha_hex, "d1e436c1cd510d0ec44d5205d4b4e3bee6387d316e0075c58206cb16603f3d82");
|
BOOST_CHECK_EQUAL(out_sha_hex, "d1e436c1cd510d0ec44d5205d4b4e3bee6387d316e0075c58206cb16603f3d82");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar test as above, but for ArgsManager::GetChainName function.
|
// Similar test as above, but for ArgsManager::GetChainTypeString function.
|
||||||
struct ChainMergeTestingSetup : public BasicTestingSetup {
|
struct ChainMergeTestingSetup : public BasicTestingSetup {
|
||||||
static constexpr int MAX_ACTIONS = 2;
|
static constexpr int MAX_ACTIONS = 2;
|
||||||
|
|
||||||
|
@ -982,7 +983,7 @@ BOOST_FIXTURE_TEST_CASE(util_ChainMerge, ChainMergeTestingSetup)
|
||||||
|
|
||||||
desc += " || ";
|
desc += " || ";
|
||||||
try {
|
try {
|
||||||
desc += parser.GetChainName();
|
desc += parser.GetChainTypeString();
|
||||||
} catch (const std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
desc += "error: ";
|
desc += "error: ";
|
||||||
desc += e.what();
|
desc += e.what();
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <node/blockstorage.h>
|
#include <node/blockstorage.h>
|
||||||
#include <node/context.h>
|
#include <node/context.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
@ -20,7 +21,7 @@ BOOST_FIXTURE_TEST_SUITE(blockmanager_tests, BasicTestingSetup)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(blockmanager_find_block_pos)
|
BOOST_AUTO_TEST_CASE(blockmanager_find_block_pos)
|
||||||
{
|
{
|
||||||
const auto params {CreateChainParams(ArgsManager{}, CBaseChainParams::MAIN)};
|
const auto params {CreateChainParams(ArgsManager{}, ChainType::MAIN)};
|
||||||
node::BlockManager::Options blockman_opts{
|
node::BlockManager::Options blockman_opts{
|
||||||
.chainparams = *params,
|
.chainparams = *params,
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <test/util/random.h>
|
#include <test/util/random.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
@ -27,9 +28,9 @@
|
||||||
struct NoLockLoggingTestingSetup : public TestingSetup {
|
struct NoLockLoggingTestingSetup : public TestingSetup {
|
||||||
NoLockLoggingTestingSetup()
|
NoLockLoggingTestingSetup()
|
||||||
#ifdef DEBUG_LOCKCONTENTION
|
#ifdef DEBUG_LOCKCONTENTION
|
||||||
: TestingSetup{CBaseChainParams::MAIN, /*extra_args=*/{"-debugexclude=lock"}} {}
|
: TestingSetup{ChainType::MAIN, /*extra_args=*/{"-debugexclude=lock"}} {}
|
||||||
#else
|
#else
|
||||||
: TestingSetup{CBaseChainParams::MAIN} {}
|
: TestingSetup{ChainType::MAIN} {}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <util/asmap.h>
|
#include <util/asmap.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -34,7 +35,7 @@ int32_t GetCheckRatio()
|
||||||
|
|
||||||
void initialize_addrman()
|
void initialize_addrman()
|
||||||
{
|
{
|
||||||
static const auto testing_setup = MakeNoLogFileContext<>(CBaseChainParams::REGTEST);
|
static const auto testing_setup = MakeNoLogFileContext<>(ChainType::REGTEST);
|
||||||
g_setup = testing_setup.get();
|
g_setup = testing_setup.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <pubkey.h>
|
#include <pubkey.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
|
|
||||||
void initialize_block()
|
void initialize_block()
|
||||||
{
|
{
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(block, initialize_block)
|
FUZZ_TARGET_INIT(block, initialize_block)
|
||||||
|
|
|
@ -6,11 +6,12 @@
|
||||||
#include <pubkey.h>
|
#include <pubkey.h>
|
||||||
#include <script/descriptor.h>
|
#include <script/descriptor.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
void initialize_descriptor_parse()
|
void initialize_descriptor_parse()
|
||||||
{
|
{
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
SelectParams(CBaseChainParams::MAIN);
|
SelectParams(ChainType::MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(descriptor_parse, initialize_descriptor_parse)
|
FUZZ_TARGET_INIT(descriptor_parse, initialize_descriptor_parse)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@
|
||||||
static void initialize_headers_sync_state_fuzz()
|
static void initialize_headers_sync_state_fuzz()
|
||||||
{
|
{
|
||||||
static const auto testing_setup = MakeNoLogFileContext<>(
|
static const auto testing_setup = MakeNoLogFileContext<>(
|
||||||
/*chain_name=*/CBaseChainParams::MAIN);
|
/*chain_type=*/ChainType::MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeHeadersContinuous(
|
void MakeHeadersContinuous(
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
#include <util/moneystr.h>
|
#include <util/moneystr.h>
|
||||||
#include <util/overflow.h>
|
#include <util/overflow.h>
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
|
|
||||||
void initialize_integer()
|
void initialize_integer()
|
||||||
{
|
{
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(integer, initialize_integer)
|
FUZZ_TARGET_INIT(integer, initialize_integer)
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <script/standard.h>
|
#include <script/standard.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -28,7 +29,7 @@
|
||||||
void initialize_key()
|
void initialize_key()
|
||||||
{
|
{
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(key, initialize_key)
|
FUZZ_TARGET_INIT(key, initialize_key)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <key_io.h>
|
#include <key_io.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -14,7 +15,7 @@
|
||||||
void initialize_key_io()
|
void initialize_key_io()
|
||||||
{
|
{
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
SelectParams(CBaseChainParams::MAIN);
|
SelectParams(ChainType::MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(key_io, initialize_key_io)
|
FUZZ_TARGET_INIT(key_io, initialize_key_io)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <test/fuzz/FuzzedDataProvider.h>
|
#include <test/fuzz/FuzzedDataProvider.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/message.h>
|
#include <util/message.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
void initialize_message()
|
void initialize_message()
|
||||||
{
|
{
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(message, initialize_message)
|
FUZZ_TARGET_INIT(message, initialize_message)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <test/util/net.h>
|
#include <test/util/net.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <util/asmap.h>
|
#include <util/asmap.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -24,7 +25,7 @@
|
||||||
|
|
||||||
void initialize_net()
|
void initialize_net()
|
||||||
{
|
{
|
||||||
static const auto testing_setup = MakeNoLogFileContext<>(CBaseChainParams::MAIN);
|
static const auto testing_setup = MakeNoLogFileContext<>(ChainType::MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(net, initialize_net)
|
FUZZ_TARGET_INIT(net, initialize_net)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <protocol.h>
|
#include <protocol.h>
|
||||||
#include <test/fuzz/FuzzedDataProvider.h>
|
#include <test/fuzz/FuzzedDataProvider.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
|
|
||||||
void initialize_p2p_transport_serialization()
|
void initialize_p2p_transport_serialization()
|
||||||
{
|
{
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(p2p_transport_serialization, initialize_p2p_transport_serialization)
|
FUZZ_TARGET_INIT(p2p_transport_serialization, initialize_p2p_transport_serialization)
|
||||||
|
|
|
@ -7,13 +7,14 @@
|
||||||
#include <rpc/client.h>
|
#include <rpc/client.h>
|
||||||
#include <rpc/util.h>
|
#include <rpc/util.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
void initialize_parse_univalue()
|
void initialize_parse_univalue()
|
||||||
{
|
{
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(parse_univalue, initialize_parse_univalue)
|
FUZZ_TARGET_INIT(parse_univalue, initialize_parse_univalue)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <test/fuzz/FuzzedDataProvider.h>
|
#include <test/fuzz/FuzzedDataProvider.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
#include <util/overflow.h>
|
#include <util/overflow.h>
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
|
|
||||||
void initialize_pow()
|
void initialize_pow()
|
||||||
{
|
{
|
||||||
SelectParams(CBaseChainParams::MAIN);
|
SelectParams(ChainType::MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(pow, initialize_pow)
|
FUZZ_TARGET_INIT(pow, initialize_pow)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <test/util/net.h>
|
#include <test/util/net.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <test/util/validation.h>
|
#include <test/util/validation.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ void initialize_process_message()
|
||||||
Assert(GetNumMsgTypes() == getAllNetMessageTypes().size()); // If this fails, add or remove the message type below
|
Assert(GetNumMsgTypes() == getAllNetMessageTypes().size()); // If this fails, add or remove the message type below
|
||||||
|
|
||||||
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(
|
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(
|
||||||
/*chain_name=*/CBaseChainParams::REGTEST,
|
/*chain_type=*/ChainType::REGTEST,
|
||||||
/*extra_args=*/{"-txreconciliation"});
|
/*extra_args=*/{"-txreconciliation"});
|
||||||
g_setup = testing_setup.get();
|
g_setup = testing_setup.get();
|
||||||
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
|
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ const TestingSetup* g_setup;
|
||||||
void initialize_process_messages()
|
void initialize_process_messages()
|
||||||
{
|
{
|
||||||
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(
|
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(
|
||||||
/*chain_name=*/CBaseChainParams::REGTEST,
|
/*chain_type=*/ChainType::REGTEST,
|
||||||
/*extra_args=*/{"-txreconciliation"});
|
/*extra_args=*/{"-txreconciliation"});
|
||||||
g_setup = testing_setup.get();
|
g_setup = testing_setup.get();
|
||||||
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
|
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct RPCFuzzTestingSetup : public TestingSetup {
|
struct RPCFuzzTestingSetup : public TestingSetup {
|
||||||
RPCFuzzTestingSetup(const std::string& chain_name, const std::vector<const char*>& extra_args) : TestingSetup{chain_name, extra_args}
|
RPCFuzzTestingSetup(const ChainType chain_type, const std::vector<const char*>& extra_args) : TestingSetup{chain_type, extra_args}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
|
|
||||||
void initialize_script()
|
void initialize_script()
|
||||||
{
|
{
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(script, initialize_script)
|
FUZZ_TARGET_INIT(script, initialize_script)
|
||||||
|
|
|
@ -11,10 +11,11 @@
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
void initialize_script_format()
|
void initialize_script_format()
|
||||||
{
|
{
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(script_format, initialize_script_format)
|
FUZZ_TARGET_INIT(script_format, initialize_script_format)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <test/fuzz/FuzzedDataProvider.h>
|
#include <test/fuzz/FuzzedDataProvider.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
void initialize_script_sign()
|
void initialize_script_sign()
|
||||||
{
|
{
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(script_sign, initialize_script_sign)
|
FUZZ_TARGET_INIT(script_sign, initialize_script_sign)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
|
|
||||||
void initialize_signet()
|
void initialize_signet()
|
||||||
{
|
{
|
||||||
static const auto testing_setup = MakeNoLogFileContext<>(CBaseChainParams::SIGNET);
|
static const auto testing_setup = MakeNoLogFileContext<>(ChainType::SIGNET);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(signet, initialize_signet)
|
FUZZ_TARGET_INIT(signet, initialize_signet)
|
||||||
|
|
|
@ -108,7 +108,7 @@ FUZZ_TARGET_INIT(system, initialize_system)
|
||||||
(void)args_manager.GetArgs(s1);
|
(void)args_manager.GetArgs(s1);
|
||||||
(void)args_manager.GetBoolArg(s1, b);
|
(void)args_manager.GetBoolArg(s1, b);
|
||||||
try {
|
try {
|
||||||
(void)args_manager.GetChainName();
|
(void)args_manager.GetChainTypeString();
|
||||||
} catch (const std::runtime_error&) {
|
} catch (const std::runtime_error&) {
|
||||||
}
|
}
|
||||||
(void)args_manager.GetHelpMessage();
|
(void)args_manager.GetHelpMessage();
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/rbf.h>
|
#include <util/rbf.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
|
|
||||||
void initialize_transaction()
|
void initialize_transaction()
|
||||||
{
|
{
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(transaction, initialize_transaction)
|
FUZZ_TARGET_INIT(transaction, initialize_transaction)
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
#include <test/util/mining.h>
|
#include <test/util/mining.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
|
@ -22,7 +23,7 @@ const std::vector<std::shared_ptr<CBlock>>* g_chain;
|
||||||
|
|
||||||
void initialize_chain()
|
void initialize_chain()
|
||||||
{
|
{
|
||||||
const auto params{CreateChainParams(ArgsManager{}, CBaseChainParams::REGTEST)};
|
const auto params{CreateChainParams(ArgsManager{}, ChainType::REGTEST)};
|
||||||
static const auto chain{CreateBlockChain(2 * COINBASE_MATURITY, *params)};
|
static const auto chain{CreateBlockChain(2 * COINBASE_MATURITY, *params)};
|
||||||
g_chain = &chain;
|
g_chain = &chain;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
#include <test/util/mining.h>
|
#include <test/util/mining.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ FUZZ_TARGET(utxo_total_supply)
|
||||||
{
|
{
|
||||||
/** The testing setup that creates a chainman only (no chainstate) */
|
/** The testing setup that creates a chainman only (no chainstate) */
|
||||||
ChainTestingSetup test_setup{
|
ChainTestingSetup test_setup{
|
||||||
CBaseChainParams::REGTEST,
|
ChainType::REGTEST,
|
||||||
{
|
{
|
||||||
"-testactivationheight=bip34@2",
|
"-testactivationheight=bip34@2",
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <common/args.h>
|
#include <common/args.h>
|
||||||
#include <consensus/params.h>
|
#include <consensus/params.h>
|
||||||
#include <primitives/block.h>
|
#include <primitives/block.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <versionbits.h>
|
#include <versionbits.h>
|
||||||
|
|
||||||
#include <test/fuzz/FuzzedDataProvider.h>
|
#include <test/fuzz/FuzzedDataProvider.h>
|
||||||
|
@ -104,7 +105,7 @@ std::unique_ptr<const CChainParams> g_params;
|
||||||
void initialize()
|
void initialize()
|
||||||
{
|
{
|
||||||
// this is actually comparatively slow, so only do it once
|
// this is actually comparatively slow, so only do it once
|
||||||
g_params = CreateChainParams(ArgsManager{}, CBaseChainParams::MAIN);
|
g_params = CreateChainParams(ArgsManager{}, ChainType::MAIN);
|
||||||
assert(g_params != nullptr);
|
assert(g_params != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <script/script.h>
|
#include <script/script.h>
|
||||||
#include <test/util/json.h>
|
#include <test/util/json.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
@ -24,7 +25,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_parse)
|
||||||
UniValue tests = read_json(std::string(json_tests::key_io_valid, json_tests::key_io_valid + sizeof(json_tests::key_io_valid)));
|
UniValue tests = read_json(std::string(json_tests::key_io_valid, json_tests::key_io_valid + sizeof(json_tests::key_io_valid)));
|
||||||
CKey privkey;
|
CKey privkey;
|
||||||
CTxDestination destination;
|
CTxDestination destination;
|
||||||
SelectParams(CBaseChainParams::MAIN);
|
SelectParams(ChainType::MAIN);
|
||||||
|
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
const UniValue& test = tests[idx];
|
const UniValue& test = tests[idx];
|
||||||
|
@ -37,7 +38,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_parse)
|
||||||
const std::vector<std::byte> exp_payload{ParseHex<std::byte>(test[1].get_str())};
|
const std::vector<std::byte> exp_payload{ParseHex<std::byte>(test[1].get_str())};
|
||||||
const UniValue &metadata = test[2].get_obj();
|
const UniValue &metadata = test[2].get_obj();
|
||||||
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
|
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
|
||||||
SelectParams(find_value(metadata, "chain").get_str());
|
SelectParams(ChainTypeFromString(find_value(metadata, "chain").get_str()).value());
|
||||||
bool try_case_flip = find_value(metadata, "tryCaseFlip").isNull() ? false : find_value(metadata, "tryCaseFlip").get_bool();
|
bool try_case_flip = find_value(metadata, "tryCaseFlip").isNull() ? false : find_value(metadata, "tryCaseFlip").get_bool();
|
||||||
if (isPrivkey) {
|
if (isPrivkey) {
|
||||||
bool isCompressed = find_value(metadata, "isCompressed").get_bool();
|
bool isCompressed = find_value(metadata, "isCompressed").get_bool();
|
||||||
|
@ -96,7 +97,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_gen)
|
||||||
std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str());
|
std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str());
|
||||||
const UniValue &metadata = test[2].get_obj();
|
const UniValue &metadata = test[2].get_obj();
|
||||||
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
|
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
|
||||||
SelectParams(find_value(metadata, "chain").get_str());
|
SelectParams(ChainTypeFromString(find_value(metadata, "chain").get_str()).value());
|
||||||
if (isPrivkey) {
|
if (isPrivkey) {
|
||||||
bool isCompressed = find_value(metadata, "isCompressed").get_bool();
|
bool isCompressed = find_value(metadata, "isCompressed").get_bool();
|
||||||
CKey key;
|
CKey key;
|
||||||
|
@ -113,7 +114,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_gen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectParams(CBaseChainParams::MAIN);
|
SelectParams(ChainType::MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,7 +136,7 @@ BOOST_AUTO_TEST_CASE(key_io_invalid)
|
||||||
std::string exp_base58string = test[0].get_str();
|
std::string exp_base58string = test[0].get_str();
|
||||||
|
|
||||||
// must be invalid as public and as private key
|
// must be invalid as public and as private key
|
||||||
for (const auto& chain : { CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::SIGNET, CBaseChainParams::REGTEST }) {
|
for (const auto& chain : {ChainType::MAIN, ChainType::TESTNET, ChainType::SIGNET, ChainType::REGTEST}) {
|
||||||
SelectParams(chain);
|
SelectParams(chain);
|
||||||
destination = DecodeDestination(exp_base58string);
|
destination = DecodeDestination(exp_base58string);
|
||||||
BOOST_CHECK_MESSAGE(!IsValidDestination(destination), "IsValid pubkey in mainnet:" + strTest);
|
BOOST_CHECK_MESSAGE(!IsValidDestination(destination), "IsValid pubkey in mainnet:" + strTest);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <pow.h>
|
#include <pow.h>
|
||||||
#include <test/util/random.h>
|
#include <test/util/random.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup)
|
||||||
/* Test calculation of next difficulty target with no constraints applying */
|
/* Test calculation of next difficulty target with no constraints applying */
|
||||||
BOOST_AUTO_TEST_CASE(get_next_work)
|
BOOST_AUTO_TEST_CASE(get_next_work)
|
||||||
{
|
{
|
||||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||||
int64_t nLastRetargetTime = 1261130161; // Block #30240
|
int64_t nLastRetargetTime = 1261130161; // Block #30240
|
||||||
CBlockIndex pindexLast;
|
CBlockIndex pindexLast;
|
||||||
pindexLast.nHeight = 32255;
|
pindexLast.nHeight = 32255;
|
||||||
|
@ -34,7 +35,7 @@ BOOST_AUTO_TEST_CASE(get_next_work)
|
||||||
/* Test the constraint on the upper bound for next work */
|
/* Test the constraint on the upper bound for next work */
|
||||||
BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
|
BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
|
||||||
{
|
{
|
||||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||||
int64_t nLastRetargetTime = 1231006505; // Block #0
|
int64_t nLastRetargetTime = 1231006505; // Block #0
|
||||||
CBlockIndex pindexLast;
|
CBlockIndex pindexLast;
|
||||||
pindexLast.nHeight = 2015;
|
pindexLast.nHeight = 2015;
|
||||||
|
@ -48,7 +49,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
|
||||||
/* Test the constraint on the lower bound for actual time taken */
|
/* Test the constraint on the lower bound for actual time taken */
|
||||||
BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
|
BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
|
||||||
{
|
{
|
||||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||||
int64_t nLastRetargetTime = 1279008237; // Block #66528
|
int64_t nLastRetargetTime = 1279008237; // Block #66528
|
||||||
CBlockIndex pindexLast;
|
CBlockIndex pindexLast;
|
||||||
pindexLast.nHeight = 68543;
|
pindexLast.nHeight = 68543;
|
||||||
|
@ -65,7 +66,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
|
||||||
/* Test the constraint on the upper bound for actual time taken */
|
/* Test the constraint on the upper bound for actual time taken */
|
||||||
BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual)
|
BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual)
|
||||||
{
|
{
|
||||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||||
int64_t nLastRetargetTime = 1263163443; // NOTE: Not an actual block time
|
int64_t nLastRetargetTime = 1263163443; // NOTE: Not an actual block time
|
||||||
CBlockIndex pindexLast;
|
CBlockIndex pindexLast;
|
||||||
pindexLast.nHeight = 46367;
|
pindexLast.nHeight = 46367;
|
||||||
|
@ -81,7 +82,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_negative_target)
|
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_negative_target)
|
||||||
{
|
{
|
||||||
const auto consensus = CreateChainParams(*m_node.args, CBaseChainParams::MAIN)->GetConsensus();
|
const auto consensus = CreateChainParams(*m_node.args, ChainType::MAIN)->GetConsensus();
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
unsigned int nBits;
|
unsigned int nBits;
|
||||||
nBits = UintToArith256(consensus.powLimit).GetCompact(true);
|
nBits = UintToArith256(consensus.powLimit).GetCompact(true);
|
||||||
|
@ -91,7 +92,7 @@ BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_negative_target)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_overflow_target)
|
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_overflow_target)
|
||||||
{
|
{
|
||||||
const auto consensus = CreateChainParams(*m_node.args, CBaseChainParams::MAIN)->GetConsensus();
|
const auto consensus = CreateChainParams(*m_node.args, ChainType::MAIN)->GetConsensus();
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
unsigned int nBits{~0x00800000U};
|
unsigned int nBits{~0x00800000U};
|
||||||
hash.SetHex("0x1");
|
hash.SetHex("0x1");
|
||||||
|
@ -100,7 +101,7 @@ BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_overflow_target)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_too_easy_target)
|
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_too_easy_target)
|
||||||
{
|
{
|
||||||
const auto consensus = CreateChainParams(*m_node.args, CBaseChainParams::MAIN)->GetConsensus();
|
const auto consensus = CreateChainParams(*m_node.args, ChainType::MAIN)->GetConsensus();
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
unsigned int nBits;
|
unsigned int nBits;
|
||||||
arith_uint256 nBits_arith = UintToArith256(consensus.powLimit);
|
arith_uint256 nBits_arith = UintToArith256(consensus.powLimit);
|
||||||
|
@ -112,7 +113,7 @@ BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_too_easy_target)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_biger_hash_than_target)
|
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_biger_hash_than_target)
|
||||||
{
|
{
|
||||||
const auto consensus = CreateChainParams(*m_node.args, CBaseChainParams::MAIN)->GetConsensus();
|
const auto consensus = CreateChainParams(*m_node.args, ChainType::MAIN)->GetConsensus();
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
unsigned int nBits;
|
unsigned int nBits;
|
||||||
arith_uint256 hash_arith = UintToArith256(consensus.powLimit);
|
arith_uint256 hash_arith = UintToArith256(consensus.powLimit);
|
||||||
|
@ -124,7 +125,7 @@ BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_biger_hash_than_target)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_zero_target)
|
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_zero_target)
|
||||||
{
|
{
|
||||||
const auto consensus = CreateChainParams(*m_node.args, CBaseChainParams::MAIN)->GetConsensus();
|
const auto consensus = CreateChainParams(*m_node.args, ChainType::MAIN)->GetConsensus();
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
unsigned int nBits;
|
unsigned int nBits;
|
||||||
arith_uint256 hash_arith{0};
|
arith_uint256 hash_arith{0};
|
||||||
|
@ -135,7 +136,7 @@ BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_zero_target)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test)
|
BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test)
|
||||||
{
|
{
|
||||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||||
std::vector<CBlockIndex> blocks(10000);
|
std::vector<CBlockIndex> blocks(10000);
|
||||||
for (int i = 0; i < 10000; i++) {
|
for (int i = 0; i < 10000; i++) {
|
||||||
blocks[i].pprev = i ? &blocks[i - 1] : nullptr;
|
blocks[i].pprev = i ? &blocks[i - 1] : nullptr;
|
||||||
|
@ -155,9 +156,9 @@ BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sanity_check_chainparams(const ArgsManager& args, std::string chainName)
|
void sanity_check_chainparams(const ArgsManager& args, ChainType chain_type)
|
||||||
{
|
{
|
||||||
const auto chainParams = CreateChainParams(args, chainName);
|
const auto chainParams = CreateChainParams(args, chain_type);
|
||||||
const auto consensus = chainParams->GetConsensus();
|
const auto consensus = chainParams->GetConsensus();
|
||||||
|
|
||||||
// hash genesis is correct
|
// hash genesis is correct
|
||||||
|
@ -184,22 +185,22 @@ void sanity_check_chainparams(const ArgsManager& args, std::string chainName)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(ChainParams_MAIN_sanity)
|
BOOST_AUTO_TEST_CASE(ChainParams_MAIN_sanity)
|
||||||
{
|
{
|
||||||
sanity_check_chainparams(*m_node.args, CBaseChainParams::MAIN);
|
sanity_check_chainparams(*m_node.args, ChainType::MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(ChainParams_REGTEST_sanity)
|
BOOST_AUTO_TEST_CASE(ChainParams_REGTEST_sanity)
|
||||||
{
|
{
|
||||||
sanity_check_chainparams(*m_node.args, CBaseChainParams::REGTEST);
|
sanity_check_chainparams(*m_node.args, ChainType::REGTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(ChainParams_TESTNET_sanity)
|
BOOST_AUTO_TEST_CASE(ChainParams_TESTNET_sanity)
|
||||||
{
|
{
|
||||||
sanity_check_chainparams(*m_node.args, CBaseChainParams::TESTNET);
|
sanity_check_chainparams(*m_node.args, ChainType::TESTNET);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(ChainParams_SIGNET_sanity)
|
BOOST_AUTO_TEST_CASE(ChainParams_SIGNET_sanity)
|
||||||
{
|
{
|
||||||
sanity_check_chainparams(*m_node.args, CBaseChainParams::SIGNET);
|
sanity_check_chainparams(*m_node.args, ChainType::SIGNET);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <test/util/str.h>
|
#include <test/util/str.h>
|
||||||
#include <util/fs.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <common/args.h>
|
#include <common/args.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
#include <util/fs.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ BOOST_FIXTURE_TEST_CASE(Merge, MergeTestingSetup)
|
||||||
if (!out_file) throw std::system_error(errno, std::generic_category(), "fopen failed");
|
if (!out_file) throw std::system_error(errno, std::generic_category(), "fopen failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& network = CBaseChainParams::MAIN;
|
const std::string& network = ChainTypeToString(ChainType::MAIN);
|
||||||
ForEachMergeSetup([&](const ActionList& arg_actions, const ActionList& conf_actions, bool force_set,
|
ForEachMergeSetup([&](const ActionList& arg_actions, const ActionList& conf_actions, bool force_set,
|
||||||
bool ignore_default_section_config) {
|
bool ignore_default_section_config) {
|
||||||
std::string desc;
|
std::string desc;
|
||||||
|
@ -225,7 +225,7 @@ BOOST_FIXTURE_TEST_CASE(Merge, MergeTestingSetup)
|
||||||
}
|
}
|
||||||
|
|
||||||
desc += " || ";
|
desc += " || ";
|
||||||
desc += GetSetting(settings, network, name, ignore_default_section_config, /*ignore_nonpersistent=*/false, /*get_chain_name=*/false).write();
|
desc += GetSetting(settings, network, name, ignore_default_section_config, /*ignore_nonpersistent=*/false, /*get_chain_type=*/false).write();
|
||||||
desc += " |";
|
desc += " |";
|
||||||
for (const auto& s : GetSettingsList(settings, network, name, ignore_default_section_config)) {
|
for (const auto& s : GetSettingsList(settings, network, name, ignore_default_section_config)) {
|
||||||
desc += " ";
|
desc += " ";
|
||||||
|
|
|
@ -9,13 +9,14 @@
|
||||||
#include <script/standard.h>
|
#include <script/standard.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
struct Dersig100Setup : public TestChain100Setup {
|
struct Dersig100Setup : public TestChain100Setup {
|
||||||
Dersig100Setup()
|
Dersig100Setup()
|
||||||
: TestChain100Setup{CBaseChainParams::REGTEST, {"-testactivationheight=dersig@102"}} {}
|
: TestChain100Setup{ChainType::REGTEST, {"-testactivationheight=dersig@102"}} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
|
bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <timedata.h>
|
#include <timedata.h>
|
||||||
#include <txdb.h>
|
#include <txdb.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
@ -98,7 +99,7 @@ std::ostream& operator<<(std::ostream& os, const uint256& num)
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
|
BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vector<const char*>& extra_args)
|
||||||
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()},
|
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()},
|
||||||
m_args{}
|
m_args{}
|
||||||
{
|
{
|
||||||
|
@ -132,7 +133,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
|
||||||
throw std::runtime_error{error};
|
throw std::runtime_error{error};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SelectParams(chainName);
|
SelectParams(chainType);
|
||||||
SeedInsecureRand();
|
SeedInsecureRand();
|
||||||
if (G_TEST_LOG_FUN) LogInstance().PushBackCallback(G_TEST_LOG_FUN);
|
if (G_TEST_LOG_FUN) LogInstance().PushBackCallback(G_TEST_LOG_FUN);
|
||||||
InitLogging(*m_node.args);
|
InitLogging(*m_node.args);
|
||||||
|
@ -163,8 +164,8 @@ BasicTestingSetup::~BasicTestingSetup()
|
||||||
gArgs.ClearArgs();
|
gArgs.ClearArgs();
|
||||||
}
|
}
|
||||||
|
|
||||||
ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
|
ChainTestingSetup::ChainTestingSetup(const ChainType chainType, const std::vector<const char*>& extra_args)
|
||||||
: BasicTestingSetup(chainName, extra_args)
|
: BasicTestingSetup(chainType, extra_args)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
|
|
||||||
|
@ -240,11 +241,11 @@ void ChainTestingSetup::LoadVerifyActivateChainstate()
|
||||||
}
|
}
|
||||||
|
|
||||||
TestingSetup::TestingSetup(
|
TestingSetup::TestingSetup(
|
||||||
const std::string& chainName,
|
const ChainType chainType,
|
||||||
const std::vector<const char*>& extra_args,
|
const std::vector<const char*>& extra_args,
|
||||||
const bool coins_db_in_memory,
|
const bool coins_db_in_memory,
|
||||||
const bool block_tree_db_in_memory)
|
const bool block_tree_db_in_memory)
|
||||||
: ChainTestingSetup(chainName, extra_args)
|
: ChainTestingSetup(chainType, extra_args)
|
||||||
{
|
{
|
||||||
m_coins_db_in_memory = coins_db_in_memory;
|
m_coins_db_in_memory = coins_db_in_memory;
|
||||||
m_block_tree_db_in_memory = block_tree_db_in_memory;
|
m_block_tree_db_in_memory = block_tree_db_in_memory;
|
||||||
|
@ -271,11 +272,11 @@ TestingSetup::TestingSetup(
|
||||||
}
|
}
|
||||||
|
|
||||||
TestChain100Setup::TestChain100Setup(
|
TestChain100Setup::TestChain100Setup(
|
||||||
const std::string& chain_name,
|
const ChainType chain_type,
|
||||||
const std::vector<const char*>& extra_args,
|
const std::vector<const char*>& extra_args,
|
||||||
const bool coins_db_in_memory,
|
const bool coins_db_in_memory,
|
||||||
const bool block_tree_db_in_memory)
|
const bool block_tree_db_in_memory)
|
||||||
: TestingSetup{CBaseChainParams::REGTEST, extra_args, coins_db_in_memory, block_tree_db_in_memory}
|
: TestingSetup{ChainType::REGTEST, extra_args, coins_db_in_memory, block_tree_db_in_memory}
|
||||||
{
|
{
|
||||||
SetMockTime(1598887952);
|
SetMockTime(1598887952);
|
||||||
constexpr std::array<unsigned char, 32> vchKey = {
|
constexpr std::array<unsigned char, 32> vchKey = {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <pubkey.h>
|
#include <pubkey.h>
|
||||||
#include <random.h>
|
#include <random.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
|
@ -80,7 +81,7 @@ static constexpr CAmount CENT{1000000};
|
||||||
struct BasicTestingSetup {
|
struct BasicTestingSetup {
|
||||||
node::NodeContext m_node; // keep as first member to be destructed last
|
node::NodeContext m_node; // keep as first member to be destructed last
|
||||||
|
|
||||||
explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector<const char*>& extra_args = {});
|
explicit BasicTestingSetup(const ChainType chainType = ChainType::MAIN, const std::vector<const char*>& extra_args = {});
|
||||||
~BasicTestingSetup();
|
~BasicTestingSetup();
|
||||||
|
|
||||||
const fs::path m_path_root;
|
const fs::path m_path_root;
|
||||||
|
@ -96,7 +97,7 @@ struct ChainTestingSetup : public BasicTestingSetup {
|
||||||
bool m_coins_db_in_memory{true};
|
bool m_coins_db_in_memory{true};
|
||||||
bool m_block_tree_db_in_memory{true};
|
bool m_block_tree_db_in_memory{true};
|
||||||
|
|
||||||
explicit ChainTestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector<const char*>& extra_args = {});
|
explicit ChainTestingSetup(const ChainType chainType = ChainType::MAIN, const std::vector<const char*>& extra_args = {});
|
||||||
~ChainTestingSetup();
|
~ChainTestingSetup();
|
||||||
|
|
||||||
// Supplies a chainstate, if one is needed
|
// Supplies a chainstate, if one is needed
|
||||||
|
@ -107,7 +108,7 @@ struct ChainTestingSetup : public BasicTestingSetup {
|
||||||
*/
|
*/
|
||||||
struct TestingSetup : public ChainTestingSetup {
|
struct TestingSetup : public ChainTestingSetup {
|
||||||
explicit TestingSetup(
|
explicit TestingSetup(
|
||||||
const std::string& chainName = CBaseChainParams::MAIN,
|
const ChainType chainType = ChainType::MAIN,
|
||||||
const std::vector<const char*>& extra_args = {},
|
const std::vector<const char*>& extra_args = {},
|
||||||
const bool coins_db_in_memory = true,
|
const bool coins_db_in_memory = true,
|
||||||
const bool block_tree_db_in_memory = true);
|
const bool block_tree_db_in_memory = true);
|
||||||
|
@ -116,7 +117,7 @@ struct TestingSetup : public ChainTestingSetup {
|
||||||
/** Identical to TestingSetup, but chain set to regtest */
|
/** Identical to TestingSetup, but chain set to regtest */
|
||||||
struct RegTestingSetup : public TestingSetup {
|
struct RegTestingSetup : public TestingSetup {
|
||||||
RegTestingSetup()
|
RegTestingSetup()
|
||||||
: TestingSetup{CBaseChainParams::REGTEST} {}
|
: TestingSetup{ChainType::REGTEST} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CBlock;
|
class CBlock;
|
||||||
|
@ -128,7 +129,7 @@ class CScript;
|
||||||
*/
|
*/
|
||||||
struct TestChain100Setup : public TestingSetup {
|
struct TestChain100Setup : public TestingSetup {
|
||||||
TestChain100Setup(
|
TestChain100Setup(
|
||||||
const std::string& chain_name = CBaseChainParams::REGTEST,
|
const ChainType chain_type = ChainType::REGTEST,
|
||||||
const std::vector<const char*>& extra_args = {},
|
const std::vector<const char*>& extra_args = {},
|
||||||
const bool coins_db_in_memory = true,
|
const bool coins_db_in_memory = true,
|
||||||
const bool block_tree_db_in_memory = true);
|
const bool block_tree_db_in_memory = true);
|
||||||
|
@ -206,7 +207,7 @@ struct TestChain100Setup : public TestingSetup {
|
||||||
* be used in "hot loops", for example fuzzing or benchmarking.
|
* be used in "hot loops", for example fuzzing or benchmarking.
|
||||||
*/
|
*/
|
||||||
template <class T = const BasicTestingSetup>
|
template <class T = const BasicTestingSetup>
|
||||||
std::unique_ptr<T> MakeNoLogFileContext(const std::string& chain_name = CBaseChainParams::REGTEST, const std::vector<const char*>& extra_args = {})
|
std::unique_ptr<T> MakeNoLogFileContext(const ChainType chain_type = ChainType::REGTEST, const std::vector<const char*>& extra_args = {})
|
||||||
{
|
{
|
||||||
const std::vector<const char*> arguments = Cat(
|
const std::vector<const char*> arguments = Cat(
|
||||||
{
|
{
|
||||||
|
@ -215,7 +216,7 @@ std::unique_ptr<T> MakeNoLogFileContext(const std::string& chain_name = CBaseCha
|
||||||
},
|
},
|
||||||
extra_args);
|
extra_args);
|
||||||
|
|
||||||
return std::make_unique<T>(chain_name, arguments);
|
return std::make_unique<T>(chain_type, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
CBlock getBlock13b8a();
|
CBlock getBlock13b8a();
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
#include <signet.h>
|
#include <signet.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
@ -41,7 +42,7 @@ static void TestBlockSubsidyHalvings(int nSubsidyHalvingInterval)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(block_subsidy_test)
|
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(chainParams->GetConsensus()); // As in main
|
||||||
TestBlockSubsidyHalvings(150); // As in regtest
|
TestBlockSubsidyHalvings(150); // As in regtest
|
||||||
TestBlockSubsidyHalvings(1000); // Just another interval
|
TestBlockSubsidyHalvings(1000); // Just another interval
|
||||||
|
@ -49,7 +50,7 @@ BOOST_AUTO_TEST_CASE(block_subsidy_test)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(subsidy_limit_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;
|
CAmount nSum = 0;
|
||||||
for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) {
|
for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) {
|
||||||
CAmount nSubsidy = GetBlockSubsidy(nHeight, chainParams->GetConsensus());
|
CAmount nSubsidy = GetBlockSubsidy(nHeight, chainParams->GetConsensus());
|
||||||
|
@ -64,7 +65,7 @@ BOOST_AUTO_TEST_CASE(signet_parse_tests)
|
||||||
{
|
{
|
||||||
ArgsManager signet_argsman;
|
ArgsManager signet_argsman;
|
||||||
signet_argsman.ForceSetArg("-signetchallenge", "51"); // set challenge to OP_TRUE
|
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;
|
CBlock block;
|
||||||
BOOST_CHECK(signet_params->GetConsensus().signet_challenge == std::vector<uint8_t>{OP_TRUE});
|
BOOST_CHECK(signet_params->GetConsensus().signet_challenge == std::vector<uint8_t>{OP_TRUE});
|
||||||
CScript challenge{OP_TRUE};
|
CScript challenge{OP_TRUE};
|
||||||
|
@ -124,7 +125,7 @@ BOOST_AUTO_TEST_CASE(signet_parse_tests)
|
||||||
//! Test retrieval of valid assumeutxo values.
|
//! Test retrieval of valid assumeutxo values.
|
||||||
BOOST_AUTO_TEST_CASE(test_assumeutxo)
|
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
|
// These heights don't have assumeutxo configurations associated, per the contents
|
||||||
// of kernel/chainparams.cpp.
|
// of kernel/chainparams.cpp.
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <consensus/params.h>
|
#include <consensus/params.h>
|
||||||
#include <test/util/random.h>
|
#include <test/util/random.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <versionbits.h>
|
#include <versionbits.h>
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#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
|
// check that any deployment on any chain can conceivably reach both
|
||||||
// ACTIVE and FAILED states in roughly the way we expect
|
// ACTIVE and FAILED states in roughly the way we expect
|
||||||
for (const auto& chain_name : {CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::SIGNET, CBaseChainParams::REGTEST}) {
|
for (const auto& chain_type: {ChainType::MAIN, ChainType::TESTNET, ChainType::SIGNET, ChainType::REGTEST}) {
|
||||||
const auto chainParams = CreateChainParams(*m_node.args, chain_name);
|
const auto chainParams = CreateChainParams(*m_node.args, chain_type);
|
||||||
uint32_t chain_all_vbits{0};
|
uint32_t chain_all_vbits{0};
|
||||||
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) {
|
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) {
|
||||||
const auto dep = static_cast<Consensus::DeploymentPos>(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
|
// deployment that's not always/never active
|
||||||
ArgsManager args;
|
ArgsManager args;
|
||||||
args.ForceSetArg("-vbparams", "testdummy:1199145601:1230767999"); // January 1, 2008 - December 31, 2008
|
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);
|
check_computeblockversion(vbcache, chainParams->GetConsensus(), Consensus::DEPLOYMENT_TESTDUMMY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,7 +451,7 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
|
||||||
// live deployment
|
// live deployment
|
||||||
ArgsManager args;
|
ArgsManager args;
|
||||||
args.ForceSetArg("-vbparams", "testdummy:1199145601:1230767999:403200"); // January 1, 2008 - December 31, 2008, min act height 403200
|
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);
|
check_computeblockversion(vbcache, chainParams->GetConsensus(), Consensus::DEPLOYMENT_TESTDUMMY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ SettingsValue GetSetting(const Settings& settings,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
bool ignore_default_section_config,
|
bool ignore_default_section_config,
|
||||||
bool ignore_nonpersistent,
|
bool ignore_nonpersistent,
|
||||||
bool get_chain_name)
|
bool get_chain_type)
|
||||||
{
|
{
|
||||||
SettingsValue result;
|
SettingsValue result;
|
||||||
bool done = false; // Done merging any more settings sources.
|
bool done = false; // Done merging any more settings sources.
|
||||||
|
@ -145,17 +145,17 @@ SettingsValue GetSetting(const Settings& settings,
|
||||||
// assigned value instead of last. In general, later settings take
|
// assigned value instead of last. In general, later settings take
|
||||||
// precedence over early settings, but for backwards compatibility in
|
// precedence over early settings, but for backwards compatibility in
|
||||||
// the config file the precedence is reversed for all settings except
|
// the config file the precedence is reversed for all settings except
|
||||||
// chain name settings.
|
// chain type settings.
|
||||||
const bool reverse_precedence =
|
const bool reverse_precedence =
|
||||||
(source == Source::CONFIG_FILE_NETWORK_SECTION || source == Source::CONFIG_FILE_DEFAULT_SECTION) &&
|
(source == Source::CONFIG_FILE_NETWORK_SECTION || source == Source::CONFIG_FILE_DEFAULT_SECTION) &&
|
||||||
!get_chain_name;
|
!get_chain_type;
|
||||||
|
|
||||||
// Weird behavior preserved for backwards compatibility: Negated
|
// Weird behavior preserved for backwards compatibility: Negated
|
||||||
// -regtest and -testnet arguments which you would expect to override
|
// -regtest and -testnet arguments which you would expect to override
|
||||||
// values set in the configuration file are currently accepted but
|
// values set in the configuration file are currently accepted but
|
||||||
// silently ignored. It would be better to apply these just like other
|
// silently ignored. It would be better to apply these just like other
|
||||||
// negated values, or at least warn they are ignored.
|
// negated values, or at least warn they are ignored.
|
||||||
const bool skip_negated_command_line = get_chain_name;
|
const bool skip_negated_command_line = get_chain_type;
|
||||||
|
|
||||||
if (done) return;
|
if (done) return;
|
||||||
|
|
||||||
|
|
|
@ -60,14 +60,14 @@ bool WriteSettings(const fs::path& path,
|
||||||
//! command line). Only return settings in the
|
//! command line). Only return settings in the
|
||||||
//! read-only config and read-write settings
|
//! read-only config and read-write settings
|
||||||
//! files.
|
//! files.
|
||||||
//! @param get_chain_name - enable special backwards compatible behavior
|
//! @param get_chain_type - enable special backwards compatible behavior
|
||||||
//! for GetChainName
|
//! for GetChainType
|
||||||
SettingsValue GetSetting(const Settings& settings,
|
SettingsValue GetSetting(const Settings& settings,
|
||||||
const std::string& section,
|
const std::string& section,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
bool ignore_default_section_config,
|
bool ignore_default_section_config,
|
||||||
bool ignore_nonpersistent,
|
bool ignore_nonpersistent,
|
||||||
bool get_chain_name);
|
bool get_chain_type);
|
||||||
|
|
||||||
//! Get combined setting value similar to GetSetting(), except if setting was
|
//! Get combined setting value similar to GetSetting(), except if setting was
|
||||||
//! specified multiple times, return a list of all the values specified.
|
//! specified multiple times, return a list of all the values specified.
|
||||||
|
|
|
@ -45,7 +45,7 @@ ExternalSigner ExternalSignerScriptPubKeyMan::GetExternalSigner() {
|
||||||
const std::string command = gArgs.GetArg("-signer", "");
|
const std::string command = gArgs.GetArg("-signer", "");
|
||||||
if (command == "") throw std::runtime_error(std::string(__func__) + ": restart bitcoind with -signer=<cmd>");
|
if (command == "") throw std::runtime_error(std::string(__func__) + ": restart bitcoind with -signer=<cmd>");
|
||||||
std::vector<ExternalSigner> signers;
|
std::vector<ExternalSigner> signers;
|
||||||
ExternalSigner::Enumerate(command, signers, Params().NetworkIDString());
|
ExternalSigner::Enumerate(command, signers, Params().GetChainTypeString());
|
||||||
if (signers.empty()) throw std::runtime_error(std::string(__func__) + ": No external signers found");
|
if (signers.empty()) throw std::runtime_error(std::string(__func__) + ": No external signers found");
|
||||||
// TODO: add fingerprint argument instead of failing in case of multiple signers.
|
// TODO: add fingerprint argument instead of failing in case of multiple signers.
|
||||||
if (signers.size() > 1) throw std::runtime_error(std::string(__func__) + ": More than one external signer found. Please connect only one at a time.");
|
if (signers.size() > 1) throw std::runtime_error(std::string(__func__) + ": More than one external signer found. Please connect only one at a time.");
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <common/args.h>
|
#include <common/args.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@
|
||||||
#include <wallet/test/init_test_fixture.h>
|
#include <wallet/test/init_test_fixture.h>
|
||||||
|
|
||||||
namespace wallet {
|
namespace wallet {
|
||||||
InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
|
InitWalletDirTestingSetup::InitWalletDirTestingSetup(const ChainType chainType) : BasicTestingSetup(chainType)
|
||||||
{
|
{
|
||||||
m_wallet_loader = MakeWalletLoader(*m_node.chain, m_args);
|
m_wallet_loader = MakeWalletLoader(*m_node.chain, m_args);
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
#include <interfaces/wallet.h>
|
#include <interfaces/wallet.h>
|
||||||
#include <node/context.h>
|
#include <node/context.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
|
|
||||||
namespace wallet {
|
namespace wallet {
|
||||||
struct InitWalletDirTestingSetup: public BasicTestingSetup {
|
struct InitWalletDirTestingSetup: public BasicTestingSetup {
|
||||||
explicit InitWalletDirTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
|
explicit InitWalletDirTestingSetup(const ChainType chain_type = ChainType::MAIN);
|
||||||
~InitWalletDirTestingSetup();
|
~InitWalletDirTestingSetup();
|
||||||
void SetWalletDir(const fs::path& walletdir_path);
|
void SetWalletDir(const fs::path& walletdir_path);
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
#include <wallet/test/wallet_test_fixture.h>
|
#include <wallet/test/wallet_test_fixture.h>
|
||||||
|
|
||||||
#include <scheduler.h>
|
#include <scheduler.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
|
|
||||||
namespace wallet {
|
namespace wallet {
|
||||||
WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
|
WalletTestingSetup::WalletTestingSetup(const ChainType chainType)
|
||||||
: TestingSetup(chainName),
|
: TestingSetup(chainType),
|
||||||
m_wallet_loader{interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args))},
|
m_wallet_loader{interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args))},
|
||||||
m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
|
m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <interfaces/chain.h>
|
#include <interfaces/chain.h>
|
||||||
#include <interfaces/wallet.h>
|
#include <interfaces/wallet.h>
|
||||||
#include <node/context.h>
|
#include <node/context.h>
|
||||||
|
#include <util/chaintype.h>
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ namespace wallet {
|
||||||
/** Testing setup and teardown for wallet.
|
/** Testing setup and teardown for wallet.
|
||||||
*/
|
*/
|
||||||
struct WalletTestingSetup : public TestingSetup {
|
struct WalletTestingSetup : public TestingSetup {
|
||||||
explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
|
explicit WalletTestingSetup(const ChainType chainType = ChainType::MAIN);
|
||||||
~WalletTestingSetup();
|
~WalletTestingSetup();
|
||||||
|
|
||||||
std::unique_ptr<interfaces::WalletLoader> m_wallet_loader;
|
std::unique_ptr<interfaces::WalletLoader> m_wallet_loader;
|
||||||
|
|
Loading…
Add table
Reference in a new issue