Skip to content

Commit

Permalink
fix last test, add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Feb 21, 2023
1 parent 7a87da3 commit fb95396
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
18 changes: 7 additions & 11 deletions base_layer/core/src/chain_storage/tests/blockchain_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ mod validator_node_merkle_root {
use super::*;
use crate::{
transactions::transaction_components::{OutputFeatures, ValidatorNodeSignature},
ValidatorNodeBMT,
ValidatorNodeMmr,
};

Expand Down Expand Up @@ -618,18 +619,13 @@ mod validator_node_merkle_root {
.unwrap()
.unwrap();

let mut vn_mmr = ValidatorNodeMmr::new(Vec::new());
vn_mmr
.push(
Blake256::new()
.chain(public_key.as_bytes())
.chain(shard_key.as_slice())
.finalize()
.to_vec(),
)
.unwrap();
let vn_bmt = ValidatorNodeBMT::create(vec![Blake256::new()
.chain(public_key.as_bytes())
.chain(shard_key.as_slice())
.finalize()
.to_vec()]);

let tip = db.fetch_tip_header().unwrap();
assert_eq!(tip.header().validator_node_mr, vn_mmr.get_merkle_root().unwrap());
assert_eq!(tip.header().validator_node_mr, vn_bmt.get_merkle_root());
}
}
1 change: 1 addition & 0 deletions base_layer/mmr/src/balanced_binary_merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub struct BalancedBinaryMerkleTree<D> {
impl<D> BalancedBinaryMerkleTree<D>
where D: Digest + DomainDigest
{
// There is no push method for this tree. This tree is created at once and no modifications are allowed.
pub fn create(leaves: Vec<Hash>) -> Self {
let leaves_cnt = leaves.len();
if leaves_cnt == 0 {
Expand Down

0 comments on commit fb95396

Please sign in to comment.