mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 01:38:04 +00:00
Integration tests (#805)
* Started substrate tests * Sync test * Test updates * Improved tests * Use on-chain block delay * Parallel test execution * Otimized tests * Logging * Fixed racing test * Fixed compilation * Fixed timestamp test * Removed rlp dependency * Minor fixes * Fixed tests * Removed best_block_id and resolved fdlimit issue * Whitespace * Use keyring * Style * Added API execution setting * Removed stale import
This commit is contained in:
committed by
Gav Wood
parent
955a5393d8
commit
9a660f82ed
@@ -18,6 +18,8 @@
|
||||
|
||||
use client::{self, Client};
|
||||
use keyring::Keyring;
|
||||
use primitives::ed25519;
|
||||
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT};
|
||||
use runtime_primitives::generic::BlockId;
|
||||
use primitives::Blake2Hasher;
|
||||
use runtime;
|
||||
@@ -41,7 +43,13 @@ impl<B, E> TestClient for Client<B, E, runtime::Block>
|
||||
E: client::CallExecutor<runtime::Block, Blake2Hasher>
|
||||
{
|
||||
fn justify_and_import(&self, origin: client::BlockOrigin, block: runtime::Block) -> client::error::Result<()> {
|
||||
let justification = fake_justify(&block.header);
|
||||
let authorities: [ed25519::Pair; 3] = [
|
||||
Keyring::Alice.into(),
|
||||
Keyring::Bob.into(),
|
||||
Keyring::Charlie.into(),
|
||||
];
|
||||
let keys: Vec<&ed25519::Pair> = authorities.iter().collect();
|
||||
let justification = fake_justify::<runtime::Block>(&block.header, &keys);
|
||||
let justified = self.check_justification(block.header, justification)?;
|
||||
self.import_block(origin, justified, Some(block.extrinsics), false)?;
|
||||
|
||||
@@ -63,21 +71,15 @@ impl<B, E> TestClient for Client<B, E, runtime::Block>
|
||||
/// headers.
|
||||
/// TODO: remove this in favor of custom verification pipelines for the
|
||||
/// client
|
||||
fn fake_justify(header: &runtime::Header) -> bft::UncheckedJustification<runtime::Hash> {
|
||||
pub fn fake_justify<Block: BlockT>(header: &Block::Header, authorities: &[&ed25519::Pair]) -> bft::UncheckedJustification<Block::Hash> {
|
||||
let hash = header.hash();
|
||||
let authorities = vec![
|
||||
Keyring::Alice.into(),
|
||||
Keyring::Bob.into(),
|
||||
Keyring::Charlie.into(),
|
||||
];
|
||||
|
||||
bft::UncheckedJustification::new(
|
||||
hash,
|
||||
authorities.iter().map(|key| {
|
||||
let msg = bft::sign_message::<runtime::Block>(
|
||||
let msg = bft::sign_message::<Block>(
|
||||
::rhododendron::Vote::Commit(1, hash).into(),
|
||||
key,
|
||||
header.parent_hash
|
||||
header.parent_hash().clone(),
|
||||
);
|
||||
|
||||
match msg {
|
||||
|
||||
Reference in New Issue
Block a user