mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +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:
@@ -18,7 +18,6 @@ codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
client = { package = "substrate-client", path = "../client" }
|
||||
substrate-executor = { path = "../executor" }
|
||||
network = { package = "substrate-network", path = "../network" }
|
||||
primitives = { package = "substrate-primitives", path = "../primitives" }
|
||||
session = { package = "substrate-session", path = "../session" }
|
||||
|
||||
@@ -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