Skip to content
Snippets Groups Projects
Commit 31da4d24 authored by Bastian Köcher's avatar Bastian Köcher Committed by Gavin Wood
Browse files

Don't set `HEAP_PAGES` in `BasicExternalities` (#3244)

* Don't set `HEAP_PAGES` in `BasicExternalities`

* Fix test
parent 04c115a6
No related merge requests found
......@@ -22,8 +22,7 @@ use crate::backend::{Backend, InMemory};
use hash_db::Hasher;
use trie::trie_root;
use primitives::offchain;
use primitives::storage::well_known_keys::{HEAP_PAGES, is_child_storage_key};
use parity_codec::Encode;
use primitives::storage::well_known_keys::is_child_storage_key;
use super::{ChildStorageKey, Externalities};
use log::warn;
......@@ -42,10 +41,9 @@ impl BasicExternalities {
/// Create a new instance of `BasicExternalities` with children
pub fn new_with_children(
mut top: HashMap<Vec<u8>, Vec<u8>>,
top: HashMap<Vec<u8>, Vec<u8>>,
children: HashMap<Vec<u8>, HashMap<Vec<u8>, Vec<u8>>>,
) -> Self {
top.insert(HEAP_PAGES.to_vec(), 8u64.encode());
BasicExternalities {
top,
children,
......@@ -188,7 +186,7 @@ mod tests {
ext.set_storage(b"doe".to_vec(), b"reindeer".to_vec());
ext.set_storage(b"dog".to_vec(), b"puppy".to_vec());
ext.set_storage(b"dogglesworth".to_vec(), b"cat".to_vec());
const ROOT: [u8; 32] = hex!("0b33ed94e74e0f8e92a55923bece1ed02d16cf424e124613ddebc53ac3eeeabe");
const ROOT: [u8; 32] = hex!("0b41e488cccbd67d1f1089592c2c235f5c5399b053f7fe9152dd4b5f279914cd");
assert_eq!(ext.storage_root(), H256::from(ROOT));
}
......@@ -231,4 +229,12 @@ mod tests {
ext.kill_child_storage(child());
assert_eq!(ext.child_storage(child(), b"doe"), None);
}
#[test]
fn basic_externalities_is_empty() {
// Make sure no values are set by default in `BasicExternalities`.
let (storage, child_storage) = BasicExternalities::new(Default::default()).into_storages();
assert!(storage.is_empty());
assert!(child_storage.is_empty());
}
}
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