mirror of https://github.com/vacp2p/pmtree.git
fix: impl
This commit is contained in:
parent
c1de1c3bca
commit
07aca1dcf7
|
@ -251,7 +251,7 @@ where
|
|||
|
||||
self.fill_nodes(root_key, start, end, &mut subtree, &leaves, start)?;
|
||||
for i in to_remove_indices {
|
||||
subtree.insert(Key(self.depth, i - leaves.len() + 1), H::default_leaf());
|
||||
subtree.insert(Key(self.depth, i + leaves.len()), H::default_leaf());
|
||||
}
|
||||
|
||||
let subtree = Arc::new(RwLock::new(subtree));
|
||||
|
|
|
@ -151,12 +151,10 @@ fn set_range() -> PmtreeResult<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn batch_operations() -> PmtreeResult<()> {
|
||||
let mut mt = MerkleTree::<MemoryDB, MyKeccak>::new(2, MemoryDBConfig)?;
|
||||
|
||||
|
||||
let leaves = [
|
||||
hex!("0000000000000000000000000000000000000000000000000000000000000001"),
|
||||
hex!("0000000000000000000000000000000000000000000000000000000000000002"),
|
||||
|
@ -184,11 +182,18 @@ fn batch_operations() -> PmtreeResult<()> {
|
|||
// this should be a no-op
|
||||
mt.batch_operations(None, [leaves[1]], [3])?;
|
||||
|
||||
assert_eq!(
|
||||
mt.root(),
|
||||
hex!("a9bb8c3f1f12e9aa903a50c47f314b57610a3ab32f2d463293f58836def38d36")
|
||||
);
|
||||
|
||||
// this should remove the last element
|
||||
mt.batch_operations(None, [], [3])?;
|
||||
|
||||
assert_eq!(
|
||||
mt.root(),
|
||||
hex!("222ff5e0b5877792c2bc1670e2ccd0c2c97cd7bb1672a57d598db05092d3d72c")
|
||||
);
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -233,6 +233,14 @@ fn batch_operations() -> PmtreeResult<()> {
|
|||
// this should be a no-op
|
||||
mt.batch_operations(None, [leaves[1]], [3])?;
|
||||
|
||||
assert_eq!(
|
||||
mt.root(),
|
||||
hex!("a9bb8c3f1f12e9aa903a50c47f314b57610a3ab32f2d463293f58836def38d36")
|
||||
);
|
||||
|
||||
// this should remove the last element
|
||||
mt.batch_operations(None, [], [3])?;
|
||||
|
||||
assert_eq!(
|
||||
mt.root(),
|
||||
hex!("222ff5e0b5877792c2bc1670e2ccd0c2c97cd7bb1672a57d598db05092d3d72c")
|
||||
|
|
Loading…
Reference in New Issue