Break appcrypto dep cycle (#4347)

* move application-crypto tests into seperate crate

* Fix crate name, update script and add docs

* pressing 'save' helps

* remove useless lines

* adding header

* split into actual modules
This commit is contained in:
Benjamin Kampmann
2019-12-10 22:12:57 +01:00
committed by Bastian Köcher
parent 8721d98dd6
commit f0cc89a4b0
27 changed files with 174 additions and 100 deletions
+2 -1
View File
@@ -35,7 +35,8 @@ TO_RENAME=(
# OLD-CRATE-NAME NEW-CRATE-NAME
# PRIMITIVES
"substrate-application-crypto sc-application-crypto"
"substrate-application-crypto sp-application-crypto"
"sc-application-crypto sp-application-crypto"
"substrate-authority-discovery-primitives sp-authority-discovery"
"substrate-block-builder-runtime-api sp-block-builder"
"substrate-consensus-aura-primitives sp-consensus-aura"
+35 -28
View File
@@ -3453,8 +3453,8 @@ dependencies = [
"pallet-timestamp 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
"sp-consensus-aura 2.0.0",
"sp-core 2.0.0",
"sp-inherents 2.0.0",
@@ -3472,8 +3472,8 @@ dependencies = [
"frame-system 2.0.0",
"pallet-session 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
"sp-authority-discovery 2.0.0",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3767,8 +3767,8 @@ dependencies = [
"pallet-authorship 0.1.0",
"pallet-session 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
"sp-core 2.0.0",
"sp-io 2.0.0",
"sp-runtime 2.0.0",
@@ -3878,8 +3878,8 @@ dependencies = [
"pallet-timestamp 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
"sp-core 2.0.0",
"sp-io 2.0.0",
"sp-runtime 2.0.0",
@@ -4879,19 +4879,6 @@ dependencies = [
"winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "sc-application-crypto"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
"sp-runtime 2.0.0",
"sp-std 2.0.0",
"substrate-test-runtime-client 2.0.0",
]
[[package]]
name = "sc-authority-discovery"
version = "2.0.0"
@@ -5129,7 +5116,6 @@ dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"sc-client 2.0.0",
"sc-client-api 2.0.0",
"sc-consensus-slots 2.0.0",
@@ -5139,6 +5125,7 @@ dependencies = [
"sc-service 2.0.0",
"sc-telemetry 2.0.0",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
"sp-block-builder 2.0.0",
"sp-blockchain 2.0.0",
"sp-consensus 2.0.0",
@@ -5174,7 +5161,6 @@ dependencies = [
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pdqselect 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"sc-block-builder 2.0.0",
"sc-client 2.0.0",
"sc-client-api 2.0.0",
@@ -5187,6 +5173,7 @@ dependencies = [
"sc-telemetry 2.0.0",
"schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
"sp-block-builder 2.0.0",
"sp-blockchain 2.0.0",
"sp-consensus 2.0.0",
@@ -5339,8 +5326,8 @@ dependencies = [
"hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
"sp-core 2.0.0",
"subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5538,7 +5525,6 @@ dependencies = [
"parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"sc-chain-spec 2.0.0",
"sc-client 2.0.0",
"sc-client-api 2.0.0",
@@ -5557,6 +5543,7 @@ dependencies = [
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
"sp-blockchain 2.0.0",
"sp-consensus 2.0.0",
"sp-consensus-babe 2.0.0",
@@ -6006,6 +5993,26 @@ dependencies = [
"trybuild 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "sp-application-crypto"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
"sp-std 2.0.0",
]
[[package]]
name = "sp-application-crypto-test"
version = "2.0.0"
dependencies = [
"sp-core 2.0.0",
"sp-runtime 2.0.0",
"substrate-test-runtime-client 2.0.0",
]
[[package]]
name = "sp-arithmetic"
version = "2.0.0"
@@ -6026,8 +6033,8 @@ name = "sp-authority-discovery"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
"sp-runtime 2.0.0",
"sp-std 2.0.0",
]
@@ -6092,8 +6099,8 @@ name = "sp-consensus-aura"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
"sp-inherents 2.0.0",
"sp-runtime 2.0.0",
"sp-std 2.0.0",
@@ -6105,9 +6112,9 @@ name = "sp-consensus-babe"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
"sp-consensus 2.0.0",
"sp-inherents 2.0.0",
"sp-runtime 2.0.0",
@@ -6202,9 +6209,9 @@ name = "sp-finality-grandpa"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
"sp-runtime 2.0.0",
"sp-std 2.0.0",
]
@@ -6301,9 +6308,9 @@ dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
"sp-arithmetic 2.0.0",
"sp-core 2.0.0",
"sp-inherents 2.0.0",
@@ -6424,8 +6431,8 @@ name = "sp-test-primitives"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
"sp-core 2.0.0",
"sp-runtime 2.0.0",
]
@@ -6682,11 +6689,11 @@ dependencies = [
"pallet-babe 2.0.0",
"pallet-timestamp 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-application-crypto 2.0.0",
"sc-client 2.0.0",
"sc-executor 2.0.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
"sp-block-builder 2.0.0",
"sp-consensus-aura 2.0.0",
"sp-consensus-babe 2.0.0",
+1
View File
@@ -90,6 +90,7 @@ members = [
"frame/treasury",
"frame/utility",
"primitives/application-crypto",
"primitives/application-crypto/test",
"primitives/authority-discovery",
"primitives/authorship",
"primitives/block-builder/runtime-api",
+1 -1
View File
@@ -6,7 +6,7 @@ description = "Aura consensus algorithm for substrate"
edition = "2018"
[dependencies]
app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto" }
app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto" }
aura_primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura" }
block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" }
client = { package = "sc-client", path = "../../" }
+1 -1
View File
@@ -9,7 +9,7 @@ edition = "2018"
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
babe_primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" }
primitives = { package = "sp-core", path = "../../../primitives/core" }
app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto" }
app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto" }
num-bigint = "0.2.3"
num-rational = "0.2.2"
num-traits = "0.2.8"
+1 -1
View File
@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
derive_more = "0.99.2"
primitives = { package = "sp-core", path = "../../primitives/core" }
app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto" }
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto" }
hex = "0.4.0"
rand = "0.7.2"
serde_json = "1.0.41"
+1 -1
View File
@@ -34,7 +34,7 @@ sp-runtime = { path = "../../primitives/runtime" }
sp-blockchain = { path = "../../primitives/blockchain" }
primitives = { package = "sp-core", path = "../../primitives/core" }
session = { package = "sp-session", path = "../../primitives/session" }
app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto" }
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto" }
consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" }
network = { package = "sc-network", path = "../network" }
chain-spec = { package = "sc-chain-spec", path = "../chain-spec" }
+5
View File
@@ -0,0 +1,5 @@
# Upgrade path for you building on substrate
## master
- crate rename has been fixed `sp-application-crypto` (was `sc-application-crypto`); `.maintain/rename-crates-for-2.0.sh` has been updated accordingly, you can use it to upgrade to latest naming convention
- crates have been renamed, run `bash .maintain/rename-crates-for-2.0.sh`
+1 -1
View File
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto", default-features = false }
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false }
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
@@ -6,7 +6,7 @@ edition = "2018"
[dependencies]
authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../primitives/authority-discovery", default-features = false }
app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto", default-features = false }
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
sp-std = { path = "../../primitives/std", default-features = false }
+1 -1
View File
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto", default-features = false }
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false }
authorship = { package = "pallet-authorship", path = "../authorship", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
primitives = { package="sp-core", path = "../../primitives/core", default-features = false }
+1 -1
View File
@@ -20,7 +20,7 @@ impl-trait-for-tuples = "0.1.3"
[dev-dependencies]
primitives = { package = "sp-core", path = "../../primitives/core" }
app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto" }
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto" }
lazy_static = "1.4.0"
[features]
@@ -1,5 +1,5 @@
[package]
name = "sc-application-crypto"
name = "sp-application-crypto"
version = "2.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
@@ -12,10 +12,6 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] }
sp-std = { path = "../std", default-features = false }
sp-io = { path = "../../primitives/io", default-features = false }
[dev-dependencies]
test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" }
sp-runtime = { path = "../../primitives/runtime" }
[features]
default = [ "std" ]
std = [ "full_crypto", "primitives/std", "codec/std", "serde", "sp-std/std", "sp-io/std" ]
@@ -55,26 +55,3 @@ impl RuntimePublic for Public {
}
}
#[cfg(test)]
mod tests {
use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi};
use primitives::{testing::{KeyStore, ED25519}, crypto::Pair};
use test_client::{
TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt,
runtime::{TestAPI, app_crypto::ed25519::{AppPair, AppPublic}},
};
#[test]
fn ed25519_works_in_runtime() {
let keystore = KeyStore::new();
let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build();
let (signature, public) = test_client.runtime_api()
.test_ed25519_crypto(&BlockId::Number(0))
.expect("Tests `ed25519` crypto.");
let key_pair = keystore.read().ed25519_key_pair(ED25519, &public.as_ref())
.expect("There should be at a `ed25519` key in the keystore for the given public key.");
assert!(AppPair::verify(&signature, "ed25519", &AppPublic::from(key_pair.public())));
}
}
@@ -45,7 +45,7 @@ pub use traits::*;
/// Application-specific types whose identifier is `$key_type`.
///
/// ```rust
///# use sc_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId};
///# use sp_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId};
/// // Declare a new set of crypto types using Ed25519 logic that identifies as `KeyTypeId`
/// // of value `b"fuba"`.
/// app_crypto!(ed25519, KeyTypeId(*b"_uba"));
@@ -66,7 +66,7 @@ macro_rules! app_crypto {
/// Application-specific types whose identifier is `$key_type`.
///
/// ```rust
///# use sc_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId};
///# use sp_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId};
/// // Declare a new set of crypto types using Ed25519 logic that identifies as `KeyTypeId`
/// // of value `b"fuba"`.
/// app_crypto!(ed25519, KeyTypeId(*b"_uba"));
@@ -390,7 +390,7 @@ macro_rules! app_crypto_signature_common {
/// Implement bidirectional `From` and on-way `AsRef`/`AsMut` for two types, `$inner` and `$outer`.
///
/// ```rust
/// sc_application_crypto::wrap! {
/// sp_application_crypto::wrap! {
/// pub struct Wrapper(u32);
/// }
/// ```
@@ -53,28 +53,4 @@ impl RuntimePublic for Public {
fn verify<M: AsRef<[u8]>>(&self, msg: &M, signature: &Self::Signature) -> bool {
sp_io::crypto::sr25519_verify(&signature, msg.as_ref(), self)
}
}
#[cfg(test)]
mod tests {
use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi};
use primitives::{testing::{KeyStore, SR25519}, crypto::Pair};
use test_client::{
TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt,
runtime::{TestAPI, app_crypto::sr25519::{AppPair, AppPublic}},
};
#[test]
fn sr25519_works_in_runtime() {
let keystore = KeyStore::new();
let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build();
let (signature, public) = test_client.runtime_api()
.test_sr25519_crypto(&BlockId::Number(0))
.expect("Tests `sr25519` crypto.");
let key_pair = keystore.read().sr25519_key_pair(SR25519, public.as_ref())
.expect("There should be at a `sr25519` key in the keystore for the given public key.");
assert!(AppPair::verify(&signature, "sr25519", &AppPublic::from(key_pair.public())));
}
}
}
@@ -0,0 +1,12 @@
[package]
name = "sp-application-crypto-test"
version = "2.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
description = "Integration tests for application-crypto"
publish = false
[dependencies]
primitives = { package = "sp-core", path = "../../core", default-features = false }
test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" }
sp-runtime = { path = "../../runtime" }
@@ -0,0 +1,38 @@
// Copyright 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/>.
//! Integration tests for ed25519
use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi};
use primitives::{testing::{KeyStore, ED25519}, crypto::Pair};
use test_client::{
TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt,
runtime::{TestAPI, app_crypto::ed25519::{AppPair, AppPublic}},
};
#[test]
fn ed25519_works_in_runtime() {
let keystore = KeyStore::new();
let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build();
let (signature, public) = test_client.runtime_api()
.test_ed25519_crypto(&BlockId::Number(0))
.expect("Tests `ed25519` crypto.");
let key_pair = keystore.read().ed25519_key_pair(ED25519, &public.as_ref())
.expect("There should be at a `ed25519` key in the keystore for the given public key.");
assert!(AppPair::verify(&signature, "ed25519", &AppPublic::from(key_pair.public())));
}
@@ -0,0 +1,22 @@
// Copyright 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/>.
//! Integration tests for application crypto
#[cfg(test)]
mod ed25519;
#[cfg(test)]
mod sr25519;
@@ -0,0 +1,39 @@
// Copyright 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/>.
//! Integration tests for sr25519
use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi};
use primitives::{testing::{KeyStore, SR25519}, crypto::Pair};
use test_client::{
TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt,
runtime::{TestAPI, app_crypto::sr25519::{AppPair, AppPublic}},
};
#[test]
fn sr25519_works_in_runtime() {
let keystore = KeyStore::new();
let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build();
let (signature, public) = test_client.runtime_api()
.test_sr25519_crypto(&BlockId::Number(0))
.expect("Tests `sr25519` crypto.");
let key_pair = keystore.read().sr25519_key_pair(SR25519, public.as_ref())
.expect("There should be at a `sr25519` key in the keystore for the given public key.");
assert!(AppPair::verify(&signature, "sr25519", &AppPublic::from(key_pair.public())));
}
@@ -6,7 +6,7 @@ description = "Authority discovery primitives"
edition = "2018"
[dependencies]
app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false }
app-crypto = { package = "sp-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 = "../api", default-features = false }
@@ -6,7 +6,7 @@ description = "Primitives for Aura consensus"
edition = "2018"
[dependencies]
app-crypto = { package = "sc-application-crypto", path = "../../application-crypto", default-features = false }
app-crypto = { package = "sp-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 = "../../api", default-features = false }
@@ -6,7 +6,7 @@ description = "Primitives for BABE consensus"
edition = "2018"
[dependencies]
app-crypto = { package = "sc-application-crypto", path = "../../application-crypto", default-features = false }
app-crypto = { package = "sp-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 }
schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true }
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false }
app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false }
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"] }
+1 -1
View File
@@ -8,7 +8,7 @@ edition = "2018"
serde = { version = "1.0.101", optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
primitives = { package = "sp-core", path = "../core", default-features = false }
app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false }
app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false }
arithmetic = { package = "sp-arithmetic", path = "../sr-arithmetic", default-features = false }
sp-std = { path = "../std", default-features = false }
sp-io = { path = "../io", default-features = false }
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false }
app-crypto = { package = "sp-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"] }
+1 -1
View File
@@ -6,7 +6,7 @@ edition = "2018"
build = "build.rs"
[dependencies]
app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto", default-features = false }
app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto", default-features = false }
aura-primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura", default-features = false }
babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe", default-features = false }
block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api", default-features = false }