mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 06:47:57 +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
@@ -251,18 +251,22 @@ fn sync_justifications() {
|
||||
assert_eq!(net.peer(1).client().justifications(&BlockId::Number(10)).unwrap(), None);
|
||||
|
||||
// we finalize block #10, #15 and #20 for peer 0 with a justification
|
||||
let backend = net.peer(0).client().as_backend();
|
||||
let hashof10 = backend.blockchain().expect_block_hash_from_id(&BlockId::Number(10)).unwrap();
|
||||
let hashof15 = backend.blockchain().expect_block_hash_from_id(&BlockId::Number(15)).unwrap();
|
||||
let hashof20 = backend.blockchain().expect_block_hash_from_id(&BlockId::Number(20)).unwrap();
|
||||
let just = (*b"FRNK", Vec::new());
|
||||
net.peer(0)
|
||||
.client()
|
||||
.finalize_block(BlockId::Number(10), Some(just.clone()), true)
|
||||
.finalize_block(&hashof10, Some(just.clone()), true)
|
||||
.unwrap();
|
||||
net.peer(0)
|
||||
.client()
|
||||
.finalize_block(BlockId::Number(15), Some(just.clone()), true)
|
||||
.finalize_block(&hashof15, Some(just.clone()), true)
|
||||
.unwrap();
|
||||
net.peer(0)
|
||||
.client()
|
||||
.finalize_block(BlockId::Number(20), Some(just.clone()), true)
|
||||
.finalize_block(&hashof20, Some(just.clone()), true)
|
||||
.unwrap();
|
||||
|
||||
let h1 = net.peer(1).client().header(&BlockId::Number(10)).unwrap().unwrap();
|
||||
@@ -309,10 +313,7 @@ fn sync_justifications_across_forks() {
|
||||
net.block_until_sync();
|
||||
|
||||
let just = (*b"FRNK", Vec::new());
|
||||
net.peer(0)
|
||||
.client()
|
||||
.finalize_block(BlockId::Hash(f1_best), Some(just), true)
|
||||
.unwrap();
|
||||
net.peer(0).client().finalize_block(&f1_best, Some(just), true).unwrap();
|
||||
|
||||
net.peer(1).request_justification(&f1_best, 10);
|
||||
net.peer(1).request_justification(&f2_best, 11);
|
||||
@@ -655,14 +656,8 @@ fn can_sync_to_peers_with_wrong_common_block() {
|
||||
|
||||
// both peers re-org to the same fork without notifying each other
|
||||
let just = Some((*b"FRNK", Vec::new()));
|
||||
net.peer(0)
|
||||
.client()
|
||||
.finalize_block(BlockId::Hash(fork_hash), just.clone(), true)
|
||||
.unwrap();
|
||||
net.peer(1)
|
||||
.client()
|
||||
.finalize_block(BlockId::Hash(fork_hash), just, true)
|
||||
.unwrap();
|
||||
net.peer(0).client().finalize_block(&fork_hash, just.clone(), true).unwrap();
|
||||
net.peer(1).client().finalize_block(&fork_hash, just, true).unwrap();
|
||||
let final_hash = net.peer(0).push_blocks(1, false);
|
||||
|
||||
net.block_until_sync();
|
||||
@@ -976,10 +971,17 @@ fn multiple_requests_are_accepted_as_long_as_they_are_not_fulfilled() {
|
||||
assert_eq!(1, net.peer(0).num_peers());
|
||||
}
|
||||
|
||||
let hashof10 = net
|
||||
.peer(0)
|
||||
.client()
|
||||
.as_backend()
|
||||
.blockchain()
|
||||
.expect_block_hash_from_id(&BlockId::Number(10))
|
||||
.unwrap();
|
||||
// Finalize the block and make the justification available.
|
||||
net.peer(0)
|
||||
.client()
|
||||
.finalize_block(BlockId::Number(10), Some((*b"FRNK", Vec::new())), true)
|
||||
.finalize_block(&hashof10, Some((*b"FRNK", Vec::new())), true)
|
||||
.unwrap();
|
||||
|
||||
block_on(futures::future::poll_fn::<(), _>(|cx| {
|
||||
@@ -1100,10 +1102,14 @@ fn syncs_state() {
|
||||
assert!(!net.peer(1).client().has_state_at(&BlockId::Number(64)));
|
||||
|
||||
let just = (*b"FRNK", Vec::new());
|
||||
net.peer(1)
|
||||
let hashof60 = net
|
||||
.peer(0)
|
||||
.client()
|
||||
.finalize_block(BlockId::Number(60), Some(just), true)
|
||||
.as_backend()
|
||||
.blockchain()
|
||||
.expect_block_hash_from_id(&BlockId::Number(60))
|
||||
.unwrap();
|
||||
net.peer(1).client().finalize_block(&hashof60, Some(just), true).unwrap();
|
||||
// Wait for state sync.
|
||||
block_on(futures::future::poll_fn::<(), _>(|cx| {
|
||||
net.poll(cx);
|
||||
|
||||
Reference in New Issue
Block a user