Remove all (non-dev) client references from frame, activate dependency enforcer (#4184)

* Move transaction pool to primitives

* move backend, errors into primitives

* remove unused client depencies

* Move rpc-api into primitives

* Move peerset back to client

* Move rpc/api back to client, move palette/support/rpc into utils

* move support-rpc into subfolder

* move system-rpc into utils

* move transaction-pool  and -graph back into client

* fix broken imports

* Clean up test primitives

* Make support test utils independent of frame

* remove unnecessary node dependencies from service

* Reactivate dependency script:
 - only enforce the now achieved status quo will remain
 - allow for primitives to depend on /client for now without failing
 - more discriptive error message so people understand, what it wants
 - minor fix to differentiative between ../client and /client (which may be a subfolder)
 - don't allow this to fail anylonger.

* fix doc comment

* 'Should not' rather than 'must not'.

* Revert unwanted dependency changes

* fix faulty import

* fixup derive_more version

* fix wrong import path
This commit is contained in:
Benjamin Kampmann
2019-11-26 21:38:28 +01:00
committed by GitHub
parent b2aab98e69
commit bd652793db
130 changed files with 836 additions and 816 deletions
+5
View File
@@ -0,0 +1,5 @@
[package]
name = "substrate-test-utils"
version = "2.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
+1
View File
@@ -16,4 +16,5 @@ keyring = { package = "substrate-keyring", path = "../../../primitives/keyring"
codec = { package = "parity-scale-codec", version = "1.0.0" }
primitives = { package = "substrate-primitives", path = "../../../primitives/core" }
sr-primitives = { path = "../../../primitives/sr-primitives" }
sp-blockchain = { path = "../../../primitives/blockchain" }
state_machine = { package = "substrate-state-machine", path = "../../../primitives/state-machine" }
@@ -56,7 +56,7 @@ pub trait ClientExt<Block: BlockT>: Sized {
&self,
id: BlockId<Block>,
justification: Option<Justification>,
) -> client::error::Result<()>;
) -> sp_blockchain::Result<()>;
/// Returns hash of the genesis block.
fn genesis_hash(&self) -> <Block as BlockT>::Hash;
@@ -152,7 +152,7 @@ impl<B, E, RA, Block> ClientExt<Block> for Client<B, E, Block, RA>
&self,
id: BlockId<Block>,
justification: Option<Justification>,
) -> client::error::Result<()> {
) -> sp_blockchain::Result<()> {
Finalizer::finalize_block(self, id, justification, true)
}
@@ -7,31 +7,9 @@ edition = "2018"
[dependencies]
app-crypto = { package = "substrate-application-crypto", path = "../../../primitives/application-crypto", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
# aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../../primitives/consensus/aura", default-features = false }
# babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../../primitives/consensus/babe", default-features = false }
# block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api", default-features = false }
# inherents = { package = "substrate-inherents", path = "../../../primitives/inherents", default-features = false }
# log = { version = "0.4.8", optional = true }
# memory-db = { version = "0.15.2", default-features = false }
# offchain-primitives = { package = "substrate-offchain-primitives", path = "../../../primitives/offchain", default-features = false}
primitives = { package = "substrate-primitives", path = "../../../primitives/core", default-features = false }
# rstd = { package = "sr-std", path = "../../../primitives/sr-std", default-features = false }
# runtime-interface = { package = "substrate-runtime-interface", path = "../../../primitives/runtime-interface", default-features = false}
# runtime_io = { package = "sr-io", path = "../../../primitives/sr-io", default-features = false }
# runtime_support = { package = "frame-support", path = "../../../frame/support", default-features = false }
# runtime_version = { package = "sr-version", path = "../../../primitives/sr-version", default-features = false }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
# session = { package = "substrate-session", path = "../../../primitives/session", default-features = false }
# sr-api = { path = "../../../primitives/sr-api", default-features = false }
sr-primitives = { path = "../../../primitives/sr-primitives", default-features = false }
# pallet-babe = { path = "../../../frame/babe", default-features = false }
# frame-system = { path = "../../../frame/system", default-features = false }
# frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api", default-features = false }
# pallet-timestamp = { path = "../../../frame/timestamp", default-features = false }
# substrate-client = { path = "../../../client", optional = true }
# substrate-trie = { path = "../../../primitives/trie", default-features = false }
# transaction-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false }
# trie-db = { version = "0.15.2", default-features = false }
[features]
default = [
@@ -39,33 +17,5 @@ default = [
]
std = [
"app-crypto/std",
# "aura-primitives/std",
# "babe-primitives/std",
# "block-builder-api/std",
# "codec/std",
# "executive/std",
# "inherents/std",
# "keyring",
# "log",
# "memory-db/std",
# "offchain-primitives/std",
# "primitives/std",
# "primitives/std",
# "rstd/std",
# "runtime-interface/std",
# "runtime_io/std",
# "runtime_support/std",
# "runtime_version/std",
"serde",
# "session/std",
# "sr-api/std",
# "sr-primitives/std",
# "pallet-babe/std",
# "frame-system-rpc-runtime-api/std",
# "frame-system/std",
# "pallet-timestamp/std",
# "substrate-client",
# "substrate-trie/std",
# "transaction-pool-api/std",
# "trie-db/std",
]
@@ -10,6 +10,7 @@ generic-test-client = { package = "substrate-test-client", path = "../../client"
primitives = { package = "substrate-primitives", path = "../../../../primitives/core" }
runtime = { package = "substrate-test-runtime", path = "../../runtime" }
sr-primitives = { path = "../../../../primitives/sr-primitives" }
sp-blockchain = { path = "../../../../primitives/blockchain" }
codec = { package = "parity-scale-codec", version = "1.0.0" }
client-api = { package = "substrate-client-api", path = "../../../../client/api" }
client = { package = "substrate-client", path = "../../../../client/" }
@@ -18,27 +18,26 @@
use runtime;
use sr_primitives::traits::ProvideRuntimeApi;
use generic_test_client::client;
use 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<(), client::error::Error>;
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), sp_blockchain::Error>;
/// Add storage change extrinsic to the block.
fn push_storage_change(
&mut self,
key: Vec<u8>,
value: Option<Vec<u8>>,
) -> Result<(), client::error::Error>;
) -> Result<(), sp_blockchain::Error>;
}
impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block, A> where
A: ProvideRuntimeApi + 'a,
A::Api: BlockBuilderApi<runtime::Block, Error = client::error::Error>,
A::Api: BlockBuilderApi<runtime::Block, Error = sp_blockchain::Error>,
{
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), client::error::Error> {
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), sp_blockchain::Error> {
self.push(transfer.into_signed_tx())
}
@@ -46,7 +45,7 @@ impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block,
&mut self,
key: Vec<u8>,
value: Option<Vec<u8>>,
) -> Result<(), client::error::Error> {
) -> Result<(), sp_blockchain::Error> {
self.push(runtime::Extrinsic::StorageChange(key, value))
}
}
+54
View File
@@ -0,0 +1,54 @@
// Copyright 2017-2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
//! Test utils
/// Panic when the vectors are different, without taking the order into account.
///
/// # Examples
///
/// ```rust
/// #[macro_use]
/// # use substrate_test_utils::{assert_eq_uvec};
/// # fn main() {
/// assert_eq_uvec!(vec![1,2], vec![2,1]);
/// # }
/// ```
///
/// ```rust,should_panic
/// #[macro_use]
/// # use substrate_test_utils::{assert_eq_uvec};
/// # fn main() {
/// assert_eq_uvec!(vec![1,2,3], vec![2,1]);
/// # }
/// ```
#[macro_export]
macro_rules! assert_eq_uvec {
( $x:expr, $y:expr ) => {
$crate::__assert_eq_uvec!($x, $y);
$crate::__assert_eq_uvec!($y, $x);
}
}
#[macro_export]
#[doc(hidden)]
macro_rules! __assert_eq_uvec {
( $x:expr, $y:expr ) => {
$x.iter().for_each(|e| {
if !$y.contains(e) { panic!(format!("vectors not equal: {:?} != {:?}", $x, $y)); }
});
}
}
@@ -16,4 +16,5 @@ primitives = { package = "substrate-primitives", path = "../../../primitives/cor
sr-api = { path = "../../../primitives/sr-api" }
sr-primitives = { path = "../../../primitives/sr-primitives" }
substrate-service = { path = "../../../client/service" }
sp-blockchain = { path = "../../../primitives/blockchain" }
@@ -64,7 +64,7 @@ where
Backend: client_api::backend::Backend<Block, Blake2Hasher> + Send,
Client<Backend, Exec, Block, RtApi>: ProvideRuntimeApi,
<Client<Backend, Exec, Block, RtApi> as ProvideRuntimeApi>::Api:
BlockBuilder<Block, Error = client::error::Error>,
BlockBuilder<Block, Error = sp_blockchain::Error>,
RtApi: ConstructRuntimeApi<Block, Client<Backend, Exec, Block, RtApi>> + Send + Sync,
RA: RuntimeAdapter,
{
@@ -105,7 +105,7 @@ where
Backend: client_api::backend::Backend<Block, Blake2Hasher> + Send,
Client<Backend, Exec, Block, RtApi>: ProvideRuntimeApi,
<Client<Backend, Exec, Block, RtApi> as ProvideRuntimeApi>::Api:
BlockBuilder<Block, Error = client::error::Error>,
BlockBuilder<Block, Error = sp_blockchain::Error>,
RtApi: ConstructRuntimeApi<Block, Client<Backend, Exec, Block, RtApi>> + Send + Sync,
Sc: SelectChain<Block>,
RA: RuntimeAdapter,
@@ -165,7 +165,7 @@ where
Client<Backend, Exec, Block, RtApi>: ProvideRuntimeApi,
RtApi: ConstructRuntimeApi<Block, Client<Backend, Exec, Block, RtApi>> + Send + Sync,
<Client<Backend, Exec, Block, RtApi> as ProvideRuntimeApi>::Api:
BlockBuilder<Block, Error = client::error::Error>,
BlockBuilder<Block, Error = sp_blockchain::Error>,
RA: RuntimeAdapter,
{
let mut block = client.new_block(Default::default()).expect("Failed to create new block");
@@ -59,7 +59,7 @@ where
Backend: client_api::backend::Backend<Block, Blake2Hasher> + Send,
Client<Backend, Exec, Block, RtApi>: ProvideRuntimeApi,
<Client<Backend, Exec, Block, RtApi> as ProvideRuntimeApi>::Api:
BlockBuilder<Block, Error = client::error::Error>,
BlockBuilder<Block, Error = sp_blockchain::Error>,
RtApi: ConstructRuntimeApi<Block, Client<Backend, Exec, Block, RtApi>> + Send + Sync,
RA: RuntimeAdapter,
{