Browse Source

raft: fix pre-vote tests

Dylan.Wen 9 years ago
parent
commit
920b155f17
1 changed files with 3 additions and 1 deletions
  1. 3 1
      raft/raft_test.go

+ 3 - 1
raft/raft_test.go

@@ -510,7 +510,7 @@ func testVoteFromAnyState(t *testing.T, vt pb.MessageType) {
 		// If this was a real vote, we reset our state and term.
 		// If this was a real vote, we reset our state and term.
 		if vt == pb.MsgVote {
 		if vt == pb.MsgVote {
 			if r.state != StateFollower {
 			if r.state != StateFollower {
-				t.Errorf("%s,%s: state %s, want %s", vt, StateFollower, r.state, st)
+				t.Errorf("%s,%s: state %s, want %s", vt, st, r.state, StateFollower)
 			}
 			}
 			if r.Term != newTerm {
 			if r.Term != newTerm {
 				t.Errorf("%s,%s: term %d, want %d", vt, st, r.Term, newTerm)
 				t.Errorf("%s,%s: term %d, want %d", vt, st, r.Term, newTerm)
@@ -1474,6 +1474,8 @@ func TestAllServerStepdown(t *testing.T) {
 		switch tt.state {
 		switch tt.state {
 		case StateFollower:
 		case StateFollower:
 			sm.becomeFollower(1, None)
 			sm.becomeFollower(1, None)
+		case StatePreCandidate:
+			sm.becomePreCandidate()
 		case StateCandidate:
 		case StateCandidate:
 			sm.becomeCandidate()
 			sm.becomeCandidate()
 		case StateLeader:
 		case StateLeader: