[big refactor] Remove crate aliasing. (#4395)

* Rename: Phase 1.

* Unify codec.

* Fixing: Phase 2

* Fixing: Phase 3.

* Fixing: Phase 4.

* Fixing: Phase 5.

* Fixing: Phase 6.

* Fixing: Phase 7.

* Fixing: Phase 8. Tests

* Fixing: Phase 9. Tests!!!

* Fixing: Phase 10. Moar tests!

* Finally done!

* More fixes.

* Rename primitives:: to sp_core::

* Apply renames in finality-grandpa.

* Fix benches.

* Fix benches 2.

* Revert node-template.

* Fix frame-system in our modules.
This commit is contained in:
Tomasz Drwięga
2019-12-16 13:36:49 +01:00
committed by Gavin Wood
parent f14d98a439
commit 8778ca7dc8
485 changed files with 4023 additions and 4005 deletions
@@ -16,15 +16,15 @@
//! Block Builder extensions for tests.
use runtime;
use substrate_test_runtime;
use sp_runtime::traits::ProvideRuntimeApi;
use block_builder::BlockBuilderApi;
use sc_block_builder::BlockBuilderApi;
/// Extension trait for test block builder.
pub trait BlockBuilderExt {
/// Add transfer extrinsic to the block.
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), sp_blockchain::Error>;
fn push_transfer(&mut self, transfer: substrate_test_runtime::Transfer) -> Result<(), sp_blockchain::Error>;
/// Add storage change extrinsic to the block.
fn push_storage_change(
&mut self,
@@ -33,11 +33,11 @@ pub trait BlockBuilderExt {
) -> Result<(), sp_blockchain::Error>;
}
impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block, A> where
impl<'a, A> BlockBuilderExt for sc_block_builder::BlockBuilder<'a, substrate_test_runtime::Block, A> where
A: ProvideRuntimeApi + 'a,
A::Api: BlockBuilderApi<runtime::Block, Error = sp_blockchain::Error>,
A::Api: BlockBuilderApi<substrate_test_runtime::Block, Error = sp_blockchain::Error>,
{
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), sp_blockchain::Error> {
fn push_transfer(&mut self, transfer: substrate_test_runtime::Transfer) -> Result<(), sp_blockchain::Error> {
self.push(transfer.into_signed_tx())
}
@@ -46,6 +46,6 @@ impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block,
key: Vec<u8>,
value: Option<Vec<u8>>,
) -> Result<(), sp_blockchain::Error> {
self.push(runtime::Extrinsic::StorageChange(key, value))
self.push(substrate_test_runtime::Extrinsic::StorageChange(key, value))
}
}
+50 -48
View File
@@ -24,15 +24,16 @@ mod block_builder_ext;
use std::sync::Arc;
use std::collections::HashMap;
pub use block_builder_ext::BlockBuilderExt;
pub use generic_test_client::*;
pub use runtime;
pub use substrate_test_client::*;
pub use substrate_test_runtime as runtime;
use primitives::sr25519;
use primitives::storage::{ChildInfo, Storage, StorageChild};
use runtime::genesismap::{GenesisConfig, additional_storage_with_genesis};
pub use self::block_builder_ext::BlockBuilderExt;
use sp_core::sr25519;
use sp_core::storage::{ChildInfo, Storage, StorageChild};
use substrate_test_runtime::genesismap::{GenesisConfig, additional_storage_with_genesis};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, NumberFor};
use client::{
use sc_client::{
light::fetcher::{
Fetcher,
RemoteHeaderRequest, RemoteReadRequest, RemoteReadChildRequest,
@@ -56,37 +57,37 @@ pub mod prelude {
mod local_executor {
#![allow(missing_docs)]
use runtime;
use crate::executor::native_executor_instance;
use substrate_test_runtime;
use crate::sc_executor::native_executor_instance;
// FIXME #1576 change the macro and pass in the `BlakeHasher` that dispatch needs from here instead
native_executor_instance!(
pub LocalExecutor,
runtime::api::dispatch,
runtime::native_version
substrate_test_runtime::api::dispatch,
substrate_test_runtime::native_version
);
}
/// Native executor used for tests.
pub use local_executor::LocalExecutor;
pub use self::local_executor::LocalExecutor;
/// Test client database backend.
pub type Backend = generic_test_client::Backend<runtime::Block>;
pub type Backend = substrate_test_client::Backend<substrate_test_runtime::Block>;
/// Test client executor.
pub type Executor = client::LocalCallExecutor<
pub type Executor = sc_client::LocalCallExecutor<
Backend,
NativeExecutor<LocalExecutor>,
>;
/// Test client light database backend.
pub type LightBackend = generic_test_client::LightBackend<runtime::Block>;
pub type LightBackend = substrate_test_client::LightBackend<substrate_test_runtime::Block>;
/// Test client light executor.
pub type LightExecutor = client::light::call_executor::GenesisCallExecutor<
pub type LightExecutor = sc_client::light::call_executor::GenesisCallExecutor<
LightBackend,
client::LocalCallExecutor<
client::light::backend::Backend<
client_db::light::LightStorage<runtime::Block>,
sc_client::LocalCallExecutor<
sc_client::light::backend::Backend<
sc_client_db::light::LightStorage<substrate_test_runtime::Block>,
Blake2Hasher,
>,
NativeExecutor<LocalExecutor>
@@ -122,9 +123,10 @@ impl GenesisParameters {
}
}
impl generic_test_client::GenesisInit for GenesisParameters {
impl substrate_test_client::GenesisInit for GenesisParameters {
fn genesis_storage(&self) -> Storage {
use codec::Encode;
let mut storage = self.genesis_config().genesis_map();
let child_roots = storage.children.iter().map(|(sk, child_content)| {
@@ -136,7 +138,7 @@ impl generic_test_client::GenesisInit for GenesisParameters {
let state_root = <<<runtime::Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
storage.top.clone().into_iter().chain(child_roots).collect()
);
let block: runtime::Block = client::genesis::construct_genesis_block(state_root);
let block: runtime::Block = sc_client::genesis::construct_genesis_block(state_root);
storage.top.extend(additional_storage_with_genesis(&block));
storage
@@ -144,14 +146,14 @@ impl generic_test_client::GenesisInit for GenesisParameters {
}
/// A `TestClient` with `test-runtime` builder.
pub type TestClientBuilder<E, B> = generic_test_client::TestClientBuilder<E, B, GenesisParameters>;
pub type TestClientBuilder<E, B> = substrate_test_client::TestClientBuilder<E, B, GenesisParameters>;
/// Test client type with `LocalExecutor` and generic Backend.
pub type Client<B> = client::Client<
pub type Client<B> = sc_client::Client<
B,
client::LocalCallExecutor<B, executor::NativeExecutor<LocalExecutor>>,
runtime::Block,
runtime::RuntimeApi,
sc_client::LocalCallExecutor<B, sc_executor::NativeExecutor<LocalExecutor>>,
substrate_test_runtime::Block,
substrate_test_runtime::RuntimeApi,
>;
/// A test client with default backend.
@@ -206,14 +208,14 @@ pub trait TestClientBuilderExt<B>: Sized {
}
/// Build the test client and longest chain selector.
fn build_with_longest_chain(self) -> (Client<B>, client::LongestChain<B, runtime::Block>);
fn build_with_longest_chain(self) -> (Client<B>, sc_client::LongestChain<B, substrate_test_runtime::Block>);
}
impl<B> TestClientBuilderExt<B> for TestClientBuilder<
client::LocalCallExecutor<B, executor::NativeExecutor<LocalExecutor>>,
sc_client::LocalCallExecutor<B, sc_executor::NativeExecutor<LocalExecutor>>,
B
> where
B: client_api::backend::Backend<runtime::Block, Blake2Hasher>,
B: sc_client_api::backend::Backend<substrate_test_runtime::Block, Blake2Hasher>,
{
fn set_heap_pages(mut self, heap_pages: u64) -> Self {
self.genesis_init_mut().heap_pages_override = Some(heap_pages);
@@ -253,7 +255,7 @@ impl<B> TestClientBuilderExt<B> for TestClientBuilder<
}
fn build_with_longest_chain(self) -> (Client<B>, client::LongestChain<B, runtime::Block>) {
fn build_with_longest_chain(self) -> (Client<B>, sc_client::LongestChain<B, substrate_test_runtime::Block>) {
self.build_with_native_executor(None)
}
}
@@ -267,15 +269,15 @@ type FetcherFutureResult<Resp> = futures::future::Ready<Result<Resp, sp_blockcha
/// Implementation of light client fetcher used in tests.
#[derive(Default)]
pub struct LightFetcher {
call: MaybeFetcherCallback<RemoteCallRequest<runtime::Header>, Vec<u8>>,
body: MaybeFetcherCallback<RemoteBodyRequest<runtime::Header>, Vec<runtime::Extrinsic>>,
call: MaybeFetcherCallback<RemoteCallRequest<substrate_test_runtime::Header>, Vec<u8>>,
body: MaybeFetcherCallback<RemoteBodyRequest<substrate_test_runtime::Header>, Vec<substrate_test_runtime::Extrinsic>>,
}
impl LightFetcher {
/// Sets remote call callback.
pub fn with_remote_call(
self,
call: MaybeFetcherCallback<RemoteCallRequest<runtime::Header>, Vec<u8>>,
call: MaybeFetcherCallback<RemoteCallRequest<substrate_test_runtime::Header>, Vec<u8>>,
) -> Self {
LightFetcher {
call,
@@ -286,7 +288,7 @@ impl LightFetcher {
/// Sets remote body callback.
pub fn with_remote_body(
self,
body: MaybeFetcherCallback<RemoteBodyRequest<runtime::Header>, Vec<runtime::Extrinsic>>,
body: MaybeFetcherCallback<RemoteBodyRequest<substrate_test_runtime::Header>, Vec<substrate_test_runtime::Extrinsic>>,
) -> Self {
LightFetcher {
call: self.call,
@@ -295,37 +297,37 @@ impl LightFetcher {
}
}
impl Fetcher<runtime::Block> for LightFetcher {
type RemoteHeaderResult = FetcherFutureResult<runtime::Header>;
impl Fetcher<substrate_test_runtime::Block> for LightFetcher {
type RemoteHeaderResult = FetcherFutureResult<substrate_test_runtime::Header>;
type RemoteReadResult = FetcherFutureResult<HashMap<Vec<u8>, Option<Vec<u8>>>>;
type RemoteCallResult = FetcherFutureResult<Vec<u8>>;
type RemoteChangesResult = FetcherFutureResult<Vec<(NumberFor<runtime::Block>, u32)>>;
type RemoteBodyResult = FetcherFutureResult<Vec<runtime::Extrinsic>>;
type RemoteChangesResult = FetcherFutureResult<Vec<(NumberFor<substrate_test_runtime::Block>, u32)>>;
type RemoteBodyResult = FetcherFutureResult<Vec<substrate_test_runtime::Extrinsic>>;
fn remote_header(&self, _: RemoteHeaderRequest<runtime::Header>) -> Self::RemoteHeaderResult {
fn remote_header(&self, _: RemoteHeaderRequest<substrate_test_runtime::Header>) -> Self::RemoteHeaderResult {
unimplemented!()
}
fn remote_read(&self, _: RemoteReadRequest<runtime::Header>) -> Self::RemoteReadResult {
fn remote_read(&self, _: RemoteReadRequest<substrate_test_runtime::Header>) -> Self::RemoteReadResult {
unimplemented!()
}
fn remote_read_child(&self, _: RemoteReadChildRequest<runtime::Header>) -> Self::RemoteReadResult {
fn remote_read_child(&self, _: RemoteReadChildRequest<substrate_test_runtime::Header>) -> Self::RemoteReadResult {
unimplemented!()
}
fn remote_call(&self, req: RemoteCallRequest<runtime::Header>) -> Self::RemoteCallResult {
fn remote_call(&self, req: RemoteCallRequest<substrate_test_runtime::Header>) -> Self::RemoteCallResult {
match self.call {
Some(ref call) => futures::future::ready(call(req)),
None => unimplemented!(),
}
}
fn remote_changes(&self, _: RemoteChangesRequest<runtime::Header>) -> Self::RemoteChangesResult {
fn remote_changes(&self, _: RemoteChangesRequest<substrate_test_runtime::Header>) -> Self::RemoteChangesResult {
unimplemented!()
}
fn remote_body(&self, req: RemoteBodyRequest<runtime::Header>) -> Self::RemoteBodyResult {
fn remote_body(&self, req: RemoteBodyRequest<substrate_test_runtime::Header>) -> Self::RemoteBodyResult {
match self.body {
Some(ref body) => futures::future::ready(body(req)),
None => unimplemented!(),
@@ -340,15 +342,15 @@ pub fn new() -> Client<Backend> {
/// Creates new light client instance used for tests.
pub fn new_light() -> (
client::Client<LightBackend, LightExecutor, runtime::Block, runtime::RuntimeApi>,
sc_client::Client<LightBackend, LightExecutor, substrate_test_runtime::Block, substrate_test_runtime::RuntimeApi>,
Arc<LightBackend>,
) {
let storage = client_db::light::LightStorage::new_test();
let blockchain = Arc::new(client::light::blockchain::Blockchain::new(storage));
let storage = sc_client_db::light::LightStorage::new_test();
let blockchain = Arc::new(sc_client::light::blockchain::Blockchain::new(storage));
let backend = Arc::new(LightBackend::new(blockchain.clone()));
let executor = NativeExecutor::new(WasmExecutionMethod::Interpreted, None);
let local_call_executor = client::LocalCallExecutor::new(backend.clone(), executor);
let local_call_executor = sc_client::LocalCallExecutor::new(backend.clone(), executor);
let call_executor = LightExecutor::new(
backend.clone(),
local_call_executor,
@@ -21,19 +21,19 @@
use std::sync::Arc;
use client_api::backend::LocalBackend;
use sc_client_api::backend::LocalBackend;
use crate::block_builder_ext::BlockBuilderExt;
use client_api::blockchain::{Backend as BlockChainBackendT, HeaderBackend};
use sc_client_api::blockchain::{Backend as BlockChainBackendT, HeaderBackend};
use crate::{AccountKeyring, ClientExt, TestClientBuilder, TestClientBuilderExt};
use generic_test_client::consensus::BlockOrigin;
use primitives::Blake2Hasher;
use runtime::{self, Transfer};
use substrate_test_client::sp_consensus::BlockOrigin;
use sp_core::Blake2Hasher;
use substrate_test_runtime::{self, Transfer};
use sp_runtime::generic::BlockId;
use sp_runtime::traits::Block as BlockT;
/// helper to test the `leaves` implementation for various backends
pub fn test_leaves_for_backend<B: 'static>(backend: Arc<B>) where
B: LocalBackend<runtime::Block, Blake2Hasher>,
B: LocalBackend<substrate_test_runtime::Block, Blake2Hasher>,
{
// block tree:
// G -> A1 -> A2 -> A3 -> A4 -> A5
@@ -149,7 +149,7 @@ pub fn test_leaves_for_backend<B: 'static>(backend: Arc<B>) where
/// helper to test the `children` implementation for various backends
pub fn test_children_for_backend<B: 'static>(backend: Arc<B>) where
B: LocalBackend<runtime::Block, Blake2Hasher>,
B: LocalBackend<substrate_test_runtime::Block, Blake2Hasher>,
{
// block tree:
// G -> A1 -> A2 -> A3 -> A4 -> A5
@@ -240,7 +240,7 @@ pub fn test_children_for_backend<B: 'static>(backend: Arc<B>) where
}
pub fn test_blockchain_query_by_number_gets_canonical<B: 'static>(backend: Arc<B>) where
B: LocalBackend<runtime::Block, Blake2Hasher>,
B: LocalBackend<substrate_test_runtime::Block, Blake2Hasher>,
{
// block tree:
// G -> A1 -> A2 -> A3 -> A4 -> A5