mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Make test-client generic over runtime (#2824)
* Make test-client generic over runtime. * Make sure genesis storage is constructed correctly. * Use prelude in tests. * Add an example of how to use test-client with node/runtime. * Bump version. * Rename test-clients.
This commit is contained in:
committed by
Bastian Köcher
parent
cae324598f
commit
ad2d958248
@@ -16,9 +16,11 @@
|
||||
|
||||
use super::*;
|
||||
use assert_matches::assert_matches;
|
||||
use test_client::{self, TestClient};
|
||||
use test_client::runtime::{H256, Block, Header};
|
||||
use consensus::BlockOrigin;
|
||||
use test_client::{
|
||||
prelude::*,
|
||||
consensus::BlockOrigin,
|
||||
runtime::{H256, Block, Header},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn should_return_header() {
|
||||
|
||||
@@ -18,10 +18,13 @@ use super::*;
|
||||
use self::error::Error;
|
||||
|
||||
use assert_matches::assert_matches;
|
||||
use consensus::BlockOrigin;
|
||||
use primitives::storage::well_known_keys;
|
||||
use sr_io::blake2_256;
|
||||
use test_client::{self, runtime, AccountKeyring, TestClient, BlockBuilderExt, LocalExecutor, TestClientBuilder};
|
||||
use test_client::{
|
||||
prelude::*,
|
||||
consensus::BlockOrigin,
|
||||
runtime,
|
||||
};
|
||||
use substrate_executor::NativeExecutionDispatch;
|
||||
|
||||
#[test]
|
||||
@@ -50,7 +53,9 @@ fn should_return_storage() {
|
||||
#[test]
|
||||
fn should_return_child_storage() {
|
||||
let core = tokio::runtime::Runtime::new().unwrap();
|
||||
let client = Arc::new(test_client::new());
|
||||
let client = Arc::new(test_client::TestClientBuilder::new()
|
||||
.add_child_storage("test", "key", vec![42_u8])
|
||||
.build());
|
||||
let genesis_hash = client.genesis_hash();
|
||||
let client = State::new(client, Subscriptions::new(core.executor()));
|
||||
let child_key = StorageKey(well_known_keys::CHILD_STORAGE_KEY_PREFIX.iter().chain(b"test").cloned().collect());
|
||||
@@ -125,7 +130,7 @@ fn should_send_initial_storage_changes_and_notifications() {
|
||||
{
|
||||
let api = State::new(Arc::new(test_client::new()), Subscriptions::new(remote));
|
||||
|
||||
let alice_balance_key = blake2_256(&test_runtime::system::balance_of_key(AccountKeyring::Alice.into()));
|
||||
let alice_balance_key = blake2_256(&runtime::system::balance_of_key(AccountKeyring::Alice.into()));
|
||||
|
||||
api.subscribe_storage(Default::default(), subscriber, Some(vec![
|
||||
StorageKey(alice_balance_key.to_vec()),
|
||||
@@ -156,13 +161,6 @@ fn should_send_initial_storage_changes_and_notifications() {
|
||||
|
||||
#[test]
|
||||
fn should_query_storage() {
|
||||
type TestClient = test_client::client::Client<
|
||||
test_client::Backend,
|
||||
test_client::Executor,
|
||||
runtime::Block,
|
||||
runtime::RuntimeApi
|
||||
>;
|
||||
|
||||
fn run_tests(client: Arc<TestClient>) {
|
||||
let core = tokio::runtime::Runtime::new().unwrap();
|
||||
let api = State::new(client.clone(), Subscriptions::new(core.executor()));
|
||||
@@ -184,7 +182,7 @@ fn should_query_storage() {
|
||||
let block2_hash = add_block(1);
|
||||
let genesis_hash = client.genesis_hash();
|
||||
|
||||
let alice_balance_key = blake2_256(&test_runtime::system::balance_of_key(AccountKeyring::Alice.into()));
|
||||
let alice_balance_key = blake2_256(&runtime::system::balance_of_key(AccountKeyring::Alice.into()));
|
||||
|
||||
let mut expected = vec![
|
||||
StorageChangeSet {
|
||||
|
||||
Reference in New Issue
Block a user