Skip to content

Commit

Permalink
fix test to use Leader() to avoid race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
k-jingyang committed Aug 21, 2024
1 parent ccb2857 commit e2ac806
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3240,7 +3240,7 @@ func TestRaft_PreVote_ShouldNotRejectLeader(t *testing.T) {

// A follower who thinks that x is the leader should not reject x's pre-vote
follower := followers[0]
require.Equal(t, leader.localAddr, follower.leaderAddr)
require.Equal(t, leader.localAddr, follower.Leader())

reqPreVote := RequestPreVoteRequest{
RPCHeader: leader.getRPCHeader(),
Expand Down Expand Up @@ -3282,7 +3282,7 @@ func TestRaft_PreVote_ShouldRejectNonLeader(t *testing.T) {
// A follower who thinks that x is the leader should reject another node's pre-vote request
follower := followers[0]
anotherFollower := followers[1]
require.NotEqual(t, anotherFollower, follower.leaderAddr)
require.NotEqual(t, anotherFollower.localAddr, follower.Leader())

reqPreVote := RequestPreVoteRequest{
RPCHeader: anotherFollower.getRPCHeader(),
Expand Down

0 comments on commit e2ac806

Please sign in to comment.