mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #16680: Preparations for more testchains
3bf9d8cac09fc88727ef2f2a2bea33b90b625e50 Testchains: Qt: Simplify network/chain styles (Jorge Timón) 052c54ecb02695e5d2694e8e0cbf5ccc89de86e8 Testchains: Generic selection with -chain=<str> in addition of -testnet and -regtest (Jorge Timón) Pull request description: Separated from #8994 as suggested by MarcoFalke and Sjors in https://github.com/bitcoin/bitcoin/pull/8994#issuecomment-522555390 You can't really test the qt changes on their own, so to test them, use #8994 . ACKs for top commit: MarcoFalke: ACK 3bf9d8cac09fc88727ef2f2a2bea33b90b625e50 Tree-SHA512: 5b5e6083ebc0a44505a507fac633e7af18037c85e5e73f5d1e6f7e730575d3297ba8a31d1c2441df623b273f061c32d8fa324f4aa6bead01d23e88582029b568
This commit is contained in:
parent
a778ddd62f
commit
d5d3c3e35d
@ -148,7 +148,7 @@ static int AppInitRPC(int argc, char* argv[])
|
||||
tfm::format(std::cerr, "Error reading configuration file: %s\n", error);
|
||||
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 true;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
@ -88,7 +88,7 @@ static bool AppInit(int argc, char* argv[])
|
||||
if (!args.ReadConfigFiles(error, true)) {
|
||||
return InitError(Untranslated(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(args.GetChainName());
|
||||
} catch (const std::exception& e) {
|
||||
|
@ -32,9 +32,10 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
|
||||
argsman.AddArg("-llmqtestinstantsendparams=<size>:<threshold>", "Override the default LLMQ size for the LLMQ_TEST_INSTANTSEND quorums (default: 3:2, regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
|
||||
argsman.AddArg("-powtargetspacing=<n>", "Override the default PowTargetSpacing value in seconds (default: 2.5 minutes, devnet-only)", ArgsManager::ALLOW_INT, OptionsCategory::CHAINPARAMS);
|
||||
argsman.AddArg("-minimumdifficultyblocks=<n>", "The number of blocks that can be mined with the minimum difficulty at the start of a chain (default: 0, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
argsman.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);
|
||||
argsman.AddArg("-testnet", "Use the test chain", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
"This is intended for regression testing tools and app development. Equivalent to -chain=regtest", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
|
||||
argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
argsman.AddArg("-vbparams=<deployment>:<start>:<end>(:<window>:<threshold/thresholdstart>(:<thresholdmin>:<falloffcoeff>))",
|
||||
"Use given start/end times for specified version bits deployment (regtest-only). "
|
||||
"Specifying window, threshold/thresholdstart, thresholdmin and falloffcoeff is optional.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
|
||||
|
@ -541,7 +541,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) {
|
||||
@ -559,7 +559,7 @@ int GuiMain(int argc, char* argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(QString::fromStdString(Params().NetworkIDString())));
|
||||
QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(Params().NetworkIDString()));
|
||||
assert(!networkStyle.isNull());
|
||||
// Allow for separate UI settings for testnets
|
||||
// QApplication::setApplicationName(networkStyle->getAppName()); // moved to NetworkStyle::NetworkStyle
|
||||
|
@ -838,7 +838,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);
|
||||
@ -933,7 +933,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||
optionFile << "Name=Dash Core\n";
|
||||
else
|
||||
optionFile << strprintf("Name=Dash Core (%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();
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <tinyformat.h>
|
||||
#include <util/system.h>
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
static const struct {
|
||||
@ -22,9 +24,9 @@ static const struct {
|
||||
const std::string titleAddText;
|
||||
} network_styles[] = {
|
||||
{"main", QAPP_APP_NAME_DEFAULT, 0, 0, ""},
|
||||
{"test", QAPP_APP_NAME_TESTNET, 190, 20, QT_TRANSLATE_NOOP("SplashScreen", "[testnet]")},
|
||||
{"test", QAPP_APP_NAME_TESTNET, 190, 20},
|
||||
{"devnet", QAPP_APP_NAME_DEVNET, 190, 20, "[devnet: %s]"},
|
||||
{"regtest", QAPP_APP_NAME_REGTEST, 160, 30, "[regtest]"}
|
||||
{"regtest", QAPP_APP_NAME_REGTEST, 160, 30}
|
||||
};
|
||||
|
||||
void NetworkStyle::rotateColor(QColor& col, const int iconColorHueShift, const int iconColorSaturationReduction)
|
||||
@ -86,8 +88,9 @@ NetworkStyle::NetworkStyle(const QString &_appName, const int iconColorHueShift,
|
||||
splashImage = QPixmap(":/images/splash");
|
||||
}
|
||||
|
||||
const NetworkStyle *NetworkStyle::instantiate(const QString &networkId)
|
||||
const NetworkStyle* NetworkStyle::instantiate(const std::string& networkId)
|
||||
{
|
||||
std::string titleAddText = networkId == CBaseChainParams::MAIN ? "" : strprintf("[%s]", networkId);
|
||||
for (const auto& network_style : network_styles)
|
||||
{
|
||||
if (networkId == network_style.networkId)
|
||||
@ -95,7 +98,7 @@ const NetworkStyle *NetworkStyle::instantiate(const QString &networkId)
|
||||
std::string appName = network_style.appName;
|
||||
std::string titleAddText = network_style.titleAddText;
|
||||
|
||||
if (networkId == QString(CBaseChainParams::DEVNET.c_str())) {
|
||||
if (networkId == CBaseChainParams::DEVNET.c_str()) {
|
||||
appName = strprintf(appName, gArgs.GetDevNetName());
|
||||
titleAddText = strprintf(titleAddText, gArgs.GetDevNetName());
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class NetworkStyle
|
||||
{
|
||||
public:
|
||||
/** Get style associated with provided network id, or 0 if not known */
|
||||
static const NetworkStyle *instantiate(const QString &networkId);
|
||||
static const NetworkStyle* instantiate(const std::string& networkId);
|
||||
|
||||
const QString &getAppName() const { return appName; }
|
||||
const QIcon &getAppIcon() const { return appIcon; }
|
||||
|
@ -73,7 +73,7 @@ void AppTests::appTests()
|
||||
GUIUtil::loadFonts();
|
||||
m_app.createOptionsModel(true /* reset settings */);
|
||||
QScopedPointer<const NetworkStyle> style(
|
||||
NetworkStyle::instantiate(QString::fromStdString(Params().NetworkIDString())));
|
||||
NetworkStyle::instantiate(Params().NetworkIDString()));
|
||||
m_app.createWindow(style.data());
|
||||
connect(&m_app, &BitcoinApplication::windowShown, this, &AppTests::guiTests);
|
||||
expectCallback("guiTests");
|
||||
|
@ -1135,7 +1135,7 @@ BOOST_FIXTURE_TEST_CASE(util_ChainMerge, ChainMergeTestingSetup)
|
||||
// Results file is formatted like:
|
||||
//
|
||||
// <input> || <output>
|
||||
BOOST_CHECK_EQUAL(out_sha_hex, "f8cff01ad967dfc82cf71208aa2b60f01a0aa621c28356af5ca91d1d7370c217");
|
||||
BOOST_CHECK_EQUAL(out_sha_hex, "1cd2697d1665d086f15ed18b3333bc356c3d39ba490589dc58afd8fc2f457731");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(util_ReadWriteSettings)
|
||||
|
@ -976,10 +976,11 @@ std::string ArgsManager::GetChainName() const
|
||||
const bool fRegTest = get_net("-regtest");
|
||||
const bool fTestNet = get_net("-testnet");
|
||||
const bool fDevNet = get_net("-devnet", false);
|
||||
const bool is_chain_arg_set = IsArgSet("-chain");
|
||||
|
||||
int nameParamsCount = (fRegTest ? 1 : 0) + (fDevNet ? 1 : 0) + (fTestNet ? 1 : 0);
|
||||
int nameParamsCount = (fRegTest ? 1 : 0) + (fDevNet ? 1 : 0) + (fTestNet ? 1 : 0) + (is_chain_arg_set ? 1 : 0);
|
||||
if (nameParamsCount > 1)
|
||||
throw std::runtime_error("Only one of -regtest, -testnet or -devnet can be used.");
|
||||
throw std::runtime_error("Only one of -regtest, -testnet, -devnet or -chain can be used.");
|
||||
|
||||
if (fDevNet)
|
||||
return CBaseChainParams::DEVNET;
|
||||
@ -987,7 +988,7 @@ std::string ArgsManager::GetChainName() const
|
||||
return CBaseChainParams::REGTEST;
|
||||
if (fTestNet)
|
||||
return CBaseChainParams::TESTNET;
|
||||
return CBaseChainParams::MAIN;
|
||||
return GetArg("-chain", CBaseChainParams::MAIN);
|
||||
}
|
||||
|
||||
std::string ArgsManager::GetDevNetName() const
|
||||
|
Loading…
Reference in New Issue
Block a user