From f4e2039d611614a4fc561cabe52fb70ee106e59f Mon Sep 17 00:00:00 2001 From: Sergey Vasilyev Date: Tue, 28 Apr 2020 00:07:10 +0300 Subject: [PATCH] Merkle tree fails to compute the root when there's no need in dummy nodes - test --- crypto-primitives/src/merkle_tree/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crypto-primitives/src/merkle_tree/mod.rs b/crypto-primitives/src/merkle_tree/mod.rs index 2861def..c621214 100644 --- a/crypto-primitives/src/merkle_tree/mod.rs +++ b/crypto-primitives/src/merkle_tree/mod.rs @@ -378,7 +378,7 @@ mod test { struct JubJubMerkleTreeParams; impl MerkleTreeConfig for JubJubMerkleTreeParams { - const HEIGHT: usize = 32; + const HEIGHT: usize = 8; type H = H; } type JubJubMerkleTree = MerkleHashTree; @@ -409,6 +409,15 @@ mod test { generate_merkle_tree(&leaves); } + #[test] + fn no_dummy_nodes_test() { + let mut leaves = Vec::new(); + for i in 0..(1u8 << JubJubMerkleTree::HEIGHT - 1) { + leaves.push([i, i, i, i, i, i, i, i]); + } + generate_merkle_tree(&leaves); + } + fn bad_merkle_tree_verify(leaves: &[L]) -> () { let mut rng = XorShiftRng::seed_from_u64(13423423u64);