diff options
author | Anthony Towns <aj@erisian.com.au> | 2021-11-12 07:14:21 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2022-01-15 04:37:56 +1000 |
commit | 240cad09baefcf363cce36a4b2795122adfce27f (patch) | |
tree | 3ca74e49bb15731b8649405d1060367d425b6696 /src/test | |
parent | 376c0c6dae2bebbb3e1352377e71fb1996d09f64 (diff) | |
download | bitcoin-240cad09baefcf363cce36a4b2795122adfce27f.tar.xz |
rpc: getdeploymentinfo: include signalling info
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/versionbits.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/test/fuzz/versionbits.cpp b/src/test/fuzz/versionbits.cpp index 890267db18..95eb71099d 100644 --- a/src/test/fuzz/versionbits.cpp +++ b/src/test/fuzz/versionbits.cpp @@ -51,7 +51,7 @@ public: ThresholdState GetStateFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateFor(pindexPrev, dummy_params, m_cache); } int GetStateSinceHeightFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateSinceHeightFor(pindexPrev, dummy_params, m_cache); } - BIP9Stats GetStateStatisticsFor(const CBlockIndex* pindex) const { return AbstractThresholdConditionChecker::GetStateStatisticsFor(pindex, dummy_params); } + BIP9Stats GetStateStatisticsFor(const CBlockIndex* pindex, std::vector<bool>* signals=nullptr) const { return AbstractThresholdConditionChecker::GetStateStatisticsFor(pindex, dummy_params, signals); } bool Condition(int32_t version) const { @@ -227,6 +227,7 @@ FUZZ_TARGET_INIT(versionbits, initialize) last_stats.threshold = threshold; last_stats.count = last_stats.elapsed = 0; last_stats.possible = (period >= threshold); + std::vector<bool> last_signals{}; int prev_next_height = (prev == nullptr ? 0 : prev->nHeight + 1); assert(exp_since <= prev_next_height); @@ -248,13 +249,24 @@ FUZZ_TARGET_INIT(versionbits, initialize) assert(since == exp_since); // check that after mining this block stats change as expected - const BIP9Stats stats = checker.GetStateStatisticsFor(current_block); + std::vector<bool> signals; + const BIP9Stats stats = checker.GetStateStatisticsFor(current_block, &signals); + const BIP9Stats stats_no_signals = checker.GetStateStatisticsFor(current_block); + assert(stats.period == stats_no_signals.period && stats.threshold == stats_no_signals.threshold + && stats.elapsed == stats_no_signals.elapsed && stats.count == stats_no_signals.count + && stats.possible == stats_no_signals.possible); + assert(stats.period == period); assert(stats.threshold == threshold); assert(stats.elapsed == b); assert(stats.count == last_stats.count + (signal ? 1 : 0)); assert(stats.possible == (stats.count + period >= stats.elapsed + threshold)); last_stats = stats; + + assert(signals.size() == last_signals.size() + 1); + assert(signals.back() == signal); + last_signals.push_back(signal); + assert(signals == last_signals); } if (exp_state == ThresholdState::STARTED) { |