Upgrade patricia_trie to use triehash v0.2
Bump patricia_trie to v0.2.1
This commit is contained in:
parent
83e2ce2fc0
commit
42214ad1c4
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "patricia-trie"
|
name = "patricia-trie"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
description = "Merkle-Patricia Trie generic over key hasher and node encoding"
|
description = "Merkle-Patricia Trie generic over key hasher and node encoding"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
|
@ -20,7 +20,7 @@ keccak-hash = { path = "../keccak-hash" }
|
||||||
memorydb = { version = "0.2", path = "../memorydb" }
|
memorydb = { version = "0.2", path = "../memorydb" }
|
||||||
rlp = { version = "0.2.1", path = "../rlp" }
|
rlp = { version = "0.2.1", path = "../rlp" }
|
||||||
trie-standardmap = { path = "../trie-standardmap" }
|
trie-standardmap = { path = "../trie-standardmap" }
|
||||||
triehash = { version = "0.1.0", path = "../triehash" }
|
triehash = { version = "0.2", path = "../triehash" }
|
||||||
|
|
||||||
# REVIEW: what's a better way to deal with this? The tests here in
|
# REVIEW: what's a better way to deal with this? The tests here in
|
||||||
# `patricia_trie` use `keccak-hasher` and `patricia-trie-ethereum` to
|
# `patricia_trie` use `keccak-hasher` and `patricia-trie-ethereum` to
|
||||||
|
|
|
@ -1012,7 +1012,7 @@ mod tests {
|
||||||
count: 100,
|
count: 100,
|
||||||
}.make_with(&mut seed);
|
}.make_with(&mut seed);
|
||||||
|
|
||||||
let real = trie_root(x.clone());
|
let real = trie_root::<KeccakHasher, _, _, _>(x.clone());
|
||||||
let mut memdb = MemoryDB::<KeccakHasher>::new();
|
let mut memdb = MemoryDB::<KeccakHasher>::new();
|
||||||
let mut root = H256::new();
|
let mut root = H256::new();
|
||||||
let mut memtrie = populate_trie::<_, RlpCodec>(&mut memdb, &mut root, &x);
|
let mut memtrie = populate_trie::<_, RlpCodec>(&mut memdb, &mut root, &x);
|
||||||
|
@ -1055,7 +1055,7 @@ mod tests {
|
||||||
let mut root = H256::new();
|
let mut root = H256::new();
|
||||||
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
||||||
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
||||||
assert_eq!(*t.root(), trie_root(vec![ (vec![0x01u8, 0x23], vec![0x01u8, 0x23]) ]));
|
assert_eq!(*t.root(), trie_root::<KeccakHasher, _, _, _>(vec![ (vec![0x01u8, 0x23], vec![0x01u8, 0x23]) ]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1084,7 +1084,7 @@ mod tests {
|
||||||
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
||||||
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
||||||
t.insert(&[0x01u8, 0x23], &[0x23u8, 0x45]).unwrap();
|
t.insert(&[0x01u8, 0x23], &[0x23u8, 0x45]).unwrap();
|
||||||
assert_eq!(*t.root(), trie_root(vec![ (vec![0x01u8, 0x23], vec![0x23u8, 0x45]) ]));
|
assert_eq!(*t.root(), trie_root::<KeccakHasher, _, _, _>(vec![ (vec![0x01u8, 0x23], vec![0x23u8, 0x45]) ]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1094,7 +1094,7 @@ mod tests {
|
||||||
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
||||||
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
||||||
t.insert(&[0x11u8, 0x23], &[0x11u8, 0x23]).unwrap();
|
t.insert(&[0x11u8, 0x23], &[0x11u8, 0x23]).unwrap();
|
||||||
assert_eq!(*t.root(), trie_root(vec![
|
assert_eq!(*t.root(), trie_root::<KeccakHasher, _, _, _>(vec![
|
||||||
(vec![0x01u8, 0x23], vec![0x01u8, 0x23]),
|
(vec![0x01u8, 0x23], vec![0x01u8, 0x23]),
|
||||||
(vec![0x11u8, 0x23], vec![0x11u8, 0x23])
|
(vec![0x11u8, 0x23], vec![0x11u8, 0x23])
|
||||||
]));
|
]));
|
||||||
|
@ -1108,7 +1108,7 @@ mod tests {
|
||||||
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
||||||
t.insert(&[0xf1u8, 0x23], &[0xf1u8, 0x23]).unwrap();
|
t.insert(&[0xf1u8, 0x23], &[0xf1u8, 0x23]).unwrap();
|
||||||
t.insert(&[0x81u8, 0x23], &[0x81u8, 0x23]).unwrap();
|
t.insert(&[0x81u8, 0x23], &[0x81u8, 0x23]).unwrap();
|
||||||
assert_eq!(*t.root(), trie_root(vec![
|
assert_eq!(*t.root(), trie_root::<KeccakHasher, _, _, _>(vec![
|
||||||
(vec![0x01u8, 0x23], vec![0x01u8, 0x23]),
|
(vec![0x01u8, 0x23], vec![0x01u8, 0x23]),
|
||||||
(vec![0x81u8, 0x23], vec![0x81u8, 0x23]),
|
(vec![0x81u8, 0x23], vec![0x81u8, 0x23]),
|
||||||
(vec![0xf1u8, 0x23], vec![0xf1u8, 0x23]),
|
(vec![0xf1u8, 0x23], vec![0xf1u8, 0x23]),
|
||||||
|
@ -1122,7 +1122,7 @@ mod tests {
|
||||||
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
||||||
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
||||||
t.insert(&[], &[0x0]).unwrap();
|
t.insert(&[], &[0x0]).unwrap();
|
||||||
assert_eq!(*t.root(), trie_root(vec![
|
assert_eq!(*t.root(), trie_root::<KeccakHasher, _, _, _>(vec![
|
||||||
(vec![], vec![0x0]),
|
(vec![], vec![0x0]),
|
||||||
(vec![0x01u8, 0x23], vec![0x01u8, 0x23]),
|
(vec![0x01u8, 0x23], vec![0x01u8, 0x23]),
|
||||||
]));
|
]));
|
||||||
|
@ -1135,7 +1135,7 @@ mod tests {
|
||||||
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
||||||
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
|
||||||
t.insert(&[0x01u8, 0x34], &[0x01u8, 0x34]).unwrap();
|
t.insert(&[0x01u8, 0x34], &[0x01u8, 0x34]).unwrap();
|
||||||
assert_eq!(*t.root(), trie_root(vec![
|
assert_eq!(*t.root(), trie_root::<KeccakHasher, _, _, _>(vec![
|
||||||
(vec![0x01u8, 0x23], vec![0x01u8, 0x23]),
|
(vec![0x01u8, 0x23], vec![0x01u8, 0x23]),
|
||||||
(vec![0x01u8, 0x34], vec![0x01u8, 0x34]),
|
(vec![0x01u8, 0x34], vec![0x01u8, 0x34]),
|
||||||
]));
|
]));
|
||||||
|
@ -1149,7 +1149,7 @@ mod tests {
|
||||||
t.insert(&[0x01, 0x23, 0x45], &[0x01]).unwrap();
|
t.insert(&[0x01, 0x23, 0x45], &[0x01]).unwrap();
|
||||||
t.insert(&[0x01, 0xf3, 0x45], &[0x02]).unwrap();
|
t.insert(&[0x01, 0xf3, 0x45], &[0x02]).unwrap();
|
||||||
t.insert(&[0x01, 0xf3, 0xf5], &[0x03]).unwrap();
|
t.insert(&[0x01, 0xf3, 0xf5], &[0x03]).unwrap();
|
||||||
assert_eq!(*t.root(), trie_root(vec![
|
assert_eq!(*t.root(), trie_root::<KeccakHasher, _, _, _>(vec![
|
||||||
(vec![0x01, 0x23, 0x45], vec![0x01]),
|
(vec![0x01, 0x23, 0x45], vec![0x01]),
|
||||||
(vec![0x01, 0xf3, 0x45], vec![0x02]),
|
(vec![0x01, 0xf3, 0x45], vec![0x02]),
|
||||||
(vec![0x01, 0xf3, 0xf5], vec![0x03]),
|
(vec![0x01, 0xf3, 0xf5], vec![0x03]),
|
||||||
|
@ -1166,7 +1166,7 @@ mod tests {
|
||||||
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
||||||
t.insert(&[0x01u8, 0x23], big_value0).unwrap();
|
t.insert(&[0x01u8, 0x23], big_value0).unwrap();
|
||||||
t.insert(&[0x11u8, 0x23], big_value1).unwrap();
|
t.insert(&[0x11u8, 0x23], big_value1).unwrap();
|
||||||
assert_eq!(*t.root(), trie_root(vec![
|
assert_eq!(*t.root(), trie_root::<KeccakHasher, _, _, _>(vec![
|
||||||
(vec![0x01u8, 0x23], big_value0.to_vec()),
|
(vec![0x01u8, 0x23], big_value0.to_vec()),
|
||||||
(vec![0x11u8, 0x23], big_value1.to_vec())
|
(vec![0x11u8, 0x23], big_value1.to_vec())
|
||||||
]));
|
]));
|
||||||
|
@ -1181,7 +1181,7 @@ mod tests {
|
||||||
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
let mut t = TrieDBMut::new(&mut memdb, &mut root);
|
||||||
t.insert(&[0x01u8, 0x23], big_value).unwrap();
|
t.insert(&[0x01u8, 0x23], big_value).unwrap();
|
||||||
t.insert(&[0x11u8, 0x23], big_value).unwrap();
|
t.insert(&[0x11u8, 0x23], big_value).unwrap();
|
||||||
assert_eq!(*t.root(), trie_root(vec![
|
assert_eq!(*t.root(), trie_root::<KeccakHasher, _, _, _>(vec![
|
||||||
(vec![0x01u8, 0x23], big_value.to_vec()),
|
(vec![0x01u8, 0x23], big_value.to_vec()),
|
||||||
(vec![0x11u8, 0x23], big_value.to_vec())
|
(vec![0x11u8, 0x23], big_value.to_vec())
|
||||||
]));
|
]));
|
||||||
|
@ -1237,7 +1237,7 @@ mod tests {
|
||||||
count: 4,
|
count: 4,
|
||||||
}.make_with(&mut seed);
|
}.make_with(&mut seed);
|
||||||
|
|
||||||
let real = trie_root(x.clone());
|
let real = trie_root::<KeccakHasher, _, _, _>(x.clone());
|
||||||
let mut memdb = MemoryDB::<KeccakHasher>::new();
|
let mut memdb = MemoryDB::<KeccakHasher>::new();
|
||||||
let mut root = H256::new();
|
let mut root = H256::new();
|
||||||
let mut memtrie = populate_trie::<_, RlpCodec>(&mut memdb, &mut root, &x);
|
let mut memtrie = populate_trie::<_, RlpCodec>(&mut memdb, &mut root, &x);
|
||||||
|
@ -1295,7 +1295,7 @@ mod tests {
|
||||||
t.insert(key, value).unwrap();
|
t.insert(key, value).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(*t.root(), trie_root(x.clone()));
|
assert_eq!(*t.root(), trie_root::<KeccakHasher, _, _, _>(x.clone()));
|
||||||
|
|
||||||
for &(ref key, _) in &x {
|
for &(ref key, _) in &x {
|
||||||
t.insert(key, &[]).unwrap();
|
t.insert(key, &[]).unwrap();
|
||||||
|
|
Loading…
Reference in New Issue