Skip to content

Commit deacbfa

Browse files
committed
Update ahash in fuzz and make equivalence 100% deterministic
Signed-off-by: Jakub Sztandera <[email protected]>
1 parent d317fea commit deacbfa

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

ipld/amt/fuzz/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ cargo-fuzz = true
1111
[dependencies]
1212
libfuzzer-sys = "0.3"
1313
arbitrary = { version = "0.4", features = ["derive"] }
14-
ahash = "0.6"
14+
ahash = "0.7.6"
15+
itertools = "0.10.3"
1516

1617
cid = { version = "0.8.2", default-features = false, features = ["serde-codec"] }
1718

ipld/amt/fuzz/fuzz_targets/equivalence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use arbitrary::Arbitrary;
66
use fvm_ipld_amt::{Amt, MAX_INDEX};
77
use libfuzzer_sys::fuzz_target;
88
use cid::Cid;
9+
use itertools::Itertools;
910

1011

1112
#[derive(Debug, Arbitrary)]
@@ -58,11 +59,10 @@ fn execute(ops: Vec<Operation>) -> (Cid, ahash::AHashMap<u64, u64>) {
5859
fuzz_target!(|ops: Vec<Operation>| {
5960
let (res_cid, m) = execute(ops);
6061

61-
let simplified_ops = m.iter().map(|(k ,v)| {
62+
let simplified_ops = m.iter().sorted_by_key(|(_, v)| *v).map(|(k ,v)| {
6263
Operation{idx: *k, method: Method::Insert(*v)}
6364
}).collect();
6465

6566
let (simplified_cid, _) = execute(simplified_ops);
66-
6767
assert_eq!(res_cid, simplified_cid)
6868
});

ipld/hamt/fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cargo-fuzz = true
1111
[dependencies]
1212
libfuzzer-sys = "0.3"
1313
arbitrary = { version = "0.4", features = ["derive"] }
14-
ahash = "0.6"
14+
ahash = "0.7.6"
1515

1616
fvm_ipld_hamt = { path = ".." }
1717
fvm_shared = { path = "../../../shared" }

0 commit comments

Comments
 (0)