aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/versionbits.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-03-27 23:00:14 +1000
committerAndrew Chow <achow101-github@achow101.com>2021-04-15 20:59:13 -0400
commit3acf0379e0979ea4bdd03976f4987aa6711eb92f (patch)
tree03f6ae026ba46234871db7ba08f789d67f60620d /src/test/fuzz/versionbits.cpp
parentb529222ad18f7facbaff394455875b4aa65d653e (diff)
versionbits: Add explicit NEVER_ACTIVE deployments
Previously we used deployments that would timeout prior to Bitcoin's invention, which allowed the deployment to still be activated in unit tests. This switches those deployments to be truly never active. Github-Pull: #21377 Rebased-From: 55ac5f568a3b73d6f1ef4654617fb76e8bcbccdf
Diffstat (limited to 'src/test/fuzz/versionbits.cpp')
-rw-r--r--src/test/fuzz/versionbits.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/test/fuzz/versionbits.cpp b/src/test/fuzz/versionbits.cpp
index 220e29ab04..5d859c911c 100644
--- a/src/test/fuzz/versionbits.cpp
+++ b/src/test/fuzz/versionbits.cpp
@@ -160,13 +160,12 @@ void test_one_input(const std::vector<uint8_t>& buffer)
} else {
if (fuzzed_data_provider.ConsumeBool()) {
start_time = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
- timeout = Consensus::BIP9Deployment::NO_TIMEOUT;
always_active_test = true;
} else {
- start_time = 1199145601; // January 1, 2008
- timeout = 1230767999; // December 31, 2008
+ start_time = Consensus::BIP9Deployment::NEVER_ACTIVE;
never_active_test = true;
}
+ timeout = fuzzed_data_provider.ConsumeBool() ? Consensus::BIP9Deployment::NO_TIMEOUT : fuzzed_data_provider.ConsumeIntegral<int64_t>();
}
int min_activation = fuzzed_data_provider.ConsumeIntegralInRange<int>(0, period * max_periods);
@@ -318,7 +317,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
assert(exp_state == ThresholdState::ACTIVE || exp_state == ThresholdState::LOCKED_IN);
break;
case ThresholdState::FAILED:
- assert(current_block->GetMedianTimePast() >= checker.m_end);
+ assert(never_active_test || current_block->GetMedianTimePast() >= checker.m_end);
assert(exp_state != ThresholdState::LOCKED_IN && exp_state != ThresholdState::ACTIVE);
break;
default:
@@ -330,25 +329,19 @@ void test_one_input(const std::vector<uint8_t>& buffer)
assert(state == ThresholdState::ACTIVE || state == ThresholdState::FAILED);
}
- // "always active" has additional restrictions
if (always_active_test) {
+ // "always active" has additional restrictions
assert(state == ThresholdState::ACTIVE);
assert(exp_state == ThresholdState::ACTIVE);
assert(since == 0);
+ } else if (never_active_test) {
+ // "never active" does too
+ assert(state == ThresholdState::FAILED);
+ assert(exp_state == ThresholdState::FAILED);
+ assert(since == 0);
} else {
- // except for always active, the initial state is always DEFINED
+ // for signalled deployments, the initial state is always DEFINED
assert(since > 0 || state == ThresholdState::DEFINED);
assert(exp_since > 0 || exp_state == ThresholdState::DEFINED);
}
-
- // "never active" does too
- if (never_active_test) {
- assert(state == ThresholdState::FAILED);
- assert(since == period);
- if (exp_since == 0) {
- assert(exp_state == ThresholdState::DEFINED);
- } else {
- assert(exp_state == ThresholdState::FAILED);
- }
- }
}