diff --git a/substrate/.maintain/rename-crates-for-2.0.sh b/substrate/.maintain/rename-crates-for-2.0.sh index ecfbfd4453..8cf5a71c0e 100644 --- a/substrate/.maintain/rename-crates-for-2.0.sh +++ b/substrate/.maintain/rename-crates-for-2.0.sh @@ -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" diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 616f5a600e..89e8ccd33a 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -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", diff --git a/substrate/Cargo.toml b/substrate/Cargo.toml index 1c4ad549b9..d1b105ab8b 100644 --- a/substrate/Cargo.toml +++ b/substrate/Cargo.toml @@ -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", diff --git a/substrate/client/consensus/aura/Cargo.toml b/substrate/client/consensus/aura/Cargo.toml index f9b56fd399..181b144333 100644 --- a/substrate/client/consensus/aura/Cargo.toml +++ b/substrate/client/consensus/aura/Cargo.toml @@ -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 = "../../" } diff --git a/substrate/client/consensus/babe/Cargo.toml b/substrate/client/consensus/babe/Cargo.toml index 4d6e77a0b8..8c61f10b68 100644 --- a/substrate/client/consensus/babe/Cargo.toml +++ b/substrate/client/consensus/babe/Cargo.toml @@ -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" diff --git a/substrate/client/keystore/Cargo.toml b/substrate/client/keystore/Cargo.toml index 0dd33a62da..32bd3d460b 100644 --- a/substrate/client/keystore/Cargo.toml +++ b/substrate/client/keystore/Cargo.toml @@ -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" diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml index cdd5b948ca..f09fad08de 100644 --- a/substrate/client/service/Cargo.toml +++ b/substrate/client/service/Cargo.toml @@ -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" } diff --git a/substrate/docs/Upgrade.md b/substrate/docs/Upgrade.md new file mode 100644 index 0000000000..4908d53f57 --- /dev/null +++ b/substrate/docs/Upgrade.md @@ -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` \ No newline at end of file diff --git a/substrate/frame/aura/Cargo.toml b/substrate/frame/aura/Cargo.toml index 76b54caf12..68083e075f 100644 --- a/substrate/frame/aura/Cargo.toml +++ b/substrate/frame/aura/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] 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 } diff --git a/substrate/frame/authority-discovery/Cargo.toml b/substrate/frame/authority-discovery/Cargo.toml index 7d52faf3f8..7909006901 100644 --- a/substrate/frame/authority-discovery/Cargo.toml +++ b/substrate/frame/authority-discovery/Cargo.toml @@ -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 } diff --git a/substrate/frame/im-online/Cargo.toml b/substrate/frame/im-online/Cargo.toml index 5110f511d1..cac2d49c5c 100644 --- a/substrate/frame/im-online/Cargo.toml +++ b/substrate/frame/im-online/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] 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 } diff --git a/substrate/frame/session/Cargo.toml b/substrate/frame/session/Cargo.toml index 3df9b868f9..b5a6efc476 100644 --- a/substrate/frame/session/Cargo.toml +++ b/substrate/frame/session/Cargo.toml @@ -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] diff --git a/substrate/primitives/application-crypto/Cargo.toml b/substrate/primitives/application-crypto/Cargo.toml index 1c7c647bb6..79b3f35f6b 100644 --- a/substrate/primitives/application-crypto/Cargo.toml +++ b/substrate/primitives/application-crypto/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sc-application-crypto" +name = "sp-application-crypto" version = "2.0.0" authors = ["Parity Technologies "] 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" ] diff --git a/substrate/primitives/application-crypto/src/ed25519.rs b/substrate/primitives/application-crypto/src/ed25519.rs index 5097b8e4dc..2ac94ac423 100644 --- a/substrate/primitives/application-crypto/src/ed25519.rs +++ b/substrate/primitives/application-crypto/src/ed25519.rs @@ -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()))); - } -} diff --git a/substrate/primitives/application-crypto/src/lib.rs b/substrate/primitives/application-crypto/src/lib.rs index d7c303e338..12972b4707 100644 --- a/substrate/primitives/application-crypto/src/lib.rs +++ b/substrate/primitives/application-crypto/src/lib.rs @@ -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); /// } /// ``` diff --git a/substrate/primitives/application-crypto/src/sr25519.rs b/substrate/primitives/application-crypto/src/sr25519.rs index e7b5c7f164..d49fc46cc2 100644 --- a/substrate/primitives/application-crypto/src/sr25519.rs +++ b/substrate/primitives/application-crypto/src/sr25519.rs @@ -53,28 +53,4 @@ impl RuntimePublic for Public { fn verify>(&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()))); - } -} +} \ No newline at end of file diff --git a/substrate/primitives/application-crypto/test/Cargo.toml b/substrate/primitives/application-crypto/test/Cargo.toml new file mode 100644 index 0000000000..e5eed8f5b3 --- /dev/null +++ b/substrate/primitives/application-crypto/test/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "sp-application-crypto-test" +version = "2.0.0" +authors = ["Parity Technologies "] +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" } \ No newline at end of file diff --git a/substrate/primitives/application-crypto/test/src/ed25519.rs b/substrate/primitives/application-crypto/test/src/ed25519.rs new file mode 100644 index 0000000000..0e66e5b3ff --- /dev/null +++ b/substrate/primitives/application-crypto/test/src/ed25519.rs @@ -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 . + +//! 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()))); +} \ No newline at end of file diff --git a/substrate/primitives/application-crypto/test/src/lib.rs b/substrate/primitives/application-crypto/test/src/lib.rs new file mode 100644 index 0000000000..282ace5b1f --- /dev/null +++ b/substrate/primitives/application-crypto/test/src/lib.rs @@ -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 . + +//! Integration tests for application crypto + +#[cfg(test)] +mod ed25519; +#[cfg(test)] +mod sr25519; \ No newline at end of file diff --git a/substrate/primitives/application-crypto/test/src/sr25519.rs b/substrate/primitives/application-crypto/test/src/sr25519.rs new file mode 100644 index 0000000000..50981f4677 --- /dev/null +++ b/substrate/primitives/application-crypto/test/src/sr25519.rs @@ -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 . + +//! 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()))); +} \ No newline at end of file diff --git a/substrate/primitives/authority-discovery/Cargo.toml b/substrate/primitives/authority-discovery/Cargo.toml index 79df9e4169..aa8fa926ca 100644 --- a/substrate/primitives/authority-discovery/Cargo.toml +++ b/substrate/primitives/authority-discovery/Cargo.toml @@ -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 } diff --git a/substrate/primitives/consensus/aura/Cargo.toml b/substrate/primitives/consensus/aura/Cargo.toml index 599083b17f..2a46cf015c 100644 --- a/substrate/primitives/consensus/aura/Cargo.toml +++ b/substrate/primitives/consensus/aura/Cargo.toml @@ -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 } diff --git a/substrate/primitives/consensus/babe/Cargo.toml b/substrate/primitives/consensus/babe/Cargo.toml index 675363e5a9..0889f6f639 100644 --- a/substrate/primitives/consensus/babe/Cargo.toml +++ b/substrate/primitives/consensus/babe/Cargo.toml @@ -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 } diff --git a/substrate/primitives/finality-grandpa/Cargo.toml b/substrate/primitives/finality-grandpa/Cargo.toml index 0e05cab228..6017745180 100644 --- a/substrate/primitives/finality-grandpa/Cargo.toml +++ b/substrate/primitives/finality-grandpa/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] 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"] } diff --git a/substrate/primitives/runtime/Cargo.toml b/substrate/primitives/runtime/Cargo.toml index 94f841d10a..d149aa089e 100644 --- a/substrate/primitives/runtime/Cargo.toml +++ b/substrate/primitives/runtime/Cargo.toml @@ -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 } diff --git a/substrate/primitives/test-primitives/Cargo.toml b/substrate/primitives/test-primitives/Cargo.toml index e54a6f5095..d8d66e91c4 100644 --- a/substrate/primitives/test-primitives/Cargo.toml +++ b/substrate/primitives/test-primitives/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] 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"] } diff --git a/substrate/test/utils/runtime/Cargo.toml b/substrate/test/utils/runtime/Cargo.toml index 87f9fd75bb..69a4396f4a 100644 --- a/substrate/test/utils/runtime/Cargo.toml +++ b/substrate/test/utils/runtime/Cargo.toml @@ -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 }