mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 22:41:02 +00:00
BlockId removal: refactor: Finalizer (#12528)
* BlockId removal: refactor: Finalizer It changes the arguments of methods of `Finalizer` trait from: block: `BlockId<Block>` to: hash: `&Block::Hash` This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292) * minor corrections * failing test corrected * minor rework
This commit is contained in:
committed by
GitHub
parent
7aadc2aa3c
commit
749bcd1949
@@ -1352,7 +1352,7 @@ where
|
||||
// ideally some handle to a synchronization oracle would be used
|
||||
// to avoid unconditionally notifying.
|
||||
client
|
||||
.apply_finality(import_op, BlockId::Hash(hash), persisted_justification, true)
|
||||
.apply_finality(import_op, &hash, persisted_justification, true)
|
||||
.map_err(|e| {
|
||||
warn!(target: "afg", "Error applying finality to block {:?}: {}", (hash, number), e);
|
||||
e
|
||||
|
||||
@@ -309,7 +309,8 @@ mod tests {
|
||||
}
|
||||
|
||||
for block in to_finalize {
|
||||
client.finalize_block(BlockId::Number(*block), None).unwrap();
|
||||
let hash = blocks[*block as usize - 1].hash();
|
||||
client.finalize_block(&hash, None).unwrap();
|
||||
}
|
||||
(client, backend, blocks)
|
||||
}
|
||||
@@ -489,7 +490,7 @@ mod tests {
|
||||
let grandpa_just8 = GrandpaJustification::from_commit(&client, round, commit).unwrap();
|
||||
|
||||
client
|
||||
.finalize_block(BlockId::Number(8), Some((ID, grandpa_just8.encode().clone())))
|
||||
.finalize_block(&block8.hash(), Some((ID, grandpa_just8.encode().clone())))
|
||||
.unwrap();
|
||||
|
||||
// Authority set change at block 8, so the justification stored there will be used in the
|
||||
|
||||
@@ -1457,7 +1457,12 @@ fn grandpa_environment_respects_voting_rules() {
|
||||
);
|
||||
|
||||
// we finalize block 19 with block 21 being the best block
|
||||
peer.client().finalize_block(BlockId::Number(19), None, false).unwrap();
|
||||
let hashof19 = peer
|
||||
.client()
|
||||
.as_client()
|
||||
.expect_block_hash_from_id(&BlockId::Number(19))
|
||||
.unwrap();
|
||||
peer.client().finalize_block(&hashof19, None, false).unwrap();
|
||||
|
||||
// the 3/4 environment should propose block 21 for voting
|
||||
assert_eq!(
|
||||
@@ -1479,7 +1484,12 @@ fn grandpa_environment_respects_voting_rules() {
|
||||
);
|
||||
|
||||
// we finalize block 21 with block 21 being the best block
|
||||
peer.client().finalize_block(BlockId::Number(21), None, false).unwrap();
|
||||
let hashof21 = peer
|
||||
.client()
|
||||
.as_client()
|
||||
.expect_block_hash_from_id(&BlockId::Number(21))
|
||||
.unwrap();
|
||||
peer.client().finalize_block(&hashof21, None, false).unwrap();
|
||||
|
||||
// even though the default environment will always try to not vote on the
|
||||
// best block, there's a hard rule that we can't cast any votes lower than
|
||||
|
||||
@@ -327,7 +327,7 @@ mod tests {
|
||||
use sp_consensus::BlockOrigin;
|
||||
use sp_finality_grandpa::GRANDPA_ENGINE_ID;
|
||||
use sp_keyring::Ed25519Keyring;
|
||||
use sp_runtime::{generic::BlockId, traits::Header as _};
|
||||
use sp_runtime::traits::Header as _;
|
||||
use std::sync::Arc;
|
||||
use substrate_test_runtime_client::{
|
||||
ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt, TestClientBuilder,
|
||||
@@ -412,10 +412,7 @@ mod tests {
|
||||
let justification = GrandpaJustification::from_commit(&client, 42, commit).unwrap();
|
||||
|
||||
client
|
||||
.finalize_block(
|
||||
BlockId::Hash(target_hash),
|
||||
Some((GRANDPA_ENGINE_ID, justification.encode())),
|
||||
)
|
||||
.finalize_block(&target_hash, Some((GRANDPA_ENGINE_ID, justification.encode())))
|
||||
.unwrap();
|
||||
|
||||
authority_set_changes.push((current_set_id, n));
|
||||
|
||||
Reference in New Issue
Block a user