From 06658e0c3ccc2ad29ae92fcdac5b11686af696ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 1 Sep 2019 15:17:17 +0200 Subject: [PATCH] Fix tests compilation on master and remove warnings (#3525) --- substrate/core/rpc/src/author/mod.rs | 6 +----- substrate/core/rpc/src/author/tests.rs | 4 ++-- substrate/core/rpc/src/state/tests.rs | 8 +++++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/substrate/core/rpc/src/author/mod.rs b/substrate/core/rpc/src/author/mod.rs index 78a8ff804f..50b5e30d57 100644 --- a/substrate/core/rpc/src/author/mod.rs +++ b/substrate/core/rpc/src/author/mod.rs @@ -28,10 +28,7 @@ use api::Subscriptions; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; use log::warn; use codec::{Encode, Decode}; -use primitives::{ - Bytes, Blake2Hasher, H256, ed25519, sr25519, crypto::{Pair, Public, key_types}, - traits::BareCryptoStorePtr, -}; +use primitives::{Bytes, Blake2Hasher, H256, traits::BareCryptoStorePtr}; use sr_primitives::{generic, traits::{self, ProvideRuntimeApi}}; use transaction_pool::{ txpool::{ @@ -98,7 +95,6 @@ impl AuthorApi, BlockHash

> for Author whe ) -> Result<()> { let key_type = key_type.as_str().try_into().map_err(|_| Error::BadKeyType)?; let mut keystore = self.keystore.write(); - let maybe_password = keystore.password(); keystore.insert_unknown(key_type, &suri, &public[..]) .map_err(|_| Error::KeyStoreUnavailable)?; Ok(()) diff --git a/substrate/core/rpc/src/author/tests.rs b/substrate/core/rpc/src/author/tests.rs index 8e6243f40e..861b65bfe7 100644 --- a/substrate/core/rpc/src/author/tests.rs +++ b/substrate/core/rpc/src/author/tests.rs @@ -26,7 +26,7 @@ use transaction_pool::{ use futures::Stream; use primitives::{ H256, blake2_256, hexdisplay::HexDisplay, traits::BareCryptoStore, testing::KeyStore, - ed25519, crypto::key_types, + ed25519, crypto::{key_types, Pair}, }; use test_client::{ self, AccountKeyring, runtime::{Extrinsic, Transfer, SessionKeys}, DefaultTestClientBuilderExt, @@ -238,4 +238,4 @@ fn should_rotate_keys() { assert_eq!(session_keys.ed25519, ed25519_key_pair.public().into()); assert_eq!(session_keys.sr25519, sr25519_key_pair.public().into()); -} \ No newline at end of file +} diff --git a/substrate/core/rpc/src/state/tests.rs b/substrate/core/rpc/src/state/tests.rs index f2a0c37b78..ba1aac4cc3 100644 --- a/substrate/core/rpc/src/state/tests.rs +++ b/substrate/core/rpc/src/state/tests.rs @@ -36,7 +36,7 @@ fn should_return_storage() { const STORAGE_KEY: &[u8] = b":child_storage:default:child"; const CHILD_VALUE: &[u8] = b"hello world !"; - let core = tokio::runtime::Runtime::new().unwrap(); + let mut core = tokio::runtime::Runtime::new().unwrap(); let client = TestClientBuilder::new() .add_extra_storage(KEY.to_vec(), VALUE.to_vec()) .add_extra_child_storage(STORAGE_KEY.to_vec(), KEY.to_vec(), CHILD_VALUE.to_vec()) @@ -61,8 +61,10 @@ fn should_return_storage() { VALUE.len(), ); assert_eq!( - client.child_storage(storage_key, key, Some(genesis_hash).into()) - .map(|x| x.map(|x| x.0.len())).unwrap().unwrap() as usize, + core.block_on( + client.child_storage(storage_key, key, Some(genesis_hash).into()) + .map(|x| x.map(|x| x.0.len())) + ).unwrap().unwrap() as usize, CHILD_VALUE.len(), );