Commit 201bfc3a authored by cheme's avatar cheme

Put tests in their own module.

parent 0594bda8
Pipeline #65243 canceled with stages
in 0 seconds
......@@ -146,40 +146,45 @@ pub type TrieError = trie::TrieError<H256, DecoderError>;
/// Convenience type alias for Keccak/Rlp flavoured trie results
pub type Result<T> = trie::Result<T, H256, DecoderError>;
#[test]
fn test_inline_encoding() {
use crate::{TrieDBMut, trie::TrieMut};
#[cfg(test)]
mod tests {
use ethereum_types::H256;
use crate::{TrieDB, TrieDBMut, trie::TrieMut};
use trie::Trie;
let mut memdb = journaldb::new_memory_db();
let mut root = H256::zero();
{
let mut triedbmut = TrieDBMut::new(&mut memdb, &mut root);
triedbmut.insert(b"foo", b"bar").unwrap();
triedbmut.insert(b"fog", b"b").unwrap();
triedbmut.insert(b"fot", &vec![0u8;33][..]).unwrap();
#[test]
fn test_inline_encoding_branch() {
let mut memdb = journaldb::new_memory_db();
let mut root = H256::zero();
{
let mut triedbmut = TrieDBMut::new(&mut memdb, &mut root);
triedbmut.insert(b"foo", b"bar").unwrap();
triedbmut.insert(b"fog", b"b").unwrap();
triedbmut.insert(b"fot", &vec![0u8;33][..]).unwrap();
}
let t = TrieDB::new(&memdb, &root).unwrap();
assert!(t.contains(b"foo").unwrap());
assert!(t.contains(b"fog").unwrap());
assert_eq!(t.get(b"foo").unwrap().unwrap(), b"bar".to_vec());
assert_eq!(t.get(b"fog").unwrap().unwrap(), b"b".to_vec());
assert_eq!(t.get(b"fot").unwrap().unwrap(), vec![0u8;33]);
}
let t = TrieDB::new(&memdb, &root).unwrap();
assert!(t.contains(b"foo").unwrap());
assert!(t.contains(b"fog").unwrap());
assert_eq!(t.get(b"foo").unwrap().unwrap(), b"bar".to_vec());
assert_eq!(t.get(b"fog").unwrap().unwrap(), b"b".to_vec());
assert_eq!(t.get(b"fot").unwrap().unwrap(), vec![0u8;33]);
}
#[test]
fn test_inline_encoding_extension() {
use crate::{TrieDBMut, trie::TrieMut};
use trie::Trie;
let mut memdb = journaldb::new_memory_db();
let mut root = H256::zero();
{
let mut triedbmut = TrieDBMut::new(&mut memdb, &mut root);
triedbmut.insert(b"foo", b"b").unwrap();
triedbmut.insert(b"fog", b"a").unwrap();
#[test]
fn test_inline_encoding_extension() {
let mut memdb = journaldb::new_memory_db();
let mut root = H256::zero();
{
let mut triedbmut = TrieDBMut::new(&mut memdb, &mut root);
triedbmut.insert(b"foo", b"b").unwrap();
triedbmut.insert(b"fog", b"a").unwrap();
}
let t = TrieDB::new(&memdb, &root).unwrap();
assert!(t.contains(b"foo").unwrap());
assert!(t.contains(b"fog").unwrap());
assert_eq!(t.get(b"foo").unwrap().unwrap(), b"b".to_vec());
assert_eq!(t.get(b"fog").unwrap().unwrap(), b"a".to_vec());
}
let t = TrieDB::new(&memdb, &root).unwrap();
assert!(t.contains(b"foo").unwrap());
assert!(t.contains(b"fog").unwrap());
assert_eq!(t.get(b"foo").unwrap().unwrap(), b"b".to_vec());
assert_eq!(t.get(b"fog").unwrap().unwrap(), b"a".to_vec());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment