mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 04:01:10 +00:00
added one more test to parachains finality pallet (#1435)
This commit is contained in:
committed by
Bastian Köcher
parent
5340ee5ab5
commit
690a929cf6
@@ -264,7 +264,7 @@ pub mod pallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Try to update parachain head.
|
/// Try to update parachain head.
|
||||||
fn update_parachain_head(
|
pub(super) fn update_parachain_head(
|
||||||
parachain: ParaId,
|
parachain: ParaId,
|
||||||
stored_best_head: Option<BestParaHead>,
|
stored_best_head: Option<BestParaHead>,
|
||||||
updated_at_relay_block_number: RelayBlockNumber,
|
updated_at_relay_block_number: RelayBlockNumber,
|
||||||
@@ -691,4 +691,54 @@ mod tests {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn is_not_rewriting_existing_head_if_failed_to_read_updated_head() {
|
||||||
|
let (state_root_5, proof_5) = prepare_parachain_heads_proof(vec![(1, head_data(1, 5))]);
|
||||||
|
let (state_root_10_at_20, proof_10_at_20) =
|
||||||
|
prepare_parachain_heads_proof(vec![(2, head_data(2, 10))]);
|
||||||
|
let (state_root_10_at_30, proof_10_at_30) =
|
||||||
|
prepare_parachain_heads_proof(vec![(1, head_data(1, 10))]);
|
||||||
|
run_test(|| {
|
||||||
|
// we've already imported head#5 of parachain#1 at relay block#10
|
||||||
|
initialize(state_root_5);
|
||||||
|
import_parachain_1_head(0, state_root_5, proof_5).expect("ok");
|
||||||
|
assert_eq!(
|
||||||
|
Pallet::<TestRuntime>::best_parachain_head(ParaId(1)),
|
||||||
|
Some(head_data(1, 5))
|
||||||
|
);
|
||||||
|
|
||||||
|
// then if someone is pretending to provide updated head#10 of parachain#1 at relay
|
||||||
|
// block#20, but fails to do that
|
||||||
|
//
|
||||||
|
// => we'll leave previous value
|
||||||
|
proceed(20, state_root_10_at_20);
|
||||||
|
assert_ok!(Pallet::<TestRuntime>::submit_parachain_heads(
|
||||||
|
Origin::signed(1),
|
||||||
|
test_relay_header(20, state_root_10_at_20).hash(),
|
||||||
|
vec![ParaId(1)],
|
||||||
|
proof_10_at_20,
|
||||||
|
),);
|
||||||
|
assert_eq!(
|
||||||
|
Pallet::<TestRuntime>::best_parachain_head(ParaId(1)),
|
||||||
|
Some(head_data(1, 5))
|
||||||
|
);
|
||||||
|
|
||||||
|
// then if someone is pretending to provide updated head#10 of parachain#1 at relay
|
||||||
|
// block#30, and actualy provides it
|
||||||
|
//
|
||||||
|
// => we'll update value
|
||||||
|
proceed(30, state_root_10_at_30);
|
||||||
|
assert_ok!(Pallet::<TestRuntime>::submit_parachain_heads(
|
||||||
|
Origin::signed(1),
|
||||||
|
test_relay_header(30, state_root_10_at_30).hash(),
|
||||||
|
vec![ParaId(1)],
|
||||||
|
proof_10_at_30,
|
||||||
|
),);
|
||||||
|
assert_eq!(
|
||||||
|
Pallet::<TestRuntime>::best_parachain_head(ParaId(1)),
|
||||||
|
Some(head_data(1, 10))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user