Revert "BlockId removal: refactor: HeaderBackend::header (#1977)"

This reverts commit b7dff85939.
This commit is contained in:
EgorPopelyaev
2022-12-21 12:15:09 +01:00
parent fa953ab35a
commit 0f59d20a1e
5 changed files with 150 additions and 25 deletions
+13 -17
View File
@@ -82,10 +82,7 @@ mod tests {
ValidationParams,
};
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT},
};
use sp_runtime::{generic::BlockId, traits::Header as HeaderT};
use std::{env, process::Command, str::FromStr};
const SLOT_DURATION: u64 = 6000;
@@ -109,14 +106,14 @@ mod tests {
fn build_block(
client: &Client,
hash: <Block as BlockT>::Hash,
at: BlockId<Block>,
timestamp: u64,
relay_chain_slot: Slot,
) -> (ParachainBlockData, PHash) {
let sproof_builder =
RelayStateSproofBuilder { current_slot: relay_chain_slot, ..Default::default() };
let parent_header = client.header(hash).ok().flatten().expect("Genesis header exists");
let parent_header = client.header(&at).ok().flatten().expect("Genesis header exists");
let relay_parent_storage_root = sproof_builder.clone().into_state_root_and_proof().0;
@@ -128,7 +125,7 @@ mod tests {
let block = client
.init_block_builder_with_timestamp(
&BlockId::Hash(hash),
&at,
Some(validation_data),
sproof_builder,
timestamp,
@@ -149,20 +146,19 @@ mod tests {
.expect("TIMESTAMP is a valid `u64`");
let block =
build_block(&client, client.chain_info().genesis_hash, SLOT_DURATION, 1.into())
.0
.into_block();
futures::executor::block_on(
client.import(sp_consensus::BlockOrigin::Own, block.clone()),
)
.unwrap();
build_block(&client, BlockId::number(0), SLOT_DURATION, 1.into()).0.into_block();
futures::executor::block_on(client.import(sp_consensus::BlockOrigin::Own, block))
.unwrap();
let hashof1 = block.hash();
let (block, relay_chain_root) =
build_block(&client, hashof1, timestamp, relay_chain_slot.into());
build_block(&client, BlockId::number(1), timestamp, relay_chain_slot.into());
let header = call_validate_block(
client.header(hashof1).ok().flatten().expect("Genesis header exists"),
client
.header(&BlockId::number(1))
.ok()
.flatten()
.expect("Genesis header exists"),
block.clone(),
relay_chain_root,
)