mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 03:33:32 +01:00
qa: Increase includeconf test coverage
This commit is contained in:
20
src/util.cpp
20
src/util.cpp
@@ -459,9 +459,9 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
||||
if (it != m_override_args.end()) {
|
||||
if (it->second.size() > 0) {
|
||||
for (const auto& ic : it->second) {
|
||||
fprintf(stderr, "warning: -includeconf cannot be used from commandline; ignoring -includeconf=%s\n", ic.c_str());
|
||||
error += "-includeconf cannot be used from commandline; -includeconf=" + ic + "\n";
|
||||
}
|
||||
m_override_args.erase(it);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -849,11 +849,12 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||
// if there is an -includeconf in the override args, but it is empty, that means the user
|
||||
// passed '-noincludeconf' on the command line, in which case we should not include anything
|
||||
if (m_override_args.count("-includeconf") == 0) {
|
||||
std::string chain_id = GetChainName();
|
||||
std::vector<std::string> includeconf(GetArgs("-includeconf"));
|
||||
{
|
||||
// We haven't set m_network yet (that happens in SelectParams()), so manually check
|
||||
// for network.includeconf args.
|
||||
std::vector<std::string> includeconf_net(GetArgs(std::string("-") + GetChainName() + ".includeconf"));
|
||||
std::vector<std::string> includeconf_net(GetArgs(std::string("-") + chain_id + ".includeconf"));
|
||||
includeconf.insert(includeconf.end(), includeconf_net.begin(), includeconf_net.end());
|
||||
}
|
||||
|
||||
@@ -862,7 +863,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||
{
|
||||
LOCK(cs_args);
|
||||
m_config_args.erase("-includeconf");
|
||||
m_config_args.erase(std::string("-") + GetChainName() + ".includeconf");
|
||||
m_config_args.erase(std::string("-") + chain_id + ".includeconf");
|
||||
}
|
||||
|
||||
for (const std::string& to_include : includeconf) {
|
||||
@@ -873,15 +874,22 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||
}
|
||||
LogPrintf("Included configuration file %s\n", to_include.c_str());
|
||||
} else {
|
||||
fprintf(stderr, "Failed to include configuration file %s\n", to_include.c_str());
|
||||
error = "Failed to include configuration file " + to_include;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Warn about recursive -includeconf
|
||||
includeconf = GetArgs("-includeconf");
|
||||
{
|
||||
std::vector<std::string> includeconf_net(GetArgs(std::string("-") + GetChainName() + ".includeconf"));
|
||||
std::vector<std::string> includeconf_net(GetArgs(std::string("-") + chain_id + ".includeconf"));
|
||||
includeconf.insert(includeconf.end(), includeconf_net.begin(), includeconf_net.end());
|
||||
std::string chain_id_final = GetChainName();
|
||||
if (chain_id_final != chain_id) {
|
||||
// Also warn about recursive includeconf for the chain that was specified in one of the includeconfs
|
||||
includeconf_net = GetArgs(std::string("-") + chain_id_final + ".includeconf");
|
||||
includeconf.insert(includeconf.end(), includeconf_net.begin(), includeconf_net.end());
|
||||
}
|
||||
}
|
||||
for (const std::string& to_include : includeconf) {
|
||||
fprintf(stderr, "warning: -includeconf cannot be used from included files; ignoring -includeconf=%s\n", to_include.c_str());
|
||||
|
||||
Reference in New Issue
Block a user