forked from foundry-rs/foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Debugger Refactor #1: fuzz single (foundry-rs#5692)
* fuzz single refactor * add struct docs * Update crates/evm/src/fuzz/mod.rs Co-authored-by: DaniPopes <[email protected]> * add docs and move types to types.rs * fmt * add docki docs * fmt --------- Co-authored-by: DaniPopes <[email protected]>
- Loading branch information
Showing
3 changed files
with
148 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use crate::{coverage::HitMaps, debug::DebugArena, executor::RawCallResult, trace::CallTraceArena}; | ||
use ethers::types::Bytes; | ||
use foundry_common::evm::Breakpoints; | ||
use revm::interpreter::InstructionResult; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Data of a single fuzz test case | ||
#[derive(Clone, Debug, Default, Serialize, Deserialize)] | ||
pub struct FuzzCase { | ||
/// The calldata used for this fuzz test | ||
pub calldata: Bytes, | ||
/// Consumed gas | ||
pub gas: u64, | ||
/// The initial gas stipend for the transaction | ||
pub stipend: u64, | ||
} | ||
|
||
/// Returned by a single fuzz in the case of a successful run | ||
#[derive(Debug)] | ||
pub struct CaseOutcome { | ||
/// Data of a single fuzz test case | ||
pub case: FuzzCase, | ||
/// The traces of the call | ||
pub traces: Option<CallTraceArena>, | ||
/// The coverage info collected during the call | ||
pub coverage: Option<HitMaps>, | ||
/// The debug nodes of the call | ||
pub debug: Option<DebugArena>, | ||
/// Breakpoints char pc map | ||
pub breakpoints: Breakpoints, | ||
} | ||
|
||
/// Returned by a single fuzz when a counterexample has been discovered | ||
#[derive(Debug)] | ||
pub struct CounterExampleOutcome { | ||
/// Minimal reproduction test case for failing test | ||
pub counterexample: (ethers::types::Bytes, RawCallResult), | ||
/// The status of the call | ||
pub exit_reason: InstructionResult, | ||
/// The debug nodes of the call | ||
pub debug: Option<DebugArena>, | ||
/// Breakpoints char pc map | ||
pub breakpoints: Breakpoints, | ||
} | ||
|
||
/// Outcome of a single fuzz | ||
#[derive(Debug)] | ||
pub enum FuzzOutcome { | ||
Case(CaseOutcome), | ||
CounterExample(CounterExampleOutcome), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters