bump hasdb and memorydb v0.3.0 and fix tests
This commit is contained in:
parent
5f7d0e2ec6
commit
7ea4e1d48c
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "hashdb"
|
name = "hashdb"
|
||||||
version = "0.2.1"
|
version = "0.3.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
description = "trait for hash-keyed databases."
|
description = "trait for hash-keyed databases."
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "memorydb"
|
name = "memorydb"
|
||||||
version = "0.2.1"
|
version = "0.3.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
description = "in-memory implementation of hashdb"
|
description = "in-memory implementation of hashdb"
|
||||||
repository = "https://github.com/paritytech/parity-common"
|
repository = "https://github.com/paritytech/parity-common"
|
||||||
|
@ -8,7 +8,7 @@ license = "GPL-3.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
heapsize = "0.4"
|
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 }
|
plain_hasher = { version = "0.2", path = "../plain_hasher", default-features = false }
|
||||||
rlp = { version = "0.3", path = "../rlp", default-features = false }
|
rlp = { version = "0.3", path = "../rlp", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,12 @@ type FastMap<H, T> = HashMap<<H as KeyHasher>::Out, T, hash::BuildHasherDefault<
|
||||||
/// use keccak_hasher::KeccakHasher;
|
/// use keccak_hasher::KeccakHasher;
|
||||||
/// use memorydb::*;
|
/// use memorydb::*;
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let mut m = MemoryDB::<KeccakHasher>::new();
|
/// let mut m = MemoryDB::<KeccakHasher, Vec<u8>>::new();
|
||||||
/// let d = "Hello world!".as_bytes();
|
/// let d = "Hello world!".as_bytes();
|
||||||
///
|
///
|
||||||
/// let k = m.insert(d);
|
/// let k = m.insert(d);
|
||||||
/// assert!(m.contains(&k));
|
/// assert!(m.contains(&k));
|
||||||
/// assert_eq!(m.get(&k).unwrap(), d);
|
/// assert_eq!(m.get(&k).unwrap(), &d);
|
||||||
///
|
///
|
||||||
/// m.insert(d);
|
/// m.insert(d);
|
||||||
/// assert!(m.contains(&k));
|
/// assert!(m.contains(&k));
|
||||||
|
@ -74,7 +74,7 @@ type FastMap<H, T> = HashMap<<H as KeyHasher>::Out, T, hash::BuildHasherDefault<
|
||||||
|
|
||||||
/// m.insert(d);
|
/// m.insert(d);
|
||||||
/// assert!(m.contains(&k));
|
/// assert!(m.contains(&k));
|
||||||
/// assert_eq!(m.get(&k).unwrap(), d);
|
/// assert_eq!(m.get(&k).unwrap(), &d);
|
||||||
///
|
///
|
||||||
/// m.remove(&k);
|
/// m.remove(&k);
|
||||||
/// assert!(!m.contains(&k));
|
/// assert!(!m.contains(&k));
|
||||||
|
@ -153,7 +153,7 @@ impl<H: KeyHasher, T> MemoryDB<H, T> {
|
||||||
/// use memorydb::*;
|
/// use memorydb::*;
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let mut m = MemoryDB::<KeccakHasher>::new();
|
/// let mut m = MemoryDB::<KeccakHasher, Vec<u8>>::new();
|
||||||
/// let hello_bytes = "Hello world!".as_bytes();
|
/// let hello_bytes = "Hello world!".as_bytes();
|
||||||
/// let hash = m.insert(hello_bytes);
|
/// let hash = m.insert(hello_bytes);
|
||||||
/// assert!(m.contains(&hash));
|
/// assert!(m.contains(&hash));
|
||||||
|
@ -332,7 +332,7 @@ mod tests {
|
||||||
Keccak::keccak256(hello_bytes, &mut hello_key);
|
Keccak::keccak256(hello_bytes, &mut hello_key);
|
||||||
let hello_key = H256(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);
|
m.remove(&hello_key);
|
||||||
assert_eq!(m.raw(&hello_key).unwrap().1, -1);
|
assert_eq!(m.raw(&hello_key).unwrap().1, -1);
|
||||||
m.purge();
|
m.purge();
|
||||||
|
@ -342,7 +342,7 @@ mod tests {
|
||||||
m.purge();
|
m.purge();
|
||||||
assert_eq!(m.raw(&hello_key), None);
|
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!(m.remove_and_purge(&hello_key).is_none());
|
||||||
assert_eq!(m.raw(&hello_key).unwrap().1, -1);
|
assert_eq!(m.raw(&hello_key).unwrap().1, -1);
|
||||||
m.insert(hello_bytes);
|
m.insert(hello_bytes);
|
||||||
|
@ -355,13 +355,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn consolidate() {
|
fn consolidate() {
|
||||||
let mut main = MemoryDB::<KeccakHasher>::new();
|
let mut main = MemoryDB::<KeccakHasher, Vec<u8>>::new();
|
||||||
let mut other = MemoryDB::<KeccakHasher>::new();
|
let mut other = MemoryDB::<KeccakHasher, Vec<u8>>::new();
|
||||||
let remove_key = other.insert(b"doggo");
|
let remove_key = other.insert(b"doggo");
|
||||||
main.remove(&remove_key);
|
main.remove(&remove_key);
|
||||||
|
|
||||||
let insert_key = other.insert(b"arf");
|
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");
|
let negative_remove_key = other.insert(b"negative");
|
||||||
other.remove(&negative_remove_key); // ref cnt: 0
|
other.remove(&negative_remove_key); // ref cnt: 0
|
||||||
|
@ -372,14 +372,14 @@ mod tests {
|
||||||
|
|
||||||
let overlay = main.drain();
|
let overlay = main.drain();
|
||||||
|
|
||||||
assert_eq!(overlay.get(&remove_key).unwrap(), &(DBValue::from_slice(b"doggo"), 0));
|
assert_eq!(overlay.get(&remove_key).unwrap(), &("doggo".as_bytes().to_vec(), 0));
|
||||||
assert_eq!(overlay.get(&insert_key).unwrap(), &(DBValue::from_slice(b"arf"), 2));
|
assert_eq!(overlay.get(&insert_key).unwrap(), &("arf".as_bytes().to_vec(), 2));
|
||||||
assert_eq!(overlay.get(&negative_remove_key).unwrap(), &(DBValue::from_slice(b"negative"), -2));
|
assert_eq!(overlay.get(&negative_remove_key).unwrap(), &("negative".as_bytes().to_vec(), -2));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn default_works() {
|
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);
|
let hashed_null_node = KeccakHasher::hash(&NULL_RLP);
|
||||||
assert_eq!(db.insert(&NULL_RLP), hashed_null_node);
|
assert_eq!(db.insert(&NULL_RLP), hashed_null_node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,14 @@ license = "GPL-3.0"
|
||||||
elastic-array = "0.10"
|
elastic-array = "0.10"
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
rand = "0.4"
|
rand = "0.4"
|
||||||
hashdb = { version = "0.2", path = "../hashdb" }
|
hashdb = { version = "0.3", path = "../hashdb" }
|
||||||
parity-bytes = { version = "0.1", path = "../parity-bytes" }
|
parity-bytes = { version = "0.1", path = "../parity-bytes" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.5"
|
env_logger = "0.5"
|
||||||
ethereum-types = "0.4"
|
ethereum-types = "0.4"
|
||||||
keccak-hash = { version = "0.1", path = "../keccak-hash" }
|
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 }
|
rlp = { version = "0.3.0", path = "../rlp", default-features = false }
|
||||||
trie-standardmap = { version = "0.1", path = "../trie-standardmap", default-features = false }
|
trie-standardmap = { version = "0.1", path = "../trie-standardmap", default-features = false }
|
||||||
triehash = { version = "0.2", path = "../triehash", default-features = false }
|
triehash = { version = "0.2", path = "../triehash", default-features = false }
|
||||||
|
|
|
@ -9,5 +9,5 @@ license = "GPL-3.0"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ethereum-types = "0.4"
|
ethereum-types = "0.4"
|
||||||
tiny-keccak = "1.4.2"
|
tiny-keccak = "1.4.2"
|
||||||
hashdb = { version = "0.2.0", path = "../../hashdb" }
|
hashdb = { version = "0.3.0", path = "../../hashdb" }
|
||||||
plain_hasher = { path = "../../plain_hasher" }
|
plain_hasher = { path = "../../plain_hasher" }
|
|
@ -8,7 +8,7 @@ license = "GPL-3.0"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
patricia-trie = { version = "0.3", path = "../../patricia_trie" }
|
patricia-trie = { version = "0.3", path = "../../patricia_trie" }
|
||||||
keccak-hasher = { version = "0.1", path = "../keccak-hasher" }
|
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" }
|
rlp = { version = "0.3.0", path = "../../rlp" }
|
||||||
parity-bytes = { version = "0.1", path = "../../parity-bytes" }
|
parity-bytes = { version = "0.1", path = "../../parity-bytes" }
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ license = "GPL-3.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
elastic-array = "0.10"
|
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 }
|
rlp = { version = "0.3", path = "../rlp", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
Loading…
Reference in New Issue