mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 08:37:56 +00:00
BlockId removal: refactor: HeaderBackend::header (#6418)
* BlockId removal: refactor: HeaderBackend::header It changes the arguments of: - `HeaderBackend::header`, - `Client::header` methods from: `BlockId<Block>` to: `Block::Hash` This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292) * missed fixes * BlockId removal: refactor: HeaderBackend::expect_header It changes the arguments of `HeaderBackend::expect_header` method from: `BlockId<Block>` to: `Block::Hash` * update lockfile for {"substrate"} * misspell fixed Co-authored-by: parity-processbot <>
This commit is contained in:
committed by
GitHub
parent
f687ab005a
commit
fcc26d42e4
@@ -117,13 +117,11 @@ impl HeaderBackend<Block> for TestClient {
|
||||
fn hash(&self, number: BlockNumber) -> sp_blockchain::Result<Option<Hash>> {
|
||||
Ok(self.finalized_blocks.get(&number).copied())
|
||||
}
|
||||
fn header(&self, id: BlockId) -> sp_blockchain::Result<Option<Header>> {
|
||||
match id {
|
||||
// for error path testing
|
||||
BlockId::Hash(hash) if hash.is_zero() =>
|
||||
Err(sp_blockchain::Error::Backend("Zero hashes are illegal!".into())),
|
||||
BlockId::Hash(hash) => Ok(self.headers.get(&hash).cloned()),
|
||||
_ => unreachable!(),
|
||||
fn header(&self, hash: Hash) -> sp_blockchain::Result<Option<Header>> {
|
||||
if hash.is_zero() {
|
||||
Err(sp_blockchain::Error::Backend("Zero hashes are illegal!".into()))
|
||||
} else {
|
||||
Ok(self.headers.get(&hash).cloned())
|
||||
}
|
||||
}
|
||||
fn status(&self, _id: BlockId) -> sp_blockchain::Result<sp_blockchain::BlockStatus> {
|
||||
@@ -203,10 +201,8 @@ fn request_block_header() {
|
||||
test_harness(|client, mut sender| {
|
||||
async move {
|
||||
const NOT_HERE: Hash = Hash::repeat_byte(0x5);
|
||||
let test_cases = [
|
||||
(TWO, client.header(BlockId::Hash(TWO)).unwrap()),
|
||||
(NOT_HERE, client.header(BlockId::Hash(NOT_HERE)).unwrap()),
|
||||
];
|
||||
let test_cases =
|
||||
[(TWO, client.header(TWO).unwrap()), (NOT_HERE, client.header(NOT_HERE).unwrap())];
|
||||
for (hash, expected) in &test_cases {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user