client: only report block import to telemetry if new best (#3548)

* client: only report block import to telemetry if new best

* grandpa: fix tests

* consensus: derive Default for ImportedAux

* network: fix test
This commit is contained in:
André Silva
2019-09-04 17:14:42 +01:00
committed by GitHub
parent c6f3798078
commit 397855c611
5 changed files with 40 additions and 29 deletions
@@ -16,8 +16,9 @@
//! Testing block import logic.
use consensus::ImportedAux;
use consensus::import_queue::{
import_single_block, IncomingBlock, BasicQueue, BlockImportError, BlockImportResult
import_single_block, BasicQueue, BlockImportError, BlockImportResult, IncomingBlock,
};
use test_client::{self, prelude::*};
use test_client::runtime::{Block, Hash};
@@ -45,9 +46,13 @@ fn prepare_good_block() -> (TestClient, Hash, u64, PeerId, IncomingBlock<Block>)
#[test]
fn import_single_good_block_works() {
let (_, _hash, number, peer_id, block) = prepare_good_block();
let mut expected_aux = ImportedAux::default();
expected_aux.is_new_best = true;
match import_single_block(&mut test_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) {
Ok(BlockImportResult::ImportedUnknown(ref num, ref aux, ref org))
if *num == number && *aux == Default::default() && *org == Some(peer_id) => {}
if *num == number && *aux == expected_aux && *org == Some(peer_id) => {}
_ => panic!()
}
}