Skip to content

Commit

Permalink
clippy --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-valerio committed Sep 2, 2024
1 parent 2aaf838 commit a0d66bd
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/contract/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ mod test {
static BUILD: Once = Once::new();

pub fn build() {
println!("executing build.sh");
BUILD.call_once(|| {
let status = Command::new("bash")
.current_dir("sample") // Change to the 'sample' directory
Expand Down
3 changes: 0 additions & 3 deletions src/fuzzer/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,7 @@ mod tests {
.decode_contract_message(&mut &encoded_bytes[..])
.expect("Failed to decode contract message");

println!("{:#?}", hex);

let binding = transcoder.lock().unwrap();
let messages = binding.metadata().spec().messages();
println!("{:#?}", messages);
}
}
3 changes: 1 addition & 2 deletions tests/cli_fuzz_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ mod tests {
// While fuzzing, let's perform the tests
let fuzzing = ensure_while_fuzzing(&config, Duration::from_secs(120), || {
let fuzz_created = phink_output.exists();
println!("Fuzz output created yet : {:?}", fuzz_created);
ensure!(fuzz_created, "Fuzz output directory wasn't created");

if fuzz_created {
Expand Down Expand Up @@ -107,7 +106,7 @@ mod tests {
let corpus_len = get_corpus_files(&phink_output.join("corpus"))
.unwrap()
.len();
println!("After a bit of fuzzing, we get {} corpus entries, when we had {} entries at the begining", corpus_len, initial_corpus_len);
println!("After a bit of fuzzing, we get {corpus_len} corpus entries, when we had {initial_corpus_len} entries at the begining");
ensure!(
corpus_len > initial_corpus_len,
"There was no new corpus while fuzzing"
Expand Down
2 changes: 1 addition & 1 deletion tests/cli_instrument_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mod tests {
// `path_instrumented_contract`
let cargo_toml_exists = WalkDir::new(path_instrumented_contract.path)
.into_iter()
.filter_map(|e| e.ok()) // Filter out errors
.filter_map(std::result::Result::ok) // Filter out errors
.any(|entry| {
entry.file_name() == "Cargo.toml"
});
Expand Down
14 changes: 7 additions & 7 deletions tests/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ where
}
}

pub fn afl_log_didnt_fail(output: &Path) -> bool {
#[must_use] pub fn afl_log_didnt_fail(output: &Path) -> bool {
let log_path = output.join("logs").join("afl.log");

match fs::read_to_string(log_path) {
Expand All @@ -159,19 +159,19 @@ pub fn try_cleanup_instrumented(config: &Configuration) {
pub fn try_cleanup_fuzzoutput(config: &Configuration) {
let output = config.clone().fuzz_output.unwrap_or_default();
match fs::remove_dir_all(&output) {
Ok(_) => {
println!("Removed {}", output.display())
Ok(()) => {
println!("Removed {}", output.display());
}
Err(_) => {
println!("**DIDN'T** removed {}", output.display())
println!("**DIDN'T** removed {}", output.display());
}
};
}

/// Simple `phink` bin pop from cargo to instrument `contract_path`
/// ** Important **
/// This should only be used in test !
pub fn instrument(contract_path: Sample) -> Assert {
#[must_use] pub fn instrument(contract_path: Sample) -> Assert {
let mut cmd = Command::cargo_bin("phink").unwrap();
cmd.args(["--config", DEFAULT_TEST_PHINK_TOML])
.arg("instrument")
Expand All @@ -183,7 +183,7 @@ pub fn instrument(contract_path: Sample) -> Assert {
/// Simple `phink` bin pop from cargo to fuzz `path_instrumented_contract`
/// ** Important **
/// This should only be used in test !
pub fn fuzz(path_instrumented_contract: InstrumentedPath) -> Child {
#[must_use] pub fn fuzz(path_instrumented_contract: InstrumentedPath) -> Child {
let child = NativeCommand::new("cargo")
.arg("run")
.arg("--")
Expand All @@ -199,7 +199,7 @@ pub fn fuzz(path_instrumented_contract: InstrumentedPath) -> Child {
}

/// Return `true` if `target` is found in any `*.rs` file of `dir`, otherwise `false`
pub fn find_string_in_rs_files(dir: &Path, target: &str) -> bool {
#[must_use] pub fn find_string_in_rs_files(dir: &Path, target: &str) -> bool {
fn file_contains_string(file_path: &Path, target: &str) -> bool {
let mut file = fs::File::open(file_path).expect("Unable to open file");
let mut content = String::new();
Expand Down
2 changes: 1 addition & 1 deletion tests/shared/samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub enum Sample {
Transfer,
}
impl Sample {
pub fn path(&self) -> &str {
#[must_use] pub fn path(&self) -> &str {
match self {
Sample::CrossMessageBug => "sample/cross_message_bug",
Sample::DNS => "sample/dns",
Expand Down

0 comments on commit a0d66bd

Please sign in to comment.