aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-04-07 10:20:46 +1000
committerAndrew Chow <achow101-github@achow101.com>2021-04-15 20:59:17 -0400
commit600357306e2e182a457174862ea2e41c7ba39c64 (patch)
tree693bb010f1d57671469e536456356d3149de8d64 /src/test/fuzz
parent3acf0379e0979ea4bdd03976f4987aa6711eb92f (diff)
downloadbitcoin-600357306e2e182a457174862ea2e41c7ba39c64.tar.xz
versionbits: simplify state transitions
This removes the DEFINED->FAILED transition and changes the STARTED->FAILED transition to only occur if signalling didn't pass the threshold. This ensures that it is always possible for activation to occur, no matter what settings are chosen, or the speed at which blocks are found. Github-Pull: #21377 Rebased-From: f054f6bcd2c2ce5fea84cf8681013f85a444e7ea
Diffstat (limited to 'src/test/fuzz')
-rw-r--r--src/test/fuzz/versionbits.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/test/fuzz/versionbits.cpp b/src/test/fuzz/versionbits.cpp
index 5d859c911c..645c0d23c0 100644
--- a/src/test/fuzz/versionbits.cpp
+++ b/src/test/fuzz/versionbits.cpp
@@ -144,19 +144,14 @@ void test_one_input(const std::vector<uint8_t>& buffer)
// pick the timestamp to switch based on a block
// note states will change *after* these blocks because mediantime lags
int start_block = fuzzed_data_provider.ConsumeIntegralInRange<int>(0, period * (max_periods - 3));
- int end_block = fuzzed_data_provider.ConsumeIntegralInRange<int>(start_block, period * (max_periods - 3));
+ int end_block = fuzzed_data_provider.ConsumeIntegralInRange<int>(0, period * (max_periods - 3));
start_time = block_start_time + start_block * interval;
timeout = block_start_time + end_block * interval;
- assert(start_time <= timeout);
-
// allow for times to not exactly match a block
if (fuzzed_data_provider.ConsumeBool()) start_time += interval / 2;
if (fuzzed_data_provider.ConsumeBool()) timeout += interval / 2;
-
- // this may make timeout too early; if so, don't run the test
- if (start_time > timeout) return;
} else {
if (fuzzed_data_provider.ConsumeBool()) {
start_time = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
@@ -292,13 +287,12 @@ void test_one_input(const std::vector<uint8_t>& buffer)
assert(since == 0);
assert(exp_state == ThresholdState::DEFINED);
assert(current_block->GetMedianTimePast() < checker.m_begin);
- assert(current_block->GetMedianTimePast() < checker.m_end);
break;
case ThresholdState::STARTED:
assert(current_block->GetMedianTimePast() >= checker.m_begin);
- assert(current_block->GetMedianTimePast() < checker.m_end);
if (exp_state == ThresholdState::STARTED) {
assert(blocks_sig < threshold);
+ assert(current_block->GetMedianTimePast() < checker.m_end);
} else {
assert(exp_state == ThresholdState::DEFINED);
}
@@ -308,7 +302,6 @@ void test_one_input(const std::vector<uint8_t>& buffer)
assert(current_block->nHeight + 1 < min_activation);
} else {
assert(exp_state == ThresholdState::STARTED);
- assert(current_block->GetMedianTimePast() < checker.m_end);
assert(blocks_sig >= threshold);
}
break;
@@ -318,7 +311,11 @@ void test_one_input(const std::vector<uint8_t>& buffer)
break;
case ThresholdState::FAILED:
assert(never_active_test || current_block->GetMedianTimePast() >= checker.m_end);
- assert(exp_state != ThresholdState::LOCKED_IN && exp_state != ThresholdState::ACTIVE);
+ if (exp_state == ThresholdState::STARTED) {
+ assert(blocks_sig < threshold);
+ } else {
+ assert(exp_state == ThresholdState::FAILED);
+ }
break;
default:
assert(false);