Skip to main content

foundry_evm/executors/invariant/
error.rs

1use super::{
2    InvariantContract,
3    shrink::{
4        CheckSequenceFailureSite, TerminalFailureSite, sequence_call_failure_site,
5        terminal_failure_site,
6    },
7};
8use crate::{
9    executors::{RawCallResult, RawFailure},
10    inspectors::{EdgeCovHit, EdgeCoverage},
11};
12use alloy_json_abi::Function;
13use alloy_primitives::{Address, B256, Bytes, Selector, keccak256};
14use foundry_config::InvariantConfig;
15use foundry_evm_core::{
16    decode::{ASSERTION_FAILED_PREFIX, EMPTY_REVERT_DATA, RevertDecoder},
17    evm::FoundryEvmNetwork,
18};
19use foundry_evm_fuzz::{BasicTxDetails, Reason, invariant::FuzzRunIdentifiedContracts};
20use proptest::test_runner::TestError;
21use std::{collections::HashMap, fmt};
22
23/// A handler-side assertion bug: a `require`/`assert` inside a fuzzed handler that the
24/// campaign reached. Deduped by `(reverter, selector)` site (Echidna/Medusa semantics),
25/// shortest sequence wins on collision.
26#[derive(Clone, Debug)]
27pub struct HandlerAssertionFailure {
28    /// Handler contract whose call asserted.
29    pub reverter: Address,
30    /// 4-byte selector of the failing function.
31    pub selector: Selector,
32    /// Call sequence including the failing call (post-shrink: minimal prefix).
33    pub call_sequence: Vec<BasicTxDetails>,
34    /// Pre-shrink length, for the `(original: N, shrunk: M)` renderer.
35    pub original_sequence_len: usize,
36    /// Decoded revert/assert reason.
37    pub revert_reason: String,
38    /// Active fork block when the handler assertion failed, if any.
39    pub fork_block_number: Option<u64>,
40    /// Stable hash of edge coverage at the asserting call (falls back to `(reverter,
41    /// selector)`). Used by the shrinker to preserve path identity, not for dedup.
42    pub edge_fingerprint: B256,
43}
44
45impl HandlerAssertionFailure {
46    /// Builds a failure from a replayed sequence whose last call asserted.
47    pub const fn from_replayed_sequence(
48        call_sequence: Vec<BasicTxDetails>,
49        reverter: Address,
50        selector: Selector,
51        edge_fingerprint: B256,
52        revert_reason: String,
53    ) -> Self {
54        let original_sequence_len = call_sequence.len();
55        Self {
56            reverter,
57            selector,
58            call_sequence,
59            original_sequence_len,
60            revert_reason,
61            fork_block_number: None,
62            edge_fingerprint,
63        }
64    }
65}
66
67/// Run-scoped references shared by failure-recording paths in an invariant run.
68pub struct InvariantRunCtx<'a> {
69    /// The invariant test contract.
70    pub contract: &'a InvariantContract<'a>,
71    /// Active invariant configuration.
72    pub config: &'a InvariantConfig,
73    /// Fuzz targets discovered for this run.
74    pub targeted_contracts: &'a FuzzRunIdentifiedContracts,
75    /// Inputs of the current run, used as the failing call sequence.
76    pub calldata: &'a [BasicTxDetails],
77}
78
79impl<'a> InvariantRunCtx<'a> {
80    /// Builds a [`FailedInvariantCaseData`] attributed to `broken_fn`. `fail_on_revert` is
81    /// passed in because `assert_invariants` overrides it with the per-invariant flag.
82    /// `assertion_failure=true` normalizes empty revert data so output is not blank.
83    /// `terminal_site` identifies a predicate or hook call; `None` identifies the last handler.
84    pub(super) fn failed_case<FEN: FoundryEvmNetwork>(
85        &self,
86        broken_fn: &Function,
87        fail_on_revert: bool,
88        assertion_failure: bool,
89        call_result: RawCallResult<FEN>,
90        inner_sequence: &[Option<BasicTxDetails>],
91        terminal_site: Option<TerminalFailureSite>,
92    ) -> FailedInvariantCaseData {
93        let revert_reason = self.decode_revert_reason(&call_result, assertion_failure);
94        let site = if let Some(terminal_site) = terminal_site {
95            Some(terminal_failure_site(
96                terminal_site,
97                self.contract.address,
98                &broken_fn.selector().into(),
99                &call_result,
100            ))
101        } else {
102            self.calldata.last().map(|call| sequence_call_failure_site(call, &call_result))
103        };
104        let campaign_failure = site.zip(call_result.raw_failure());
105        let origin = broken_fn.name.as_str();
106        FailedInvariantCaseData {
107            test_error: TestError::Fail(
108                format!("{origin}, reason: {revert_reason}").into(),
109                self.calldata.to_vec(),
110            ),
111            return_reason: "".into(),
112            revert_reason,
113            addr: self.contract.address,
114            calldata: broken_fn.selector().into(),
115            inner_sequence: inner_sequence.to_vec(),
116            shrink_run_limit: self.config.shrink_run_limit,
117            fail_on_revert,
118            assertion_failure,
119            fork_block_number: call_result.fork_block_number,
120            campaign_failure,
121            after_invariant: false,
122            unchecked_invariants: Vec::new(),
123        }
124    }
125
126    /// Decodes the revert/assert reason without allocating a full [`FailedInvariantCaseData`].
127    /// Used by callers that only need the reason (e.g. handler-bug recording). A failed
128    /// `vm.assert*` reports its own message when it caused the failure, since the revert data may
129    /// come from a later revert.
130    pub fn decode_revert_reason<FEN: FoundryEvmNetwork>(
131        &self,
132        call_result: &RawCallResult<FEN>,
133        assertion_failure: bool,
134    ) -> String {
135        if (assertion_failure || !call_result.reverted)
136            && let Some(message) = &call_result.failed_assertion
137        {
138            return message.clone();
139        }
140        let revert_reason = RevertDecoder::new()
141            .with_abis(self.targeted_contracts.targets().values().map(|c| &c.abi))
142            .with_abi(self.contract.abi)
143            .decode(call_result.result.as_ref(), call_result.exit_reason);
144        // Non-reverting assertion failures surface through Foundry's failure flags, not
145        // revert data — fall back so invariant output is not blank.
146        let needs_fallback = matches!(revert_reason.as_str(), "" | EMPTY_REVERT_DATA);
147        if needs_fallback && (!call_result.reverted || assertion_failure) {
148            ASSERTION_FAILED_PREFIX.to_string()
149        } else {
150            revert_reason
151        }
152    }
153}
154
155/// Edge-coverage fingerprint for a handler-side assertion call. Prefers a pre-merge
156/// edges hash; falls back to `keccak(target || selector)` when edge coverage is disabled.
157pub fn handler_edge_fingerprint(
158    pre_merge_edges_hash: Option<B256>,
159    target: Address,
160    selector: Selector,
161) -> B256 {
162    if let Some(hash) = pre_merge_edges_hash {
163        return hash;
164    }
165    let mut buf = [0u8; 24];
166    buf[..20].copy_from_slice(target.as_slice());
167    buf[20..].copy_from_slice(selector.as_slice());
168    keccak256(buf)
169}
170
171/// Records a handler-side assertion bug (if strictly shorter than the existing repro for
172/// this site) and pops the just-asserted reverted input from `inputs`.
173#[expect(clippy::too_many_arguments)]
174pub(crate) fn record_handler_assertion_bug<FEN: FoundryEvmNetwork>(
175    invariant_contract: &InvariantContract<'_>,
176    config: &InvariantConfig,
177    targeted_contracts: &FuzzRunIdentifiedContracts,
178    failures: &mut InvariantFailures,
179    inputs: &mut Vec<BasicTxDetails>,
180    handler_target: Address,
181    handler_selector: Selector,
182    pre_merge_edges_hash: Option<B256>,
183    call_result: RawCallResult<FEN>,
184    call_reverted: bool,
185    is_optimization: bool,
186) {
187    let fingerprint =
188        handler_edge_fingerprint(pre_merge_edges_hash, handler_target, handler_selector);
189
190    if !handler_site_already_minimal(
191        &failures.failures,
192        (handler_target, handler_selector),
193        inputs.len(),
194    ) {
195        // Handler bugs go through `FailureKey::Handler`; we only need the reason.
196        let revert_reason = InvariantRunCtx {
197            contract: invariant_contract,
198            config,
199            targeted_contracts,
200            calldata: inputs,
201        }
202        .decode_revert_reason(&call_result, true);
203        let call_sequence = inputs.clone();
204        let original_sequence_len = call_sequence.len();
205        failures.record_handler_failure(HandlerAssertionFailure {
206            reverter: handler_target,
207            selector: handler_selector,
208            call_sequence,
209            original_sequence_len,
210            revert_reason,
211            fork_block_number: call_result.fork_block_number,
212            edge_fingerprint: fingerprint,
213        });
214    }
215
216    // Standard reverted-input pop. Delay-enabled campaigns keep reverted calls so their warp/roll
217    // contribution can be replayed.
218    if call_reverted && !is_optimization && !config.has_delay() {
219        inputs.pop();
220    }
221}
222
223/// True iff there is already a [`HandlerAssertionFailure`] for `site` no longer than
224/// `candidate_len`. Used to skip inserting a not-strictly-shorter repro.
225pub fn handler_site_already_minimal(
226    failures: &HashMap<FailureKey, InvariantFuzzError>,
227    site: (Address, Selector),
228    candidate_len: usize,
229) -> bool {
230    failures
231        .get(&FailureKey::Handler(site.0, site.1))
232        .and_then(InvariantFuzzError::as_handler_assertion)
233        .is_some_and(|existing| existing.call_sequence.len() <= candidate_len)
234}
235
236/// Stable hash of the call's edge coverage, taken *before* `merge_edge_coverage`
237/// zeroes the buffer. Returns `None` when edge coverage is disabled.
238pub fn snapshot_edge_fingerprint<FEN: FoundryEvmNetwork>(
239    call_result: &RawCallResult<FEN>,
240) -> Option<B256> {
241    let edges = call_result.edge_coverage.as_ref()?;
242    if edges.is_empty() {
243        return None;
244    }
245    match edges {
246        EdgeCoverage::Hash(edges) => Some(keccak256(edges)),
247        EdgeCoverage::Instrumented(hits) => {
248            // Hits are in first-hit order; sort for a fingerprint independent of it.
249            let mut sorted = hits.clone();
250            sorted.sort_unstable();
251            let mut bytes = Vec::with_capacity(sorted.len() * 5);
252            for hit in sorted {
253                bytes.extend_from_slice(&hit.id.to_le_bytes());
254                bytes.push(hit.count);
255            }
256            Some(keccak256(bytes))
257        }
258        EdgeCoverage::CollisionFree(hits) => {
259            // `From<EdgeCovInspector>` does not sort on the per-call drain path,
260            // so sort here for a deterministic fingerprint across runs regardless
261            // of HashMap iteration order. Cold path — only invoked on handler
262            // assertion failure.
263            let mut sorted: Vec<&EdgeCovHit> = hits.iter().collect();
264            sorted.sort_unstable_by_key(|hit| hit.edge);
265
266            // address(20) + pc(8) + jump_dest(32) + depth_tag(1) + depth(8) + count(1)
267            let mut bytes = Vec::with_capacity(sorted.len() * (20 + 8 + 32 + 1 + 8 + 1));
268            for hit in sorted {
269                bytes.extend_from_slice(hit.edge.address.as_slice());
270                bytes.extend_from_slice(&hit.edge.pc.to_le_bytes());
271                bytes.extend_from_slice(&hit.edge.jump_dest.to_be_bytes::<32>());
272                // Tag byte disambiguates `None` from `Some(0)` so configs with
273                // `include_call_depth` toggled don't collide in the fingerprint.
274                bytes.push(u8::from(hit.edge.depth.is_some()));
275                bytes.extend_from_slice(&hit.edge.depth.unwrap_or(0).to_le_bytes());
276                bytes.push(hit.count);
277            }
278            Some(keccak256(bytes))
279        }
280    }
281}
282
283/// Identifies a single entry in the [`InvariantFailures`] map. Invariant predicate
284/// failures and handler-side assertion bugs share one map keyed by this enum.
285#[derive(Clone, Debug, Eq, Hash, PartialEq)]
286pub enum FailureKey {
287    /// Keyed by invariant function name.
288    Invariant(String),
289    /// Keyed by handler `(reverter, selector)` site (Echidna/Medusa semantics: one bug
290    /// per handler function regardless of code path).
291    Handler(Address, Selector),
292}
293
294/// Stores invariant test failures and revert counts.
295///
296/// TODO: dedup multiple distinct `assert(...)` within the same `(reverter, selector)`
297/// handler if callers ever need finer attribution (e.g. per-assertion-label).
298#[derive(Clone, Default)]
299pub struct InvariantFailures {
300    /// Total number of reverts.
301    pub reverts: usize,
302    /// Invariant predicate failures and handler-side assertion bugs share one map.
303    /// Mutate only via `record_failure` / `record_handler_failure` / `seed_handler_failure`
304    /// so the cached counters stay in sync.
305    pub(crate) failures: HashMap<FailureKey, InvariantFuzzError>,
306    /// Cached `FailureKey::Invariant` count, kept O(1) on the hot path.
307    invariant_count: usize,
308    /// Cached `FailureKey::Handler` count, read on progress/metrics ticks.
309    handler_count: usize,
310    /// Increments whenever a failure or its reproducer is inserted or replaced.
311    revision: usize,
312    /// Invariants that the current run does not check, see [`Self::start_run`].
313    unchecked_invariants: Vec<String>,
314}
315
316impl InvariantFailures {
317    pub fn new() -> Self {
318        Self::default()
319    }
320
321    /// Splits `self.failures` into the legacy `(invariant_errors, handler_errors)` pair.
322    pub fn partition(
323        self,
324    ) -> (HashMap<String, InvariantFuzzError>, HashMap<(Address, Selector), InvariantFuzzError>)
325    {
326        let mut invariant_errors = HashMap::new();
327        let mut handler_errors = HashMap::new();
328        for (key, err) in self.failures {
329            match key {
330                FailureKey::Invariant(name) => {
331                    invariant_errors.insert(name, err);
332                }
333                FailureKey::Handler(addr, sel) => {
334                    handler_errors.insert((addr, sel), err);
335                }
336            }
337        }
338        (invariant_errors, handler_errors)
339    }
340
341    /// Returns the names of the invariants broken so far.
342    pub fn broken_invariants(&self) -> Vec<String> {
343        self.failures
344            .keys()
345            .filter_map(|key| match key {
346                FailureKey::Invariant(name) => Some(name.clone()),
347                FailureKey::Handler(..) => None,
348            })
349            .collect()
350    }
351
352    /// Sets the invariants not checked after any call of the run starting now; failures it records
353    /// carry them.
354    pub fn start_run(&mut self, unchecked_invariants: Vec<String>) {
355        self.unchecked_invariants = unchecked_invariants;
356    }
357
358    pub fn record_failure(&mut self, invariant: &Function, mut failure: InvariantFuzzError) {
359        if let InvariantFuzzError::BrokenInvariant(case) | InvariantFuzzError::Revert(case) =
360            &mut failure
361        {
362            case.unchecked_invariants.clone_from(&self.unchecked_invariants);
363        }
364        let prev = self.failures.insert(FailureKey::Invariant(invariant.name.clone()), failure);
365        self.revision = self.revision.wrapping_add(1);
366        if prev.is_none() {
367            self.invariant_count += 1;
368        }
369    }
370
371    pub fn has_failure(&self, invariant: &Function) -> bool {
372        self.get_failure(invariant).is_some()
373    }
374
375    pub fn get_failure(&self, invariant: &Function) -> Option<&InvariantFuzzError> {
376        // Most checks run before any invariant fails; skip the key allocation for them.
377        if self.invariant_count == 0 {
378            return None;
379        }
380        self.failures.get(&FailureKey::Invariant(invariant.name.clone()))
381    }
382
383    /// Recorded revert reason for `invariant`, or empty when none. Used by failure events
384    /// so the metrics payload mirrors the persisted failure.
385    pub fn broken_reason(&self, invariant: &Function) -> String {
386        self.get_failure(invariant).and_then(|e| e.revert_reason()).unwrap_or_default()
387    }
388
389    pub const fn can_continue(&self, invariants: usize) -> bool {
390        self.invariant_count() < invariants
391    }
392
393    /// Number of unique broken invariant predicates (O(1), cached).
394    pub const fn invariant_count(&self) -> usize {
395        self.invariant_count
396    }
397
398    /// Number of unique handler-side assertion bugs (O(1), cached).
399    pub const fn handler_count(&self) -> usize {
400        self.handler_count
401    }
402
403    /// Revision of the failure map, including replacements with shorter reproducers.
404    pub const fn revision(&self) -> usize {
405        self.revision
406    }
407
408    pub fn handler_failures_mut(&mut self) -> impl Iterator<Item = &mut InvariantFuzzError> {
409        self.failures.iter_mut().filter_map(|(key, error)| match key {
410            FailureKey::Handler(_, _) => Some(error),
411            FailureKey::Invariant(_) => None,
412        })
413    }
414
415    /// Records a handler-side assertion bug. Deduped by `(reverter, selector)` site;
416    /// shortest sequence wins on collision.
417    pub fn record_handler_failure(&mut self, failure: HandlerAssertionFailure) {
418        let site = (failure.reverter, failure.selector);
419        if !handler_site_already_minimal(&self.failures, site, failure.call_sequence.len()) {
420            let prev = self.failures.insert(
421                FailureKey::Handler(site.0, site.1),
422                InvariantFuzzError::HandlerAssertion(failure),
423            );
424            self.revision = self.revision.wrapping_add(1);
425            if prev.is_none() {
426                self.handler_count += 1;
427            }
428        }
429    }
430
431    /// Inserts a persisted-replay handler bug. Skips dedup (caller seeds an empty map)
432    /// but bumps `handler_count` so the live counter is correct from the first tick.
433    pub fn seed_handler_failure(
434        &mut self,
435        target: Address,
436        selector: Selector,
437        err: InvariantFuzzError,
438    ) {
439        let prev = self.failures.insert(FailureKey::Handler(target, selector), err);
440        self.revision = self.revision.wrapping_add(1);
441        if prev.is_none() {
442            self.handler_count += 1;
443        }
444    }
445
446    /// Returns true if a handler bug has already been recorded for the given site.
447    pub fn has_handler_failure(&self, target: Address, selector: Selector) -> bool {
448        self.failures.contains_key(&FailureKey::Handler(target, selector))
449    }
450}
451
452impl fmt::Display for InvariantFailures {
453    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
454        writeln!(f)?;
455        writeln!(f, "      ❌ Failures: {}", self.invariant_count())?;
456        Ok(())
457    }
458}
459
460#[derive(Clone, Debug)]
461pub enum InvariantFuzzError {
462    /// A handler call reverted under `fail_on_revert = true`.
463    Revert(FailedInvariantCaseData),
464    /// An `invariant_*` predicate returned `false` (or asserted).
465    BrokenInvariant(FailedInvariantCaseData),
466    /// A handler-side `assert(...)` / `vm.assert*` failed (bug inside a handler, not in
467    /// an `invariant_*` predicate). Recorded per `(reverter, selector)` site.
468    HandlerAssertion(HandlerAssertionFailure),
469    /// `vm.assume` rejected more inputs than allowed.
470    MaxAssumeRejects(u32),
471}
472
473impl InvariantFuzzError {
474    /// Reconstructs a predicate failure from a persisted sequence that still reproduces.
475    #[expect(clippy::too_many_arguments)]
476    pub fn from_replayed_invariant(
477        invariant_address: Address,
478        invariant: &Function,
479        call_sequence: Vec<BasicTxDetails>,
480        reason: Option<String>,
481        config: &InvariantConfig,
482        fail_on_revert: bool,
483        assertion_failure: bool,
484        is_revert: bool,
485    ) -> Self {
486        let revert_reason = reason.unwrap_or_default();
487        let origin = invariant.name.as_str();
488        let failure = FailedInvariantCaseData {
489            test_error: TestError::Fail(
490                format!("{origin}, reason: {revert_reason}").into(),
491                call_sequence,
492            ),
493            return_reason: "".into(),
494            revert_reason,
495            addr: invariant_address,
496            calldata: invariant.selector().into(),
497            inner_sequence: Vec::new(),
498            shrink_run_limit: config.shrink_run_limit,
499            fail_on_revert,
500            assertion_failure,
501            fork_block_number: None,
502            campaign_failure: None,
503            after_invariant: false,
504            unchecked_invariants: Vec::new(),
505        };
506        if is_revert { Self::Revert(failure) } else { Self::BrokenInvariant(failure) }
507    }
508
509    /// Active fork block when this invariant failure was observed, if any.
510    pub const fn fork_block_number(&self) -> Option<u64> {
511        match self {
512            Self::BrokenInvariant(case_data) | Self::Revert(case_data) => {
513                case_data.fork_block_number
514            }
515            Self::HandlerAssertion(failure) => failure.fork_block_number,
516            Self::MaxAssumeRejects(_) => None,
517        }
518    }
519
520    pub fn revert_reason(&self) -> Option<String> {
521        match self {
522            Self::BrokenInvariant(case_data) | Self::Revert(case_data) => {
523                (!case_data.revert_reason.is_empty()).then(|| case_data.revert_reason.clone())
524            }
525            Self::HandlerAssertion(failure) => {
526                (!failure.revert_reason.is_empty()).then(|| failure.revert_reason.clone())
527            }
528            Self::MaxAssumeRejects(allowed) => {
529                Some(format!("`vm.assume` rejected too many inputs ({allowed} allowed)"))
530            }
531        }
532    }
533
534    /// Wrapped `HandlerAssertionFailure` if this is the [`Self::HandlerAssertion`] variant.
535    pub const fn as_handler_assertion(&self) -> Option<&HandlerAssertionFailure> {
536        match self {
537            Self::HandlerAssertion(failure) => Some(failure),
538            _ => None,
539        }
540    }
541
542    /// Mutable counterpart of [`Self::as_handler_assertion`]. Used by post-campaign shrinking.
543    pub const fn as_handler_assertion_mut(&mut self) -> Option<&mut HandlerAssertionFailure> {
544        match self {
545            Self::HandlerAssertion(failure) => Some(failure),
546            _ => None,
547        }
548    }
549}
550
551#[derive(Clone, Debug)]
552pub struct FailedInvariantCaseData {
553    /// The proptest error occurred as a result of a test case.
554    pub test_error: TestError<Vec<BasicTxDetails>>,
555    /// The return reason of the offending call.
556    pub return_reason: Reason,
557    /// The revert string of the offending call.
558    pub revert_reason: String,
559    /// Address of the invariant asserter.
560    pub addr: Address,
561    /// Function calldata for invariant check.
562    pub calldata: Bytes,
563    /// Inner fuzzing Sequence coming from overriding calls.
564    pub inner_sequence: Vec<Option<BasicTxDetails>>,
565    /// Shrink run limit
566    pub shrink_run_limit: u32,
567    /// Fail on revert, used to check sequence when shrinking.
568    pub fail_on_revert: bool,
569    /// Whether this failure originated from a handler assertion.
570    pub assertion_failure: bool,
571    /// Active fork block when the failure was observed, if any.
572    pub fork_block_number: Option<u64>,
573    /// Site and observable outcome of the campaign's failing call, to check that a replay
574    /// reproduced it. `None` when its failure provenance was not recorded.
575    pub campaign_failure: Option<(CheckSequenceFailureSite, RawFailure)>,
576    /// Whether `afterInvariant` failed, which can happen without any calls.
577    pub after_invariant: bool,
578    /// Invariants that the campaign did not check after any call of the failing sequence, because
579    /// they broke before it.
580    pub unchecked_invariants: Vec<String>,
581}
582
583#[cfg(test)]
584mod tests {
585    use super::*;
586    use foundry_evm_fuzz::CallDetails;
587
588    fn handler_failure(sequence_len: usize) -> HandlerAssertionFailure {
589        let tx = BasicTxDetails {
590            warp: None,
591            roll: None,
592            sender: Address::ZERO,
593            call_details: CallDetails {
594                target: Address::ZERO,
595                calldata: Bytes::new(),
596                value: None,
597            },
598        };
599        HandlerAssertionFailure::from_replayed_sequence(
600            vec![tx; sequence_len],
601            Address::ZERO,
602            Selector::ZERO,
603            B256::ZERO,
604            "assertion failed".to_string(),
605        )
606    }
607
608    #[test]
609    fn failure_revision_tracks_shorter_handler_reproducer() {
610        let mut failures = InvariantFailures::new();
611        failures.record_handler_failure(handler_failure(2));
612        let checkpoint = failures.revision();
613
614        failures.record_handler_failure(handler_failure(2));
615        assert_eq!(failures.revision(), checkpoint);
616
617        failures.record_handler_failure(handler_failure(1));
618        assert_ne!(failures.revision(), checkpoint);
619        let failure = failures
620            .failures
621            .get(&FailureKey::Handler(Address::ZERO, Selector::ZERO))
622            .and_then(InvariantFuzzError::as_handler_assertion)
623            .unwrap();
624        assert_eq!(failure.call_sequence.len(), 1);
625    }
626}