Skip to content

Commit

Permalink
rename to show_fuzz_logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Azleal committed Jul 8, 2024
1 parent 15652dc commit 7487b8e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions crates/config/src/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct FuzzConfig {
/// Name of the file to record fuzz failures, defaults to `failures`.
pub failure_persist_file: Option<String>,
/// show `console.log` in fuzz test, defaults to `false`
pub show_execution_logs: bool,
pub show_fuzz_logs: bool,
}

impl Default for FuzzConfig {
Expand All @@ -44,7 +44,7 @@ impl Default for FuzzConfig {
gas_report_samples: 256,
failure_persist_dir: None,
failure_persist_file: None,
show_execution_logs: false,
show_fuzz_logs: false,
}
}
}
Expand All @@ -60,7 +60,7 @@ impl FuzzConfig {
gas_report_samples: 256,
failure_persist_dir: Some(cache_dir),
failure_persist_file: Some("failures".to_string()),
show_execution_logs: false,
show_fuzz_logs: false,
}
}
}
Expand Down Expand Up @@ -89,8 +89,8 @@ impl InlineConfigParser for FuzzConfig {
conf_clone.dictionary.dictionary_weight = parse_config_u32(key, value)?
}
"failure-persist-file" => conf_clone.failure_persist_file = Some(value),
"show-execution-logs" => {
conf_clone.show_execution_logs = parse_config_bool(key, value)?
"show-fuzz-logs" => {
conf_clone.show_fuzz_logs = parse_config_bool(key, value)?
}
_ => Err(InlineConfigParserError::InvalidConfigProperty(key))?,
}
Expand Down
4 changes: 2 additions & 2 deletions crates/evm/evm/src/executors/fuzz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl FuzzedExecutor {
];
// We want to collect at least one trace which will be displayed to user.
let max_traces_to_collect = std::cmp::max(1, self.config.gas_report_samples) as usize;
let show_execution_logs = self.config.show_execution_logs;
let show_fuzz_logs = self.config.show_fuzz_logs;

//Stores logs for all fuzz cases
let logs: RefCell<Vec<Log>> = RefCell::default();
Expand Down Expand Up @@ -157,7 +157,7 @@ impl FuzzedExecutor {
};

// decide whether to use trace logs or only error logs
let actual_logs = if show_execution_logs { logs.into_inner() } else { call.logs };
let actual_logs = if show_fuzz_logs { logs.into_inner() } else { call.logs };

let mut result = FuzzTestResult {
first_case: fuzz_result.first_case.unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ forgetest!(can_extract_config_values, |prj, cmd| {
seed: Some(U256::from(1000)),
failure_persist_dir: Some("test-cache/fuzz".into()),
failure_persist_file: Some("failures".to_string()),
show_execution_logs: false,
show_fuzz_logs: false,
..Default::default()
},
invariant: InvariantConfig {
Expand Down
24 changes: 12 additions & 12 deletions crates/forge/tests/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,14 +680,14 @@ contract ReplayFailuresTest is Test {
);
});

// tests that `forge test` with config `show_execution_logs: true` for fuzz tests will
// tests that `forge test` with config `show_fuzz_logs: true` for fuzz tests will
// display `console.log` info
forgetest_init!(should_show_execution_logs_when_fuzz_test, |prj, cmd| {
forgetest_init!(should_show_fuzz_logs_when_fuzz_test, |prj, cmd| {
prj.wipe_contracts();

// run fuzz test 3 times
let config = Config {
fuzz: { FuzzConfig { runs: 3, show_execution_logs: true, ..Default::default() } },
fuzz: { FuzzConfig { runs: 3, show_fuzz_logs: true, ..Default::default() } },
..Default::default()
};
prj.write_config(config);
Expand All @@ -711,9 +711,9 @@ forgetest_init!(should_show_execution_logs_when_fuzz_test, |prj, cmd| {
assert!(stdout.contains("inside fuzz test, x is:"), "\n{stdout}");
});

// tests that `forge test` with inline config `show_execution_logs = true` for fuzz tests will
// tests that `forge test` with inline config `show_fuzz_logs = true` for fuzz tests will
// display `console.log` info
forgetest_init!(should_show_execution_logs_when_fuzz_test_inline_config, |prj, cmd| {
forgetest_init!(should_show_fuzz_logs_when_fuzz_test_inline_config, |prj, cmd| {
prj.wipe_contracts();

// run fuzz test 3 times
Expand All @@ -729,7 +729,7 @@ forgetest_init!(should_show_execution_logs_when_fuzz_test_inline_config, |prj, c
import {Test, console2} from "forge-std/Test.sol";
contract ContractFuzz is Test {
/// forge-config: default.fuzz.show-execution-logs = true
/// forge-config: default.fuzz.show-fuzz-logs = true
function testFuzzConsoleLog(uint256 x) public pure {
console2.log("inside fuzz test, x is:", x);
}
Expand All @@ -742,14 +742,14 @@ forgetest_init!(should_show_execution_logs_when_fuzz_test_inline_config, |prj, c
assert!(stdout.contains("inside fuzz test, x is:"), "\n{stdout}");
});

// tests that `forge test` with config `show_execution_logs: false` for fuzz tests will not display
// tests that `forge test` with config `show_fuzz_logs: false` for fuzz tests will not display
// `console.log` info
forgetest_init!(should_not_show_execution_logs_when_fuzz_test, |prj, cmd| {
forgetest_init!(should_not_show_fuzz_logs_when_fuzz_test, |prj, cmd| {
prj.wipe_contracts();

// run fuzz test 3 times
let config = Config {
fuzz: { FuzzConfig { runs: 3, show_execution_logs: false, ..Default::default() } },
fuzz: { FuzzConfig { runs: 3, show_fuzz_logs: false, ..Default::default() } },
..Default::default()
};
prj.write_config(config);
Expand All @@ -774,9 +774,9 @@ forgetest_init!(should_not_show_execution_logs_when_fuzz_test, |prj, cmd| {
assert!(!stdout.contains("inside fuzz test, x is:"), "\n{stdout}");
});

// tests that `forge test` with inline config `show_execution_logs = false` for fuzz tests will not
// tests that `forge test` with inline config `show_fuzz_logs = false` for fuzz tests will not
// display `console.log` info
forgetest_init!(should_not_show_execution_logs_when_fuzz_test_inline_config, |prj, cmd| {
forgetest_init!(should_not_show_fuzz_logs_when_fuzz_test_inline_config, |prj, cmd| {
prj.wipe_contracts();

// run fuzz test 3 times
Expand All @@ -792,7 +792,7 @@ forgetest_init!(should_not_show_execution_logs_when_fuzz_test_inline_config, |pr
import {Test, console2} from "forge-std/Test.sol";
contract ContractFuzz is Test {
/// forge-config: default.fuzz.show-execution-logs = false
/// forge-config: default.fuzz.show-fuzz-logs = false
function testFuzzConsoleLog(uint256 x) public pure {
console2.log("inside fuzz test, x is:", x);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/it/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl ForgeTestProfile {
gas_report_samples: 256,
failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()),
failure_persist_file: Some("testfailure".to_string()),
show_execution_logs: false,
show_fuzz_logs: false,
})
.invariant(InvariantConfig {
runs: 256,
Expand Down

0 comments on commit 7487b8e

Please sign in to comment.