bump hasdb and memorydb v0.3.0 and fix tests

This commit is contained in:
Johann Tuffe 2018-08-22 18:48:21 +08:00
parent 5f7d0e2ec6
commit 7ea4e1d48c
7 changed files with 22 additions and 22 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "hashdb"
version = "0.2.1"
version = "0.3.0"
authors = ["Parity Technologies <admin@parity.io>"]
description = "trait for hash-keyed databases."
license = "GPL-3.0"

View File

@ -1,6 +1,6 @@
[package]
name = "memorydb"
version = "0.2.1"
version = "0.3.0"
authors = ["Parity Technologies <admin@parity.io>"]
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 }

View File

@ -50,12 +50,12 @@ type FastMap<H, T> = HashMap<<H as KeyHasher>::Out, T, hash::BuildHasherDefault<
/// use keccak_hasher::KeccakHasher;
/// use memorydb::*;
/// fn main() {
/// let mut m = MemoryDB::<KeccakHasher>::new();
/// let mut m = MemoryDB::<KeccakHasher, Vec<u8>>::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<H, T> = HashMap<<H as KeyHasher>::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<H: KeyHasher, T> MemoryDB<H, T> {
/// use memorydb::*;
///
/// fn main() {
/// let mut m = MemoryDB::<KeccakHasher>::new();
/// let mut m = MemoryDB::<KeccakHasher, Vec<u8>>::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::<KeccakHasher>::new();
let mut m = MemoryDB::<KeccakHasher, Vec<u8>>::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::<KeccakHasher>::new();
let mut m = MemoryDB::<KeccakHasher, Vec<u8>>::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::<KeccakHasher>::new();
let mut other = MemoryDB::<KeccakHasher>::new();
let mut main = MemoryDB::<KeccakHasher, Vec<u8>>::new();
let mut other = MemoryDB::<KeccakHasher, Vec<u8>>::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::<KeccakHasher>::default();
let mut db = MemoryDB::<KeccakHasher, Vec<u8>>::default();
let hashed_null_node = KeccakHasher::hash(&NULL_RLP);
assert_eq!(db.insert(&NULL_RLP), hashed_null_node);
}

View File

@ -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 }

View File

@ -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" }
hashdb = { version = "0.3.0", path = "../../hashdb" }
plain_hasher = { path = "../../plain_hasher" }

View File

@ -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" }

View File

@ -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]