Skip to content

Commit 99baf51

Browse files
foriequal0mergify[bot]
authored andcommitted
Fix assertions to clarify the intention
1 parent 8731fc4 commit 99baf51

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

core/src/consensus/tendermint/vote_regression_checker.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ impl VoteRegressionChecker {
1313
}
1414

1515
pub fn check(&mut self, vote_on: &VoteOn) -> bool {
16-
assert!(match vote_on.step.step {
17-
Step::Propose | Step::Prevote | Step::Precommit => true,
18-
_ => false,
19-
});
16+
assert!(
17+
match vote_on.step.step {
18+
Step::Propose | Step::Prevote | Step::Precommit => true,
19+
_ => false,
20+
},
21+
"We don't vote on Commit. Check your code"
22+
);
2023

2124
let monotonic = if let Some(last_vote) = &self.last_vote {
2225
match last_vote.step.cmp(&vote_on.step) {
@@ -55,15 +58,15 @@ mod tests {
5558

5659
#[test]
5760
#[should_panic]
58-
fn test_disallow_commit() {
61+
fn test_panic_on_commit() {
5962
let mut checker = VoteRegressionChecker::new();
6063

6164
let random_commit_step = VoteStep::new(100, 10, Step::Commit);
6265
let random_hash = Some(H256::random());
63-
assert!(checker.check(&VoteOn {
66+
checker.check(&VoteOn {
6467
step: random_commit_step,
65-
block_hash: random_hash
66-
}))
68+
block_hash: random_hash,
69+
});
6770
}
6871

6972
#[test]

0 commit comments

Comments
 (0)