Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into mku-blockid-new_blo…
…ck_at
  • Loading branch information
michalkucharczyk committed Feb 21, 2023
commit 7fc1c0f18e08a54bd931f1e5079c893c36f53a91
30 changes: 12 additions & 18 deletions client/beefy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,10 +752,7 @@ async fn beefy_importing_justifications() {
.and_then(|j| j.get(BEEFY_ENGINE_ID).cloned())
};

let full_client = client.as_client();
let builder = full_client
.new_block_at(full_client.chain_info().genesis_hash, Default::default(), false)
.unwrap();
let builder = full_client.new_block_at(full_client.chain_info().genesis_hash, Default::default(), false).unwrap();
let block = builder.build().unwrap().block;
let hashof1 = block.header.hash();

Expand All @@ -773,9 +770,8 @@ async fn beefy_importing_justifications() {
);

// Import block 2 with "valid" justification (beefy pallet genesis block not yet reached).
let parent_id = BlockId::Number(1);
let block_num = 2;
let builder = full_client.new_block_at(&parent_id, Default::default(), false).unwrap();
let builder = full_client.new_block_at(hashof1, Default::default(), false).unwrap();
let block = builder.build().unwrap().block;
let hashof2 = block.header.hash();

Expand Down Expand Up @@ -805,16 +801,15 @@ async fn beefy_importing_justifications() {
.await;
}

// Import with valid justification.
let block_num = 2;
// Import block 3 with valid justification.
let block_num = 3;
let builder = full_client.new_block_at(hashof2, Default::default(), false).unwrap();
let block = builder.build().unwrap().block;
let hashof3 = block.header.hash();
let proof = crate::justification::tests::new_finality_proof(block_num, &good_set, keys);
let versioned_proof: VersionedFinalityProof<NumberFor<Block>, Signature> = proof.into();
let encoded = versioned_proof.encode();
let justif = Some(Justifications::from((BEEFY_ENGINE_ID, encoded)));

let builder = full_client.new_block_at(hashof1, Default::default(), false).unwrap();
let block = builder.build().unwrap().block;
let hashof2 = block.header.hash();
let mut justif_recv = justif_stream.subscribe(100_000);
assert_eq!(
block_import.import_block(params(block, justif), HashMap::new()).await.unwrap(),
Expand All @@ -840,18 +835,17 @@ async fn beefy_importing_justifications() {
.await;
}

// Import with invalid justification (incorrect validator set).
let block_num = 3;
// Import block 4 with invalid justification (incorrect validator set).
let block_num = 4;
let builder = full_client.new_block_at(hashof3, Default::default(), false).unwrap();
let block = builder.build().unwrap().block;
let hashof4 = block.header.hash();
let keys = &[BeefyKeyring::Alice];
let bad_set = ValidatorSet::new(make_beefy_ids(keys), 1).unwrap();
let proof = crate::justification::tests::new_finality_proof(block_num, &bad_set, keys);
let versioned_proof: VersionedFinalityProof<NumberFor<Block>, Signature> = proof.into();
let encoded = versioned_proof.encode();
let justif = Some(Justifications::from((BEEFY_ENGINE_ID, encoded)));

let builder = full_client.new_block_at(hashof2, Default::default(), false).unwrap();
let block = builder.build().unwrap().block;
let hashof3 = block.header.hash();
let mut justif_recv = justif_stream.subscribe(100_000);
assert_eq!(
block_import.import_block(params(block, justif), HashMap::new()).await.unwrap(),
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.