Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions core/src/consensus/tendermint/vote_regression_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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]
Expand Down