mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
Make BlockImport and Verifier async (#8472)
* Make grandpa work * Introduce `SharedData` * Add test and fix bugs * Switch to `SharedData` * Make grandpa tests working * More Babe work * Make it async * Fix fix * Use `async_trait` in sc-consensus-slots This makes the code a little bit easier to read and also expresses that there can always only be one call at a time to `on_slot`. * Make grandpa tests compile * More Babe tests work * Fix network test * Start fixing service test * Finish service-test * Fix sc-consensus-aura * Fix fix fix * More fixes * Make everything compile *yeah* * Fix build when we have Rust 1.51 * Update client/consensus/common/src/shared_data.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/common/src/shared_data.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/common/src/shared_data.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/common/src/shared_data.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/common/src/shared_data.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/babe/src/tests.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/babe/src/tests.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Fix warning Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
@@ -26,12 +26,13 @@ use substrate_test_runtime_client::{self, prelude::*};
|
||||
use substrate_test_runtime_client::runtime::{Block, Hash};
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sc_block_builder::BlockBuilderProvider;
|
||||
use futures::executor::block_on;
|
||||
use super::*;
|
||||
|
||||
fn prepare_good_block() -> (TestClient, Hash, u64, PeerId, IncomingBlock<Block>) {
|
||||
let mut client = substrate_test_runtime_client::new();
|
||||
let block = client.new_block(Default::default()).unwrap().build().unwrap().block;
|
||||
client.import(BlockOrigin::File, block).unwrap();
|
||||
block_on(client.import(BlockOrigin::File, block)).unwrap();
|
||||
|
||||
let (hash, number) = (client.block_hash(1).unwrap().unwrap(), 1);
|
||||
let header = client.header(&BlockId::Number(1)).unwrap();
|
||||
@@ -55,12 +56,12 @@ fn import_single_good_block_works() {
|
||||
let mut expected_aux = ImportedAux::default();
|
||||
expected_aux.is_new_best = true;
|
||||
|
||||
match import_single_block(
|
||||
match block_on(import_single_block(
|
||||
&mut substrate_test_runtime_client::new(),
|
||||
BlockOrigin::File,
|
||||
block,
|
||||
&mut PassThroughVerifier::new(true)
|
||||
) {
|
||||
)) {
|
||||
Ok(BlockImportResult::ImportedUnknown(ref num, ref aux, ref org))
|
||||
if *num == number && *aux == expected_aux && *org == Some(peer_id) => {}
|
||||
r @ _ => panic!("{:?}", r)
|
||||
@@ -70,12 +71,12 @@ fn import_single_good_block_works() {
|
||||
#[test]
|
||||
fn import_single_good_known_block_is_ignored() {
|
||||
let (mut client, _hash, number, _, block) = prepare_good_block();
|
||||
match import_single_block(
|
||||
match block_on(import_single_block(
|
||||
&mut client,
|
||||
BlockOrigin::File,
|
||||
block,
|
||||
&mut PassThroughVerifier::new(true)
|
||||
) {
|
||||
)) {
|
||||
Ok(BlockImportResult::ImportedKnown(ref n, _)) if *n == number => {}
|
||||
_ => panic!()
|
||||
}
|
||||
@@ -85,12 +86,12 @@ fn import_single_good_known_block_is_ignored() {
|
||||
fn import_single_good_block_without_header_fails() {
|
||||
let (_, _, _, peer_id, mut block) = prepare_good_block();
|
||||
block.header = None;
|
||||
match import_single_block(
|
||||
match block_on(import_single_block(
|
||||
&mut substrate_test_runtime_client::new(),
|
||||
BlockOrigin::File,
|
||||
block,
|
||||
&mut PassThroughVerifier::new(true)
|
||||
) {
|
||||
)) {
|
||||
Err(BlockImportError::IncompleteHeader(ref org)) if *org == Some(peer_id) => {}
|
||||
_ => panic!()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user