Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Fix test problem (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aki Wu authored Aug 8, 2022
1 parent 78d02d4 commit a3ed15d
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions primitives/header-chain/tests/implementation_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
//! Some of tests in this module may partially duplicate tests from `justification.rs`,
//! but their purpose is different.

use assert_matches::assert_matches;
use bp_header_chain::justification::{verify_justification, Error, GrandpaJustification};
use bp_test_utils::{
header_id, make_justification_for_header, signed_precommit, test_header, Account,
Expand Down Expand Up @@ -127,14 +126,15 @@ fn same_result_when_precommit_target_has_lower_number_than_commit_target() {
Err(Error::PrecommitIsNotCommitDescendant),
);
// original implementation returns empty GHOST
assert_matches!(
// https://github.com/paritytech/finality-grandpa/commit/36e409bcb76b41344be5b284732b529cd087432b#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L496-R521
assert_eq!(
finality_grandpa::validate_commit(
&justification.commit,
&full_voter_set(),
&AncestryChain::new(&justification.votes_ancestries),
)
.map(|result| result.ghost().cloned()),
Ok(None)
.map(|result| result.is_valid()),
Ok(false)
);
}

Expand All @@ -159,14 +159,15 @@ fn same_result_when_precommit_target_is_not_descendant_of_commit_target() {
Err(Error::PrecommitIsNotCommitDescendant),
);
// original implementation returns empty GHOST
assert_matches!(
// https://github.com/paritytech/finality-grandpa/commit/36e409bcb76b41344be5b284732b529cd087432b#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L496-R521
assert_eq!(
finality_grandpa::validate_commit(
&justification.commit,
&full_voter_set(),
&AncestryChain::new(&justification.votes_ancestries),
)
.map(|result| result.ghost().cloned()),
Ok(None)
.map(|result| result.is_valid()),
Ok(false)
);
}

Expand All @@ -189,14 +190,15 @@ fn same_result_when_justification_contains_duplicate_vote() {
Ok(()),
);
// original implementation returns non-empty GHOST
assert_matches!(
// https://github.com/paritytech/finality-grandpa/commit/36e409bcb76b41344be5b284732b529cd087432b#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L496-R521
assert_eq!(
finality_grandpa::validate_commit(
&justification.commit,
&full_voter_set(),
&AncestryChain::new(&justification.votes_ancestries),
)
.map(|result| result.ghost().cloned()),
Ok(Some(_))
.map(|result| result.is_valid()),
Ok(false)
);
}

Expand All @@ -223,14 +225,15 @@ fn same_result_when_authority_equivocates_once_in_a_round() {
Ok(()),
);
// original implementation returns non-empty GHOST
assert_matches!(
// https://github.com/paritytech/finality-grandpa/commit/36e409bcb76b41344be5b284732b529cd087432b#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L496-R521
assert_eq!(
finality_grandpa::validate_commit(
&justification.commit,
&full_voter_set(),
&AncestryChain::new(&justification.votes_ancestries),
)
.map(|result| result.ghost().cloned()),
Ok(Some(_))
.map(|result| result.is_valid()),
Ok(false)
);
}

Expand Down Expand Up @@ -267,14 +270,15 @@ fn same_result_when_authority_equivocates_twice_in_a_round() {
Ok(()),
);
// original implementation returns non-empty GHOST
assert_matches!(
// https://github.com/paritytech/finality-grandpa/commit/36e409bcb76b41344be5b284732b529cd087432b#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L496-R521
assert_eq!(
finality_grandpa::validate_commit(
&justification.commit,
&full_voter_set(),
&AncestryChain::new(&justification.votes_ancestries),
)
.map(|result| result.ghost().cloned()),
Ok(Some(_))
.map(|result| result.is_valid()),
Ok(false)
);
}

Expand All @@ -300,13 +304,14 @@ fn same_result_when_there_are_not_enough_cumulative_weight_to_finalize_commit_ta
Err(Error::TooLowCumulativeWeight),
);
// original implementation returns empty GHOST
assert_matches!(
// https://github.com/paritytech/finality-grandpa/commit/36e409bcb76b41344be5b284732b529cd087432b#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L496-R521
assert_eq!(
finality_grandpa::validate_commit(
&justification.commit,
&full_voter_set(),
&AncestryChain::new(&justification.votes_ancestries),
)
.map(|result| result.ghost().cloned()),
Ok(None)
.map(|result| result.is_valid()),
Ok(false)
);
}

0 comments on commit a3ed15d

Please sign in to comment.