mirror of
https://github.com/logos-co/nomos-pocs.git
synced 2025-02-16 03:06:32 +00:00
add tests
This commit is contained in:
parent
b48f3016df
commit
d817cb860a
@ -16,3 +16,8 @@ sha2 = "0.10"
|
||||
lazy_static = "1.5.0"
|
||||
risc0-zkvm = "1.2"
|
||||
itertools = "0.14"
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
proptest = "1.2.0"
|
||||
proptest-macro = "0.1"
|
@ -524,8 +524,34 @@ fn frontier_root(roots: &[Root]) -> [u8; 32] {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
use proptest_macro::property_test;
|
||||
|
||||
#[test]
|
||||
fn test_empty_roots() {
|
||||
let mut root = [0; 32];
|
||||
for i in 0..32 {
|
||||
assert_eq!(root, EMPTY_ROOTS[i]);
|
||||
root = merkle::node(root, root);
|
||||
}
|
||||
}
|
||||
|
||||
#[property_test]
|
||||
fn test_frontier_root(elems: Vec<[u8; 32]>) {
|
||||
let mut mmr = MMR::new();
|
||||
for elem in &elems {
|
||||
mmr.push(elem);
|
||||
}
|
||||
assert_eq!(
|
||||
frontier_root(&mmr.roots),
|
||||
merkle::root(&merkle::padded_leaves(
|
||||
&elems
|
||||
.into_iter()
|
||||
.map(|array| array.to_vec())
|
||||
.collect::<Vec<_>>()
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
|
Loading…
x
Reference in New Issue
Block a user