break sp-api dependency cycle (#4352)

* move benches into tests, ignore non-passing doctests

* Rename sr-api folder

* Move test-primitives to primitives, use that for sp-api doctests
This commit is contained in:
Benjamin Kampmann
2019-12-10 20:18:01 +01:00
committed by Bastian Köcher
parent f6f0f1cc16
commit 8721d98dd6
71 changed files with 62 additions and 60 deletions
@@ -14,14 +14,7 @@ sp-version = { path = "../sr-version", default-features = false }
state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true }
[dev-dependencies]
criterion = "0.3.0"
test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" }
sp-runtime = { path = "../runtime" }
sp-version = { path = "../sr-version" }
[[bench]]
name = "bench"
harness = false
sp-test-primitives = { path = "../test-primitives" }
[features]
default = [ "std" ]
@@ -158,7 +158,7 @@ pub use sp_api_proc_macro::decl_runtime_apis;
/// use sp_version::create_runtime_str;
/// #
/// # use sp_runtime::traits::GetNodeBlockType;
/// # use test_client::runtime::{Block, Header};
/// # use sp_test_primitives::{Block, Header};
/// #
/// # /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
/// # /// trait are done by the `construct_runtime!` macro in a real runtime.
@@ -16,6 +16,14 @@ state-machine = { package = "sp-state-machine", path = "../../../primitives/stat
trybuild = "1.0.17"
rustversion = "1.0.0"
[dev-dependencies]
criterion = "0.3.0"
test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" }
[[bench]]
name = "bench"
harness = false
# We only need this to generate the correct code.
[features]
default = [ "std" ]
@@ -9,7 +9,7 @@ edition = "2018"
app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false }
codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" }
sp-std = { path = "../std", default-features = false }
sp-api = { path = "../sr-api", default-features = false }
sp-api = { path = "../api", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
[features]
@@ -6,7 +6,7 @@ edition = "2018"
[dependencies]
sp-runtime = { path = "../../runtime", default-features = false }
sp-api = { path = "../../sr-api", default-features = false }
sp-api = { path = "../../api", default-features = false }
sp-std = { path = "../../std", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false }
inherents = { package = "sp-inherents", path = "../../inherents", default-features = false }
@@ -9,7 +9,7 @@ edition = "2018"
app-crypto = { package = "sc-application-crypto", path = "../../application-crypto", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
sp-std = { path = "../../std", default-features = false }
sp-api = { path = "../../sr-api", default-features = false }
sp-api = { path = "../../api", default-features = false }
sp-runtime = { path = "../../runtime", default-features = false }
inherents = { package = "sp-inherents", path = "../../inherents", default-features = false }
sp-timestamp = { path = "../../timestamp", default-features = false }
@@ -10,7 +10,7 @@ app-crypto = { package = "sc-application-crypto", path = "../../application-cryp
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
sp-std = { path = "../../std", default-features = false }
schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true }
sp-api = { path = "../../sr-api", default-features = false }
sp-api = { path = "../../api", default-features = false }
sp-consensus = { path = "../common", optional = true }
sp-inherents = { package = "sp-inherents", path = "../../inherents", default-features = false }
sp-runtime = { path = "../../runtime", default-features = false }
@@ -6,7 +6,7 @@ description = "Primitives for Aura consensus"
edition = "2018"
[dependencies]
sp-api = { path = "../../sr-api", default-features = false }
sp-api = { path = "../../api", default-features = false }
sp-std = { path = "../../std", default-features = false }
sp-runtime = { path = "../../runtime", default-features = false }
primitives = { package = "sp-core", path = "../../core", default-features = false }
@@ -9,7 +9,7 @@ app-crypto = { package = "sc-application-crypto", path = "../application-crypto"
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
sp-std = { path = "../std", default-features = false }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
sp-api = { path = "../sr-api", default-features = false }
sp-api = { path = "../api", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
[features]
+1 -1
View File
@@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
sp-api = { path = "../sr-api", default-features = false }
sp-api = { path = "../api", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
[features]
+1 -1
View File
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
sp-api = { path = "../sr-api", default-features = false }
sp-api = { path = "../api", default-features = false }
sp-std = { path = "../std", default-features = false }
sp-runtime = { path = "../runtime", optional = true }
@@ -0,0 +1,21 @@
[package]
name = "sp-test-primitives"
version = "2.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
primitives = { package = "sp-core", path = "../core", default-features = false }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
sp-runtime = { path = "../runtime", default-features = false }
[features]
default = [
"std",
]
std = [
"app-crypto/std",
"serde",
]
@@ -0,0 +1,78 @@
// 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/>.
//! The Substrate test primitives to share
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Encode, Decode};
use app_crypto::sr25519;
pub use app_crypto;
pub use primitives::{hash::H256, RuntimeDebug};
use sp_runtime::traits::{BlakeTwo256, Verify, Extrinsic as ExtrinsicT,};
/// Extrinsic for test-runtime.
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
pub enum Extrinsic {
IncludeData(Vec<u8>),
StorageChange(Vec<u8>, Option<Vec<u8>>),
}
#[cfg(feature = "std")]
impl serde::Serialize for Extrinsic {
fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error> where S: ::serde::Serializer {
self.using_encoded(|bytes| seq.serialize_bytes(bytes))
}
}
impl ExtrinsicT for Extrinsic {
type Call = Extrinsic;
type SignaturePayload = ();
fn is_signed(&self) -> Option<bool> {
if let Extrinsic::IncludeData(_) = *self {
Some(false)
} else {
Some(true)
}
}
fn new(call: Self::Call, _signature_payload: Option<Self::SignaturePayload>) -> Option<Self> {
Some(call)
}
}
/// The signature type used by accounts/transactions.
pub type AccountSignature = sr25519::Signature;
/// An identifier for an account on this system.
pub type AccountId = <AccountSignature as Verify>::Signer;
/// A simple hash type for all our hashing.
pub type Hash = H256;
/// The block number type used in this runtime.
pub type BlockNumber = u64;
/// Index of a transaction.
pub type Index = u64;
/// The item of a block digest.
pub type DigestItem = sp_runtime::generic::DigestItem<H256>;
/// The digest of a block.
pub type Digest = sp_runtime::generic::Digest<H256>;
/// A test block.
pub type Block = sp_runtime::generic::Block<Header, Extrinsic>;
/// A test block's header.
pub type Header = sp_runtime::generic::Header<BlockNumber, BlakeTwo256>;
+1 -1
View File
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
sp-api = { path = "../sr-api", default-features = false }
sp-api = { path = "../api", default-features = false }
sp-std = { path = "../std", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
@@ -10,7 +10,7 @@ derive_more = { version = "0.99.2", optional = true }
futures = { version = "0.3.1", optional = true }
log = { version = "0.4.8", optional = true }
serde = { version = "1.0.101", features = ["derive"], optional = true}
sp-api = { path = "../sr-api", default-features = false }
sp-api = { path = "../api", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
[features]