Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ukint-vs committed Oct 29, 2024
1 parent 992c25f commit f55a237
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 58 deletions.
6 changes: 2 additions & 4 deletions node/authorship/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -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)
Expand All @@ -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));
});
Expand Down
40 changes: 20 additions & 20 deletions node/testing/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RuntimeExecutor>) -> Client;
/// Build the test client.
fn build(self, executor: Option<RuntimeExecutor>) -> Client;
}

impl TestClientBuilderExt
Expand All @@ -76,20 +76,20 @@ impl TestClientBuilderExt
GenesisParameters,
>
{
fn new() -> Self {
Self::default()
}
fn build(self, executor: Option<RuntimeExecutor>) -> 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<RuntimeExecutor>) -> 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
}
}
70 changes: 36 additions & 34 deletions node/testing/src/keyring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
}

0 comments on commit f55a237

Please sign in to comment.