Skip to content

Commit

Permalink
removed decoded_logs in FuzzTestResult & refactored some code
Browse files Browse the repository at this point in the history
fmt
  • Loading branch information
Azleal committed Jul 9, 2024
1 parent fdf165b commit b73b815
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
16 changes: 6 additions & 10 deletions crates/evm/evm/src/executors/fuzz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use foundry_common::evm::Breakpoints;
use foundry_config::FuzzConfig;
use foundry_evm_core::{
constants::MAGIC_ASSUME,
decode::{decode_console_logs, RevertDecoder},
decode::RevertDecoder,
};
use foundry_evm_coverage::HitMaps;
use foundry_evm_fuzz::{
Expand Down Expand Up @@ -116,8 +116,9 @@ impl FuzzedExecutor {
data.traces.push(call_traces);
data.breakpoints.replace(case.breakpoints);
}
data.logs.extend(case.logs);

if show_logs {
data.logs.extend(case.logs);
}
// Collect and merge coverage if `forge snapshot` context.
match &mut data.coverage {
Some(prev) => prev.merge(case.coverage.unwrap()),
Expand All @@ -137,8 +138,7 @@ impl FuzzedExecutor {
// to run at least one more case to find a minimal failure
// case.
let reason = rd.maybe_decode(&outcome.1.result, Some(status));
let cloned_logs = outcome.1.logs.clone();
execution_data.borrow_mut().logs.extend(cloned_logs);
execution_data.borrow_mut().logs.extend(outcome.1.logs.clone());
execution_data.borrow_mut().counterexample = outcome;
// HACK: we have to use an empty string here to denote `None`.
Err(TestCaseError::fail(reason.unwrap_or_default()))
Expand All @@ -156,17 +156,13 @@ impl FuzzedExecutor {
(call.traces.clone(), call.cheatcodes.map(|c| c.breakpoints))
};

// decide whether to use trace logs or only error logs
let actual_logs = if show_logs { fuzz_result.logs } else { call.logs };

let mut result = FuzzTestResult {
first_case: fuzz_result.first_case.unwrap_or_default(),
gas_by_case: fuzz_result.gas_by_case,
success: run_result.is_ok(),
reason: None,
counterexample: None,
decoded_logs: decode_console_logs(&actual_logs),
logs: actual_logs,
logs: fuzz_result.logs,
labeled_addresses: call.labels,
traces: last_run_traces,
breakpoints: last_run_breakpoints,
Expand Down
3 changes: 0 additions & 3 deletions crates/evm/fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ pub struct FuzzTestResult {
/// be printed to the user.
pub logs: Vec<Log>,

/// The decoded DSTest logging events and Hardhat's `console.log` from [logs](Self::logs).
pub decoded_logs: Vec<String>,

/// Labeled addresses
pub labeled_addresses: HashMap<Address, String>,

Expand Down

0 comments on commit b73b815

Please sign in to comment.