mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 04:07:57 +00:00
* Grandpa justifications: Avoid duplicate vote ancestries
This commit is contained in:
committed by
Bastian Köcher
parent
0067c9fa7c
commit
dcd2debbb2
@@ -158,6 +158,26 @@ fn unrelated_ancestry_votes_are_removed_by_optimizer() {
|
||||
assert_eq!(num_precommits_before - 1, num_precommits_after);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn duplicate_votes_ancestries_are_removed_by_optimizer() {
|
||||
let mut justification = make_default_justification::<TestHeader>(&test_header(1));
|
||||
let optimized_votes_ancestries = justification.votes_ancestries.clone();
|
||||
justification.votes_ancestries = justification
|
||||
.votes_ancestries
|
||||
.into_iter()
|
||||
.flat_map(|item| std::iter::repeat(item).take(3))
|
||||
.collect();
|
||||
|
||||
verify_and_optimize_justification::<TestHeader>(
|
||||
header_id::<TestHeader>(1),
|
||||
&verification_context(TEST_GRANDPA_SET_ID),
|
||||
&mut justification,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(justification.votes_ancestries, optimized_votes_ancestries);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn redundant_votes_ancestries_are_removed_by_optimizer() {
|
||||
let mut justification = make_default_justification::<TestHeader>(&test_header(1));
|
||||
|
||||
@@ -149,7 +149,21 @@ fn justification_with_invalid_authority_signature_rejected() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn justification_with_invalid_precommit_ancestry() {
|
||||
fn justification_with_duplicate_votes_ancestry() {
|
||||
let mut justification = make_default_justification::<TestHeader>(&test_header(1));
|
||||
justification.votes_ancestries.push(justification.votes_ancestries[0].clone());
|
||||
|
||||
assert_eq!(
|
||||
verify_justification::<TestHeader>(
|
||||
header_id::<TestHeader>(1),
|
||||
&verification_context(TEST_GRANDPA_SET_ID),
|
||||
&justification,
|
||||
),
|
||||
Err(JustificationVerificationError::DuplicateVotesAncestries),
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn justification_with_redundant_votes_ancestry() {
|
||||
let mut justification = make_default_justification::<TestHeader>(&test_header(1));
|
||||
justification.votes_ancestries.push(test_header(10));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user