Skip to content

Commit

Permalink
Adds more lattice hash tests (anza-xyz#3137)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored and ray-kast committed Nov 27, 2024
1 parent 50ab5e2 commit 0dc65ae
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lattice-hash/src/lt_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ mod tests {
let a = LtHash::new_random();
let b = LtHash::new_random();
assert_eq!(a, a + b - b);
assert_eq!(a, a - b + b);
}

// Ensure that mixing is commutative
Expand All @@ -149,6 +150,16 @@ mod tests {
assert_eq!((a + b) + c, a + (b + c));
}

// Ensure that mixing out respects distribution
#[test]
fn test_distribute() {
let a = LtHash::new_random();
let b = LtHash::new_random();
let c = LtHash::new_random();
let d = LtHash::new_random();
assert_eq!(a - b - c - d, a - (b + c + d));
}

// Ensure the correct lattice hash and checksum values are produced
#[test]
fn test_hello_world() {
Expand Down

0 comments on commit 0dc65ae

Please sign in to comment.