Skip to main content

foundry_evm/executors/fuzz/
types.rs

1use crate::executors::RawCallResult;
2use alloy_primitives::{
3    Bytes, Log,
4    map::{AddressHashMap, HashMap},
5};
6use foundry_evm_core::{Breakpoints, evm::FoundryEvmNetwork};
7use foundry_evm_coverage::HitMaps;
8use foundry_evm_fuzz::FuzzCase;
9use foundry_evm_traces::SparsedTraceArena;
10use revm::interpreter::InstructionResult;
11
12/// Returned by a single fuzz in the case of a successful run
13#[derive(Debug)]
14pub struct CaseOutcome {
15    /// Data of a single fuzz test case.
16    pub case: FuzzCase,
17    /// The traces of the call.
18    pub traces: Option<SparsedTraceArena>,
19    /// Runtime bytecodes for contracts seen in the trace.
20    pub debug_bytecodes: AddressHashMap<Bytes>,
21    /// The coverage info collected during the call.
22    pub coverage: Option<HitMaps>,
23    /// Breakpoints char pc map.
24    pub breakpoints: Breakpoints,
25    /// logs of a single fuzz test case.
26    pub logs: Vec<Log>,
27    // Deprecated cheatcodes mapped to their replacements.
28    pub deprecated_cheatcodes: HashMap<&'static str, Option<&'static str>>,
29}
30
31/// Returned by a single fuzz when a counterexample has been discovered
32#[derive(Debug)]
33pub struct CounterExampleOutcome<FEN: FoundryEvmNetwork> {
34    /// Minimal reproduction test case for failing test.
35    pub counterexample: (Bytes, RawCallResult<FEN>),
36    /// The status of the call.
37    pub exit_reason: Option<InstructionResult>,
38    /// Breakpoints char pc map.
39    pub breakpoints: Breakpoints,
40}
41
42/// Outcome of a single fuzz
43#[derive(Debug)]
44#[expect(clippy::large_enum_variant)]
45pub enum FuzzOutcome<FEN: FoundryEvmNetwork> {
46    Case(CaseOutcome),
47    CounterExample(CounterExampleOutcome<FEN>),
48}