Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fominok committed Nov 6, 2024
1 parent 2f134ac commit 72f519f
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion grovedb/src/merk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl<'db, 'c> MerkHandle<'db, 'c> {
mod tests {
use grovedb_costs::OperationCost;
use grovedb_path::SubtreePath;
use grovedb_storage::StorageBatch;
use grovedb_storage::{Storage, StorageBatch};
use grovedb_version::version::GroveVersion;

use super::MerkCache;
Expand Down Expand Up @@ -322,4 +322,35 @@ mod tests {
// Do something and finalize another batch:
assert!(cache.finalize().unwrap().unwrap().len() > 0);
}

#[test]
fn changes_to_merk_are_propagated() {
let version = GroveVersion::latest();
let db = make_deep_tree(&version);
let tx = db.start_transaction();

let pre_hash = db.root_hash(Some(&tx), &version).unwrap().unwrap();

let mut cache = MerkCache::new(&db, &tx, version);
let [mut subtree] = cache
.get_multi_mut([SubtreePath::from(&[TEST_LEAF, b"innertree"])])
.unwrap()
.unwrap();
subtree
.insert(b"ayy", Element::new_item(b"lmao".to_vec()), None)
.unwrap()
.unwrap();

let batch = cache.finalize().unwrap().unwrap();

db.db
.commit_multi_context_batch(*batch, Some(&tx))
.unwrap()
.unwrap();

assert_ne!(
pre_hash,
db.root_hash(Some(&tx), &version).unwrap().unwrap()
)
}
}

0 comments on commit 72f519f

Please sign in to comment.