From 2738d271e04e830b3eae9d143e3ec8f63f67c1f6 Mon Sep 17 00:00:00 2001 From: SeongChan Lee Date: Mon, 30 Sep 2019 19:07:32 +0900 Subject: [PATCH] Fix assertions to clarify the intention --- .../tendermint/vote_regression_checker.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/core/src/consensus/tendermint/vote_regression_checker.rs b/core/src/consensus/tendermint/vote_regression_checker.rs index fc37907afa..5538c9ea45 100644 --- a/core/src/consensus/tendermint/vote_regression_checker.rs +++ b/core/src/consensus/tendermint/vote_regression_checker.rs @@ -13,10 +13,13 @@ impl VoteRegressionChecker { } pub fn check(&mut self, vote_on: &VoteOn) -> bool { - assert!(match vote_on.step.step { - Step::Propose | Step::Prevote | Step::Precommit => true, - _ => false, - }); + assert!( + match vote_on.step.step { + Step::Propose | Step::Prevote | Step::Precommit => true, + _ => false, + }, + "We don't vote on Commit. Check your code" + ); let monotonic = if let Some(last_vote) = &self.last_vote { match last_vote.step.cmp(&vote_on.step) { @@ -55,15 +58,15 @@ mod tests { #[test] #[should_panic] - fn test_disallow_commit() { + fn test_panic_on_commit() { let mut checker = VoteRegressionChecker::new(); let random_commit_step = VoteStep::new(100, 10, Step::Commit); let random_hash = Some(H256::random()); - assert!(checker.check(&VoteOn { + checker.check(&VoteOn { step: random_commit_step, - block_hash: random_hash - })) + block_hash: random_hash, + }); } #[test]