Skip to content

Commit 4fe8aaa

Browse files
authored
tests: Add extra tests to check the case when a rule return nil action (#2966)
1 parent 475f08d commit 4fe8aaa

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

consensus/tendermint/rule_proposal_and_polka_current_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,43 @@ func TestProposalAndPolkaCurrent(t *testing.T) {
3232
assertState(t, stateMachine, types.Height(0), types.Round(0), types.StepPrecommit)
3333
})
3434

35+
t.Run("Line 36: lock and broadcast precommit when step is precommit", func(t *testing.T) {
36+
stateMachine := setupStateMachine(t, 4, 3)
37+
currentRound := newTestRound(t, stateMachine, 0, 0)
38+
nextRound := newTestRound(t, stateMachine, 1, 0)
39+
40+
committedValue := value(42)
41+
42+
// Initialise the round
43+
currentRound.start()
44+
45+
// Proposal timeout
46+
currentRound.processTimeout(types.StepPropose).expectActions(
47+
currentRound.action().broadcastPrevote(nil),
48+
)
49+
50+
// Prevotes are collected
51+
currentRound.validator(1).prevote(&committedValue).expectActions()
52+
currentRound.validator(2).prevote(&committedValue).expectActions(
53+
currentRound.action().scheduleTimeout(types.StepPrevote),
54+
)
55+
currentRound.processTimeout(types.StepPrevote).expectActions(
56+
currentRound.action().broadcastPrecommit(nil),
57+
)
58+
currentRound.validator(0).prevote(&committedValue).expectActions()
59+
60+
// Receives precommits, this rule shouldn't block the commit value rule
61+
currentRound.validator(1).precommit(&committedValue)
62+
currentRound.validator(2).precommit(&committedValue)
63+
currentRound.validator(0).precommit(&committedValue)
64+
currentRound.validator(0).proposal(committedValue, -1).expectActions(
65+
currentRound.action().commit(committedValue, -1, 0),
66+
nextRound.action().scheduleTimeout(types.StepPropose),
67+
)
68+
69+
assertState(t, stateMachine, types.Height(1), types.Round(0), types.StepPropose)
70+
})
71+
3572
t.Run("Line 36: record valid value even if we don't prevote it", func(t *testing.T) {
3673
stateMachine := setupStateMachine(t, 4, 1)
3774
currentRound := newTestRound(t, stateMachine, 0, 0)

0 commit comments

Comments
 (0)