Skip to content

Commit 3b85ede

Browse files
authored
Merge pull request #426 from filecoin-project/fuzz/minor-fixes
Run clippy, fmt on fuzz targets and fix rle_encode corpus symlink
2 parents 2417154 + 5e481b8 commit 3b85ede

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

ipld/amt/fuzz/fuzz_targets/equivalence.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
#![no_main]
55
use arbitrary::Arbitrary;
6-
use fvm_ipld_amt::Amt;
7-
use libfuzzer_sys::fuzz_target;
86
use cid::Cid;
7+
use fvm_ipld_amt::Amt;
98
use itertools::Itertools;
10-
9+
use libfuzzer_sys::fuzz_target;
1110

1211
#[derive(Debug, Arbitrary)]
1312
struct Operation {
@@ -27,7 +26,7 @@ fn execute(ops: Vec<Operation>) -> (Cid, ahash::AHashMap<u64, u64>) {
2726
let mut amt = Amt::new(&db);
2827
let mut elements = ahash::AHashMap::new();
2928

30-
for (i, Operation { idx, method, flush}) in ops.into_iter().enumerate() {
29+
for (i, Operation { idx, method, flush }) in ops.into_iter().enumerate() {
3130
let idx = idx as u64;
3231
if flush > 255 - 13 {
3332
// Periodic flushing and reloading of Amt to fuzz blockstore usage also
@@ -62,9 +61,15 @@ fn execute(ops: Vec<Operation>) -> (Cid, ahash::AHashMap<u64, u64>) {
6261
fuzz_target!(|ops: Vec<Operation>| {
6362
let (res_cid, m) = execute(ops);
6463

65-
let simplified_ops = m.iter().sorted_by_key(|(_, v)| *v).map(|(k ,v)| {
66-
Operation{idx: *k as u16, method: Method::Insert(*v), flush: 0}
67-
}).collect();
64+
let simplified_ops = m
65+
.iter()
66+
.sorted_by_key(|(_, v)| *v)
67+
.map(|(k, v)| Operation {
68+
idx: *k as u16,
69+
method: Method::Insert(*v),
70+
flush: 0,
71+
})
72+
.collect();
6873

6974
let (simplified_cid, _) = execute(simplified_ops);
7075
assert_eq!(res_cid, simplified_cid)

testing/common_fuzz/fuzz/fuzz_targets/rle_encode.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![no_main]
2-
use libfuzzer_sys::fuzz_target;
3-
use fvm_ipld_bitfield::BitField;
42
use arbitrary::Arbitrary;
3+
use fvm_ipld_bitfield::BitField;
4+
use libfuzzer_sys::fuzz_target;
55

66
#[derive(Debug, Arbitrary)]
77
enum Operation {
@@ -14,8 +14,12 @@ fuzz_target!(|data: (BitField, Vec<Operation>)| {
1414

1515
for op in ops {
1616
match op {
17-
Operation::Set(x) => { _ = bf.try_set(x);}
18-
Operation::Unset(x) => {bf.unset(x);}
17+
Operation::Set(x) => {
18+
let _ = bf.try_set(x);
19+
}
20+
Operation::Unset(x) => {
21+
bf.unset(x);
22+
}
1923
};
2024
}
2125

testing/common_fuzz/fuzz/fuzz_targets/rle_ops.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0, MIT
33

44
#![no_main]
5+
#![allow(clippy::eq_op)]
56

67
use fvm_ipld_bitfield::BitField;
78
use libfuzzer_sys::fuzz_target;
@@ -31,6 +32,4 @@ fuzz_target!(|bfs: [BitField; 3]| {
3132
assert_eq!(&(bf1 - bf2) - bf3, &(bf1 - bf3) - bf2);
3233
assert_eq!(&(bf1 ^ bf2) ^ bf3, &(bf1 ^ bf3) ^ bf2);
3334
}
34-
35-
()
3635
});

testing/common_fuzz/fuzz/rust-toolchain

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)