From f55a2373b90c9a173ba79546e3d85550bfd3dc6e Mon Sep 17 00:00:00 2001 From: Vadim Smirnov Date: Tue, 29 Oct 2024 16:56:02 +0100 Subject: [PATCH] fmt --- node/authorship/src/tests.rs | 6 ++-- node/testing/src/client.rs | 40 ++++++++++----------- node/testing/src/keyring.rs | 70 ++++++++++++++++++------------------ 3 files changed, 58 insertions(+), 58 deletions(-) diff --git a/node/authorship/src/tests.rs b/node/authorship/src/tests.rs index 52072966cfc..71a761a2890 100644 --- a/node/authorship/src/tests.rs +++ b/node/authorship/src/tests.rs @@ -67,8 +67,8 @@ use std::{ }; use testing::{ client::{ - Backend as TestBackend, Client as TestClient, ClientBlockImportExt, - RuntimeExecutor, TestClientBuilder, TestClientBuilderExt, + Backend as TestBackend, Client as TestClient, ClientBlockImportExt, RuntimeExecutor, + TestClientBuilder, TestClientBuilderExt, }, keyring::{alice, bob, sign, signed_extra, CheckedExtrinsic}, }; @@ -705,7 +705,6 @@ fn test_block_builder_cloned_ok() { genesis_hash, ); - let mut block_builder = BlockBuilderBuilder::new(client.as_ref()) .on_parent_block(genesis_hash.into()) .with_parent_block_number(0) @@ -714,7 +713,6 @@ fn test_block_builder_cloned_ok() { .unwrap(); extrinsics.into_iter().for_each(|xt: OpaqueExtrinsic| { - log::info!("{:?}", &xt); assert_ok!(block_builder.push(xt)); }); diff --git a/node/testing/src/client.rs b/node/testing/src/client.rs index 3b6c04eeac5..7f1fcae99d8 100644 --- a/node/testing/src/client.rs +++ b/node/testing/src/client.rs @@ -61,11 +61,11 @@ impl substrate_test_client::GenesisInit for GenesisParameters { /// A `test-runtime` extensions to `TestClientBuilder`. pub trait TestClientBuilderExt: Sized { - /// Create test client builder. - fn new() -> Self; + /// Create test client builder. + fn new() -> Self; - /// Build the test client. - fn build(self, executor: Option) -> Client; + /// Build the test client. + fn build(self, executor: Option) -> Client; } impl TestClientBuilderExt @@ -76,20 +76,20 @@ impl TestClientBuilderExt GenesisParameters, > { - fn new() -> Self { - Self::default() - } - fn build(self, executor: Option) -> Client { - let executor = executor.unwrap_or_else(|| RuntimeExecutor::builder().build()); - use sc_service::client::LocalCallExecutor; - use std::sync::Arc; - let executor = LocalCallExecutor::new( - self.backend().clone(), - executor.clone(), - Default::default(), - ExecutionExtensions::new(None, Arc::new(executor)), - ) - .expect("Creates LocalCallExecutor"); - self.build_with_executor(executor).0 - } + fn new() -> Self { + Self::default() + } + fn build(self, executor: Option) -> Client { + let executor = executor.unwrap_or_else(|| RuntimeExecutor::builder().build()); + use sc_service::client::LocalCallExecutor; + use std::sync::Arc; + let executor = LocalCallExecutor::new( + self.backend().clone(), + executor.clone(), + Default::default(), + ExecutionExtensions::new(None, Arc::new(executor)), + ) + .expect("Creates LocalCallExecutor"); + self.build_with_executor(executor).0 + } } diff --git a/node/testing/src/keyring.rs b/node/testing/src/keyring.rs index 99137e831c6..86913bc54fe 100644 --- a/node/testing/src/keyring.rs +++ b/node/testing/src/keyring.rs @@ -91,39 +91,41 @@ pub fn signed_extra(nonce: Nonce) -> SignedExtra { /// Sign given `CheckedExtrinsic`. pub fn sign( - xt: CheckedExtrinsic, - spec_version: u32, - tx_version: u32, - genesis_hash: [u8; 32], - metadata_hash: Option<[u8; 32]>, + xt: CheckedExtrinsic, + spec_version: u32, + tx_version: u32, + genesis_hash: [u8; 32], + metadata_hash: Option<[u8; 32]>, ) -> UncheckedExtrinsic { - match xt.signed { - Some((signed, extra)) => { - let payload = ( - xt.function, - extra.clone(), - spec_version, - tx_version, - genesis_hash, - genesis_hash, - metadata_hash, - ); - let key = AccountKeyring::from_account_id(&signed).unwrap(); - let signature = - payload - .using_encoded(|b| { - if b.len() > 256 { - key.sign(&sp_io::hashing::blake2_256(b)) - } else { - key.sign(b) - } - }) - .into(); - UncheckedExtrinsic { - signature: Some((sp_runtime::MultiAddress::Id(signed), signature, extra)), - function: payload.0, - } - }, - None => UncheckedExtrinsic { signature: None, function: xt.function }, - } + match xt.signed { + Some((signed, extra)) => { + let payload = ( + xt.function, + extra.clone(), + spec_version, + tx_version, + genesis_hash, + genesis_hash, + metadata_hash, + ); + let key = AccountKeyring::from_account_id(&signed).unwrap(); + let signature = payload + .using_encoded(|b| { + if b.len() > 256 { + key.sign(&sp_io::hashing::blake2_256(b)) + } else { + key.sign(b) + } + }) + .into(); + UncheckedExtrinsic { + signature: Some((sp_runtime::MultiAddress::Id(signed), signature, extra)), + function: payload.0, + } + } + None => UncheckedExtrinsic { + signature: None, + function: xt.function, + }, + } }