@@ -61,20 +61,20 @@ func TestEpochLeaderFailover(t *testing.T) {
6161 // Then, don't do anything and wait for our node
6262 // to start complaining about a block not being notarized
6363
64- for _, round := range [] uint64{0, 1, 2} {
64+ for round := uint64(0); round < 3; round++ {
6565 notarizeAndFinalizeRound(t, nodes, round, round, e, bb, quorum, storage, false)
6666 }
6767
6868 bb.blockShouldBeBuilt <- struct{}{}
6969
7070 waitForEvent(t, start, e, timeoutDetected)
71-
71+
7272 lastBlock, _, ok := storage.Retrieve(storage.Height() - 1)
7373 require.True(t, ok)
7474
7575 prev := lastBlock.BlockHeader().Digest
7676
77- md := ProtocolMetadata{
77+ emptyBlockMd := ProtocolMetadata{
7878 Round: 3,
7979 Seq: 2,
8080 Prev: prev,
@@ -83,8 +83,8 @@ func TestEpochLeaderFailover(t *testing.T) {
8383 nextBlockSeqToCommit := uint64(3)
8484 nextRoundToCommit := uint64(4)
8585
86- emptyVoteFrom1 := createEmptyVote(md , nodes[1])
87- emptyVoteFrom2 := createEmptyVote(md , nodes[2])
86+ emptyVoteFrom1 := createEmptyVote(emptyBlockMd , nodes[1])
87+ emptyVoteFrom2 := createEmptyVote(emptyBlockMd , nodes[2])
8888
8989 e.HandleMessage(&Message{
9090 EmptyVoteMessage: emptyVoteFrom1,
@@ -93,25 +93,25 @@ func TestEpochLeaderFailover(t *testing.T) {
9393 EmptyVoteMessage: emptyVoteFrom2,
9494 }, nodes[2])
9595
96- // Ensure our node proposes block with sequence 3 for round 4
97- notarizeAndFinalizeRound(t, nodes, nextRoundToCommit, nextBlockSeqToCommit, e, bb, quorum, storage, false)
98-
99- // WAL must contain an empty vote and an empty block.
96+ wal.lock.Lock()
10097 walContent, err := wal.ReadAll()
10198 require.NoError(t, err)
102-
103- // WAL should be: [..., <empty vote>, <empty block>, <notarization for 4>, <block3>]
104- rawEmptyVote, rawEmptyNotarization := walContent[len(walContent)-4], walContent[len(walContent)-3]
105-
99+ wal.lock.Unlock()
100+
101+ rawEmptyVote, rawEmptyNotarization := walContent[len(walContent)-2], walContent[len(walContent)-1]
106102 emptyVote, err := ParseEmptyVoteRecord(rawEmptyVote)
107103 require.NoError(t, err)
108- require.Equal(t, createEmptyVote(md , nodes[0]).Vote, emptyVote)
104+ require.Equal(t, createEmptyVote(emptyBlockMd , nodes[0]).Vote, emptyVote)
109105
110106 emptyNotarization, err := EmptyNotarizationFromRecord(rawEmptyNotarization, &testQCDeserializer{t: t})
111107 require.NoError(t, err)
112108 require.Equal(t, emptyVoteFrom1.Vote, emptyNotarization.Vote)
113109 require.Equal(t, uint64(3), emptyNotarization.Vote.Round)
114110 require.Equal(t, uint64(2), emptyNotarization.Vote.Seq)
111+ require.Equal(t, uint64(3), storage.Height())
112+
113+ // Ensure our node proposes block with sequence 3 for round 4
114+ notarizeAndFinalizeRound(t, nodes, nextRoundToCommit, nextBlockSeqToCommit, e, bb, quorum, storage, false)
115115 require.Equal(t, uint64(4), storage.Height())
116116}
117117
0 commit comments