mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 01:41:09 +00:00
chain-selection: allow reverting current block (#4103)
Block reversion of the current block is technically possible as can be seen from https://github.com/paritytech/polkadot-sdk/blob/39b1f50f1c251def87c1625d68567ed252dc6272/polkadot/runtime/parachains/src/disputes.rs#L1215-L1223 - [x] Fix the test
This commit is contained in:
@@ -966,19 +966,54 @@ fn ancestor_of_unviable_is_not_leaf_if_has_children() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn self_and_future_reversions_are_ignored() {
|
||||
fn self_reversions_are_not_ignored() {
|
||||
test_harness(|backend, _, mut virtual_overseer| async move {
|
||||
let finalized_number = 0;
|
||||
let finalized_hash = Hash::repeat_byte(0);
|
||||
|
||||
// F <- A1 <- A2 <- A3.
|
||||
//
|
||||
// A3 reverts itself and future blocks. ignored.
|
||||
// A3 reverts itself
|
||||
|
||||
let (_, chain_a) =
|
||||
construct_chain_on_base(vec![1, 2, 3], finalized_number, finalized_hash, |h| {
|
||||
if h.number == 3 {
|
||||
add_reversions(h, vec![3])
|
||||
}
|
||||
});
|
||||
|
||||
let a2_hash = chain_a.iter().rev().nth(1).unwrap().0.hash();
|
||||
|
||||
import_blocks_into(
|
||||
&mut virtual_overseer,
|
||||
&backend,
|
||||
Some((finalized_number, finalized_hash)),
|
||||
chain_a.clone(),
|
||||
)
|
||||
.await;
|
||||
|
||||
assert_backend_contains(&backend, chain_a.iter().map(|(h, _)| h));
|
||||
assert_leaves(&backend, vec![a2_hash]);
|
||||
assert_leaves_query(&mut virtual_overseer, vec![a2_hash]).await;
|
||||
|
||||
virtual_overseer
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn future_reversions_are_ignored() {
|
||||
test_harness(|backend, _, mut virtual_overseer| async move {
|
||||
let finalized_number = 0;
|
||||
let finalized_hash = Hash::repeat_byte(0);
|
||||
|
||||
// F <- A1 <- A2 <- A3.
|
||||
//
|
||||
// A3 reverts future blocks. ignored.
|
||||
|
||||
let (a3_hash, chain_a) =
|
||||
construct_chain_on_base(vec![1, 2, 3], finalized_number, finalized_hash, |h| {
|
||||
if h.number == 3 {
|
||||
add_reversions(h, vec![3, 4, 100])
|
||||
add_reversions(h, vec![4, 100])
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1006,7 +1041,7 @@ fn revert_finalized_is_ignored() {
|
||||
|
||||
// F <- A1 <- A2 <- A3.
|
||||
//
|
||||
// A3 reverts itself and future blocks. ignored.
|
||||
// A3 reverts finalized F and its ancestors. ignored.
|
||||
|
||||
let (a3_hash, chain_a) =
|
||||
construct_chain_on_base(vec![1, 2, 3], finalized_number, finalized_hash, |h| {
|
||||
|
||||
Reference in New Issue
Block a user