mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Testchains: Generic selection with -chain=<str> in addition of -testnet and -regtest
This commit is contained in:
parent
ae3e3bd151
commit
052c54ecb0
8 changed files with 17 additions and 14 deletions
|
@ -133,7 +133,7 @@ static int AppInitRPC(int argc, char* argv[])
|
|||
tfm::format(std::cerr, "Error reading configuration file: %s\n", error.c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause)
|
||||
// Check for -chain, -testnet or -regtest parameter (BaseParams() calls are only valid after this clause)
|
||||
try {
|
||||
SelectBaseParams(gArgs.GetChainName());
|
||||
} catch (const std::exception& e) {
|
||||
|
|
|
@ -88,7 +88,7 @@ static int AppInitRawTx(int argc, char* argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
// Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
try {
|
||||
SelectParams(gArgs.GetChainName());
|
||||
} catch (const std::exception& e) {
|
||||
|
|
|
@ -101,7 +101,7 @@ static bool AppInit(int argc, char* argv[])
|
|||
if (!gArgs.ReadConfigFiles(error, true)) {
|
||||
return InitError(strprintf("Error reading configuration file: %s\n", error));
|
||||
}
|
||||
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
// Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
try {
|
||||
SelectParams(gArgs.GetChainName());
|
||||
} catch (const std::exception& e) {
|
||||
|
|
|
@ -17,10 +17,11 @@ const std::string CBaseChainParams::REGTEST = "regtest";
|
|||
|
||||
void SetupChainParamsBaseOptions()
|
||||
{
|
||||
gArgs.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
gArgs.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
|
||||
"This is intended for regression testing tools and app development.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
|
||||
"This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
|
||||
gArgs.AddArg("-segwitheight=<n>", "Set the activation height of segwit. -1 to disable. (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||
gArgs.AddArg("-testnet", "Use the test chain", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
gArgs.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
gArgs.AddArg("-vbparams=deployment:start:end", "Use given start/end times for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
|
||||
}
|
||||
|
||||
|
|
|
@ -511,7 +511,7 @@ int GuiMain(int argc, char* argv[])
|
|||
// - QSettings() will use the new application name after this, resulting in network-specific settings
|
||||
// - Needs to be done before createOptionsModel
|
||||
|
||||
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
// Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
try {
|
||||
node->selectParams(gArgs.GetChainName());
|
||||
} catch(std::exception &e) {
|
||||
|
|
|
@ -588,7 +588,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
|||
// Start client minimized
|
||||
QString strArgs = "-min";
|
||||
// Set -testnet /-regtest options
|
||||
strArgs += QString::fromStdString(strprintf(" -testnet=%d -regtest=%d", gArgs.GetBoolArg("-testnet", false), gArgs.GetBoolArg("-regtest", false)));
|
||||
strArgs += QString::fromStdString(strprintf(" -chain=%s", gArgs.GetChainName()));
|
||||
|
||||
// Set the path to the shortcut target
|
||||
psl->SetPath(pszExePath);
|
||||
|
@ -683,7 +683,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
|||
optionFile << "Name=Bitcoin\n";
|
||||
else
|
||||
optionFile << strprintf("Name=Bitcoin (%s)\n", chain);
|
||||
optionFile << "Exec=" << pszExePath << strprintf(" -min -testnet=%d -regtest=%d\n", gArgs.GetBoolArg("-testnet", false), gArgs.GetBoolArg("-regtest", false));
|
||||
optionFile << "Exec=" << pszExePath << strprintf(" -min -chain=%s\n", chain);
|
||||
optionFile << "Terminal=false\n";
|
||||
optionFile << "Hidden=false\n";
|
||||
optionFile.close();
|
||||
|
|
|
@ -913,7 +913,7 @@ BOOST_FIXTURE_TEST_CASE(util_ChainMerge, ChainMergeTestingSetup)
|
|||
// Results file is formatted like:
|
||||
//
|
||||
// <input> || <output>
|
||||
BOOST_CHECK_EQUAL(out_sha_hex, "b284f4b4a15dd6bf8c06213a69a004b1960388e1d9917173927db52ac220927f");
|
||||
BOOST_CHECK_EQUAL(out_sha_hex, "94b4ad55c8ac639a56b93e36f7e32e4c611fd7d7dd7b2be6a71707b1eadcaec7");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(util_FormatMoney)
|
||||
|
|
|
@ -954,16 +954,18 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
|||
std::string ArgsManager::GetChainName() const
|
||||
{
|
||||
LOCK(cs_args);
|
||||
bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest");
|
||||
bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet");
|
||||
const bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest");
|
||||
const bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet");
|
||||
const bool is_chain_arg_set = IsArgSet("-chain");
|
||||
|
||||
if (fTestNet && fRegTest)
|
||||
throw std::runtime_error("Invalid combination of -regtest and -testnet.");
|
||||
if ((int)is_chain_arg_set + (int)fRegTest + (int)fTestNet > 1) {
|
||||
throw std::runtime_error("Invalid combination of -regtest, -testnet and -chain. Can use at most one.");
|
||||
}
|
||||
if (fRegTest)
|
||||
return CBaseChainParams::REGTEST;
|
||||
if (fTestNet)
|
||||
return CBaseChainParams::TESTNET;
|
||||
return CBaseChainParams::MAIN;
|
||||
return GetArg("-chain", CBaseChainParams::MAIN);
|
||||
}
|
||||
|
||||
bool RenameOver(fs::path src, fs::path dest)
|
||||
|
|
Loading…
Add table
Reference in a new issue