Skip to content

Commit

Permalink
test_fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ufoscout committed Mar 30, 2024
1 parent e9b8078 commit 8ab9f5b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/db/versioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ mod test {
let root_zero = trie.commit().unwrap();
db.commit_version(None);

let mut trie = EthTrie::new_mut(&mut db).at_root(root_zero);
let mut trie = EthTrie::new_mut_at_root(&mut db,root_zero);
assert_eq!(Some(b"test".to_vec()), trie.get(b"test").unwrap());
trie.remove(b"test").unwrap();

// Committed at version 1
let root_one = trie.commit().unwrap();
db.commit_version(None);

let mut trie = EthTrie::new_mut(&mut db).at_root(root_one);
let mut trie = EthTrie::new_mut_at_root(&mut db,root_one);
assert_eq!(None, trie.get(b"test").unwrap());
trie.insert(b"test", b"test_2").unwrap();

Expand Down
1 change: 0 additions & 1 deletion src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
mod trie_tests {
use hex::FromHex;
use rand::Rng;
use std::sync::Arc;

use crate::db::MemoryDB;
use crate::trie::{EthTrie, Trie, TrieMut};
Expand Down
16 changes: 8 additions & 8 deletions src/trie/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pub fn new_mut(db: &mut D) -> EthTrie<&mut D, D> {
}
}

pub fn new_at_root(db: &mut D, root_hash: H256) -> EthTrie<&mut D, D> {
pub fn new_mut_at_root(db: &mut D, root_hash: H256) -> EthTrie<&mut D, D> {
EthTrie {
root: Node::from_hash(root_hash),
root_hash,
Expand Down Expand Up @@ -442,7 +442,7 @@ mod tests {
assert_eq!(db.get(&node_hash_to_delete).unwrap(), None);

(
trie,
EthTrie::new_mut_at_root(db, actual_root_hash),
actual_root_hash,
node_hash_to_delete,
)
Expand Down Expand Up @@ -643,7 +643,7 @@ mod tests {
trie.commit().unwrap()
};

let mut trie = EthTrie::new_mut(&mut memdb).at_root(root);
let mut trie = EthTrie::new_mut_at_root(&mut memdb,root);
let v1 = trie.get(b"test33").unwrap();
assert_eq!(Some(b"test".to_vec()), v1);
let v2 = trie.get(b"test44").unwrap();
Expand All @@ -666,7 +666,7 @@ mod tests {
trie.commit().unwrap()
};

let mut trie = EthTrie::new_mut(&mut memdb).at_root(root);
let mut trie = EthTrie::new_mut_at_root(&mut memdb,root);
trie.insert(b"test55", b"test55").unwrap();
trie.commit().unwrap();
let v = trie.get(b"test55").unwrap();
Expand All @@ -687,7 +687,7 @@ mod tests {
trie.commit().unwrap()
};

let mut trie = EthTrie::new_mut(&mut memdb).at_root(root);
let mut trie = EthTrie::new_mut_at_root(&mut memdb,root);
let removed = trie.remove(b"test44").unwrap();
assert!(removed);
let removed = trie.remove(b"test33").unwrap();
Expand Down Expand Up @@ -842,7 +842,7 @@ mod tests {
assert!(kv2.is_empty());
}

let trie = EthTrie::new_mut(&mut memdb).at_root(root1);
let trie = EthTrie::new_mut_at_root(&mut memdb,root1);
trie.iter()
.for_each(|(k, v)| assert_eq!(kv.remove(&k).unwrap(), v));
assert!(kv.is_empty());
Expand Down Expand Up @@ -907,7 +907,7 @@ mod tests {
};

let root_hash_2 = {
let mut trie = EthTrie::new_mut(&mut memdb).at_root(root_hash_1);
let mut trie = EthTrie::new_mut_at_root(&mut memdb,root_hash_1);

trie.insert(b"key", b"val_inner").unwrap();
trie.insert(b"key2", b"val_inner").unwrap();
Expand All @@ -923,7 +923,7 @@ mod tests {
};

let _root_hash_3 = {
let mut trie = EthTrie::new_mut( &mut memdb).at_root(root_hash_2);
let mut trie = EthTrie::new_mut_at_root(&mut memdb, root_hash_2);

let removed = trie.remove_all().unwrap();
assert_eq!(removed, 3);
Expand Down
2 changes: 1 addition & 1 deletion tests/trie/trie_utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::BTreeMap, sync::Arc};
use std::collections::BTreeMap;

use eth_trie::{EthTrie, MemoryDB, Trie, TrieMut};
use keccak_hash::H256;
Expand Down

0 comments on commit 8ab9f5b

Please sign in to comment.