Skip to content

Commit 2c46e5e

Browse files
committed
mmr_authentication_struct: Add for empty MMR / no opened leafs
1 parent f47bb0e commit 2c46e5e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

twenty-first/src/util_types/mmr/mmr_authentication_struct.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,22 @@ mod tests {
418418
}
419419
}
420420

421+
#[test]
422+
fn auth_struct_on_empty_mmr() {
423+
let empty_mmra = MmrAccumulator::init(vec![], 0);
424+
let authenticated_auth_structs =
425+
AuthStructIntegrityProof::new_from_mmr_membership_proofs(&empty_mmra, vec![]);
426+
assert!(authenticated_auth_structs.is_empty());
427+
}
428+
429+
#[test]
430+
fn auth_struct_non_empty_mmr_empty_leaf_list() {
431+
let mmra_10_leafs = MmrAccumulator::new_from_leafs(vec![Digest::default(); 10]);
432+
let authenticated_auth_structs =
433+
AuthStructIntegrityProof::new_from_mmr_membership_proofs(&mmra_10_leafs, vec![]);
434+
assert!(authenticated_auth_structs.is_empty());
435+
}
436+
421437
#[test]
422438
fn auth_struct_from_mmr_mps_test_height_5_9_indices() {
423439
let local_tree_height = 5;

0 commit comments

Comments
 (0)