Eradicate native_equivalent (#3494)

* Add ability to supply extra storage in test-client

* Don't use native_equivalent in tests.

* Get rid of native_equivalent

* Try to make fields private

* Apply Basti's suggestions

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Sergei Pepyakin
2019-08-27 22:20:47 +02:00
committed by GitHub
parent 095c7de7ff
commit 36ef4c067b
9 changed files with 70 additions and 51 deletions
+10 -6
View File
@@ -25,20 +25,24 @@ use test_client::{
consensus::BlockOrigin,
runtime,
};
use substrate_executor::NativeExecutionDispatch;
#[test]
fn should_return_storage() {
const KEY: &[u8] = b":mock";
const VALUE: &[u8] = b"hello world";
let core = tokio::runtime::Runtime::new().unwrap();
let client = Arc::new(test_client::new());
let client = TestClientBuilder::new()
.add_extra_storage(KEY.to_vec(), VALUE.to_vec())
.build();
let genesis_hash = client.genesis_hash();
let client = State::new(client, Subscriptions::new(Arc::new(core.executor())));
let key = StorageKey(b":code".to_vec());
let client = State::new(Arc::new(client), Subscriptions::new(Arc::new(core.executor())));
let key = StorageKey(KEY.to_vec());
assert_eq!(
client.storage(key.clone(), Some(genesis_hash).into())
.map(|x| x.map(|x| x.0.len())).unwrap().unwrap() as usize,
LocalExecutor::native_equivalent().len(),
VALUE.len(),
);
assert_matches!(
client.storage_hash(key.clone(), Some(genesis_hash).into()).map(|x| x.is_some()),
@@ -46,7 +50,7 @@ fn should_return_storage() {
);
assert_eq!(
client.storage_size(key.clone(), None).unwrap().unwrap() as usize,
LocalExecutor::native_equivalent().len(),
VALUE.len(),
);
}