mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 07:47:57 +00:00
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:
@@ -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(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user