From 7ea4e1d48c8883f642bdf850e4a09cfd8ab68e18 Mon Sep 17 00:00:00 2001 From: Johann Tuffe Date: Wed, 22 Aug 2018 18:48:21 +0800 Subject: [PATCH] bump hasdb and memorydb v0.3.0 and fix tests --- hashdb/Cargo.toml | 2 +- memorydb/Cargo.toml | 4 +-- memorydb/src/lib.rs | 26 +++++++++---------- patricia_trie/Cargo.toml | 4 +-- test-support/keccak-hasher/Cargo.toml | 4 +-- .../patricia-trie-ethereum/Cargo.toml | 2 +- triehash/Cargo.toml | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/hashdb/Cargo.toml b/hashdb/Cargo.toml index 8f9793e..a3a1441 100644 --- a/hashdb/Cargo.toml +++ b/hashdb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hashdb" -version = "0.2.1" +version = "0.3.0" authors = ["Parity Technologies "] description = "trait for hash-keyed databases." license = "GPL-3.0" diff --git a/memorydb/Cargo.toml b/memorydb/Cargo.toml index 81b5874..9749cee 100644 --- a/memorydb/Cargo.toml +++ b/memorydb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "memorydb" -version = "0.2.1" +version = "0.3.0" authors = ["Parity Technologies "] description = "in-memory implementation of hashdb" repository = "https://github.com/paritytech/parity-common" @@ -8,7 +8,7 @@ license = "GPL-3.0" [dependencies] heapsize = "0.4" -hashdb = { version = "0.2", path = "../hashdb" } +hashdb = { version = "0.3", path = "../hashdb" } plain_hasher = { version = "0.2", path = "../plain_hasher", default-features = false } rlp = { version = "0.3", path = "../rlp", default-features = false } diff --git a/memorydb/src/lib.rs b/memorydb/src/lib.rs index 9e4c5dc..1759518 100644 --- a/memorydb/src/lib.rs +++ b/memorydb/src/lib.rs @@ -50,12 +50,12 @@ type FastMap = HashMap<::Out, T, hash::BuildHasherDefault< /// use keccak_hasher::KeccakHasher; /// use memorydb::*; /// fn main() { -/// let mut m = MemoryDB::::new(); +/// let mut m = MemoryDB::>::new(); /// let d = "Hello world!".as_bytes(); /// /// let k = m.insert(d); /// assert!(m.contains(&k)); -/// assert_eq!(m.get(&k).unwrap(), d); +/// assert_eq!(m.get(&k).unwrap(), &d); /// /// m.insert(d); /// assert!(m.contains(&k)); @@ -74,7 +74,7 @@ type FastMap = HashMap<::Out, T, hash::BuildHasherDefault< /// m.insert(d); /// assert!(m.contains(&k)); -/// assert_eq!(m.get(&k).unwrap(), d); +/// assert_eq!(m.get(&k).unwrap(), &d); /// /// m.remove(&k); /// assert!(!m.contains(&k)); @@ -153,7 +153,7 @@ impl MemoryDB { /// use memorydb::*; /// /// fn main() { - /// let mut m = MemoryDB::::new(); + /// let mut m = MemoryDB::>::new(); /// let hello_bytes = "Hello world!".as_bytes(); /// let hash = m.insert(hello_bytes); /// assert!(m.contains(&hash)); @@ -332,7 +332,7 @@ mod tests { Keccak::keccak256(hello_bytes, &mut hello_key); let hello_key = H256(hello_key); - let mut m = MemoryDB::::new(); + let mut m = MemoryDB::>::new(); m.remove(&hello_key); assert_eq!(m.raw(&hello_key).unwrap().1, -1); m.purge(); @@ -342,7 +342,7 @@ mod tests { m.purge(); assert_eq!(m.raw(&hello_key), None); - let mut m = MemoryDB::::new(); + let mut m = MemoryDB::>::new(); assert!(m.remove_and_purge(&hello_key).is_none()); assert_eq!(m.raw(&hello_key).unwrap().1, -1); m.insert(hello_bytes); @@ -355,13 +355,13 @@ mod tests { #[test] fn consolidate() { - let mut main = MemoryDB::::new(); - let mut other = MemoryDB::::new(); + let mut main = MemoryDB::>::new(); + let mut other = MemoryDB::>::new(); let remove_key = other.insert(b"doggo"); main.remove(&remove_key); let insert_key = other.insert(b"arf"); - main.emplace(insert_key, DBValue::from_slice(b"arf")); + main.emplace(insert_key, "arf".as_bytes().to_vec()); let negative_remove_key = other.insert(b"negative"); other.remove(&negative_remove_key); // ref cnt: 0 @@ -372,14 +372,14 @@ mod tests { let overlay = main.drain(); - assert_eq!(overlay.get(&remove_key).unwrap(), &(DBValue::from_slice(b"doggo"), 0)); - assert_eq!(overlay.get(&insert_key).unwrap(), &(DBValue::from_slice(b"arf"), 2)); - assert_eq!(overlay.get(&negative_remove_key).unwrap(), &(DBValue::from_slice(b"negative"), -2)); + assert_eq!(overlay.get(&remove_key).unwrap(), &("doggo".as_bytes().to_vec(), 0)); + assert_eq!(overlay.get(&insert_key).unwrap(), &("arf".as_bytes().to_vec(), 2)); + assert_eq!(overlay.get(&negative_remove_key).unwrap(), &("negative".as_bytes().to_vec(), -2)); } #[test] fn default_works() { - let mut db = MemoryDB::::default(); + let mut db = MemoryDB::>::default(); let hashed_null_node = KeccakHasher::hash(&NULL_RLP); assert_eq!(db.insert(&NULL_RLP), hashed_null_node); } diff --git a/patricia_trie/Cargo.toml b/patricia_trie/Cargo.toml index 0a51fcd..c374ba3 100644 --- a/patricia_trie/Cargo.toml +++ b/patricia_trie/Cargo.toml @@ -10,14 +10,14 @@ license = "GPL-3.0" elastic-array = "0.10" log = "0.3" rand = "0.4" -hashdb = { version = "0.2", path = "../hashdb" } +hashdb = { version = "0.3", path = "../hashdb" } parity-bytes = { version = "0.1", path = "../parity-bytes" } [dev-dependencies] env_logger = "0.5" ethereum-types = "0.4" keccak-hash = { version = "0.1", path = "../keccak-hash" } -memorydb = { version = "0.2", path = "../memorydb", default-features = false } +memorydb = { version = "0.3", path = "../memorydb", default-features = false } rlp = { version = "0.3.0", path = "../rlp", default-features = false } trie-standardmap = { version = "0.1", path = "../trie-standardmap", default-features = false } triehash = { version = "0.2", path = "../triehash", default-features = false } diff --git a/test-support/keccak-hasher/Cargo.toml b/test-support/keccak-hasher/Cargo.toml index 08f19c7..53d07d0 100644 --- a/test-support/keccak-hasher/Cargo.toml +++ b/test-support/keccak-hasher/Cargo.toml @@ -9,5 +9,5 @@ license = "GPL-3.0" [dependencies] ethereum-types = "0.4" tiny-keccak = "1.4.2" -hashdb = { version = "0.2.0", path = "../../hashdb" } -plain_hasher = { path = "../../plain_hasher" } \ No newline at end of file +hashdb = { version = "0.3.0", path = "../../hashdb" } +plain_hasher = { path = "../../plain_hasher" } diff --git a/test-support/patricia-trie-ethereum/Cargo.toml b/test-support/patricia-trie-ethereum/Cargo.toml index 5665504..a219c76 100644 --- a/test-support/patricia-trie-ethereum/Cargo.toml +++ b/test-support/patricia-trie-ethereum/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" [dependencies] patricia-trie = { version = "0.3", path = "../../patricia_trie" } keccak-hasher = { version = "0.1", path = "../keccak-hasher" } -hashdb = { version = "0.2", path = "../../hashdb" } +hashdb = { version = "0.3", path = "../../hashdb" } rlp = { version = "0.3.0", path = "../../rlp" } parity-bytes = { version = "0.1", path = "../../parity-bytes" } diff --git a/triehash/Cargo.toml b/triehash/Cargo.toml index 3d39c77..c7bf6c0 100644 --- a/triehash/Cargo.toml +++ b/triehash/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" [dependencies] elastic-array = "0.10" -hashdb = { version = "0.2", path = "../hashdb", default-features = false } +hashdb = { version = "0.3", path = "../hashdb", default-features = false } rlp = { version = "0.3", path = "../rlp", default-features = false } [dev-dependencies]