Skip to content

Commit 074cc8a

Browse files
committed
Refactored consensus decider access and improved thread safety.
1 parent 6082a58 commit 074cc8a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

consensus/view_change_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ func TestGetNextLeaderKeyShouldFailForStandardGeneratedConsensus(t *testing.T) {
8686

8787
// The below results in: "panic: runtime error: integer divide by zero"
8888
// This happens because there's no check for if there are any participants or not in https://github.com/harmony-one/harmony/blob/main/consensus/quorum/quorum.go#L188-L197
89-
assert.Panics(t, func() { consensus.current.getNextLeaderKey(consensus.Blockchain(), consensus.decider, uint64(1), nil) })
89+
assert.Panics(t, func() {
90+
consensus.current.getNextLeaderKey(consensus.Blockchain(), consensus.decider(), uint64(1), nil)
91+
})
9092
}
9193

9294
func TestGetNextLeaderKeyShouldSucceed(t *testing.T) {
@@ -114,7 +116,7 @@ func TestGetNextLeaderKeyShouldSucceed(t *testing.T) {
114116
assert.Equal(t, keyCount, consensus.Decider().ParticipantsCount())
115117

116118
consensus.setLeaderPubKey(&wrappedBLSKeys[0])
117-
nextKey := consensus.current.getNextLeaderKey(consensus.Blockchain(), consensus.decider, uint64(1), nil)
119+
nextKey := consensus.current.getNextLeaderKey(consensus.Blockchain(), consensus.decider(), uint64(1), nil)
118120

119121
assert.Equal(t, nextKey, &wrappedBLSKeys[1])
120122
}

0 commit comments

Comments
 (0)