mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-21 06:12:30 +02:00
test: Reject + sign when parsing regtest deployment params
The + sign does not make sense for times or heights.
This commit is contained in:
parent
fa123afa0e
commit
fafd43c691
@ -53,14 +53,14 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto value{arg.substr(found + 1)};
|
const auto value{arg.substr(found + 1)};
|
||||||
int32_t height;
|
const auto height{ToIntegral<int32_t>(value)};
|
||||||
if (!ParseInt32(value, &height) || height < 0 || height >= std::numeric_limits<int>::max()) {
|
if (!height || *height < 0 || *height >= std::numeric_limits<int>::max()) {
|
||||||
throw std::runtime_error(strprintf("Invalid height value (%s) for -testactivationheight=name@height.", arg));
|
throw std::runtime_error(strprintf("Invalid height value (%s) for -testactivationheight=name@height.", arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto deployment_name{arg.substr(0, found)};
|
const auto deployment_name{arg.substr(0, found)};
|
||||||
if (const auto buried_deployment = GetBuriedDeployment(deployment_name)) {
|
if (const auto buried_deployment = GetBuriedDeployment(deployment_name)) {
|
||||||
options.activation_heights[*buried_deployment] = height;
|
options.activation_heights[*buried_deployment] = *height;
|
||||||
} else {
|
} else {
|
||||||
throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg));
|
throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg));
|
||||||
}
|
}
|
||||||
@ -72,16 +72,22 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
|
|||||||
throw std::runtime_error("Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]");
|
throw std::runtime_error("Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]");
|
||||||
}
|
}
|
||||||
CChainParams::VersionBitsParameters vbparams{};
|
CChainParams::VersionBitsParameters vbparams{};
|
||||||
if (!ParseInt64(vDeploymentParams[1], &vbparams.start_time)) {
|
const auto start_time{ToIntegral<int64_t>(vDeploymentParams[1])};
|
||||||
|
if (!start_time) {
|
||||||
throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1]));
|
throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1]));
|
||||||
}
|
}
|
||||||
if (!ParseInt64(vDeploymentParams[2], &vbparams.timeout)) {
|
vbparams.start_time = *start_time;
|
||||||
|
const auto timeout{ToIntegral<int64_t>(vDeploymentParams[2])};
|
||||||
|
if (!timeout) {
|
||||||
throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2]));
|
throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2]));
|
||||||
}
|
}
|
||||||
|
vbparams.timeout = *timeout;
|
||||||
if (vDeploymentParams.size() >= 4) {
|
if (vDeploymentParams.size() >= 4) {
|
||||||
if (!ParseInt32(vDeploymentParams[3], &vbparams.min_activation_height)) {
|
const auto min_activation_height{ToIntegral<int64_t>(vDeploymentParams[3])};
|
||||||
|
if (!min_activation_height) {
|
||||||
throw std::runtime_error(strprintf("Invalid min_activation_height (%s)", vDeploymentParams[3]));
|
throw std::runtime_error(strprintf("Invalid min_activation_height (%s)", vDeploymentParams[3]));
|
||||||
}
|
}
|
||||||
|
vbparams.min_activation_height = *min_activation_height;
|
||||||
} else {
|
} else {
|
||||||
vbparams.min_activation_height = 0;
|
vbparams.min_activation_height = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user