瀏覽代碼

raft: remove unnecessary type conversion

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 年之前
父節點
當前提交
0249c39cb3
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 2 2
      raft/log_test.go
  2. 2 2
      raft/raft_test.go

+ 2 - 2
raft/log_test.go

@@ -282,11 +282,11 @@ func TestCompactionSideEffects(t *testing.T) {
 	lastTerm := lastIndex
 	storage := NewMemoryStorage()
 	for i = 1; i <= unstableIndex; i++ {
-		storage.Append([]pb.Entry{{Term: uint64(i), Index: uint64(i)}})
+		storage.Append([]pb.Entry{{Term: i, Index: i}})
 	}
 	raftLog := newLog(storage, raftLogger)
 	for i = unstableIndex; i < lastIndex; i++ {
-		raftLog.append(pb.Entry{Term: uint64(i + 1), Index: uint64(i + 1)})
+		raftLog.append(pb.Entry{Term: i + 1, Index: i + 1})
 	}
 
 	ok := raftLog.maybeCommit(lastIndex, lastTerm)

+ 2 - 2
raft/raft_test.go

@@ -303,7 +303,7 @@ func TestLeaderElectionPreVote(t *testing.T) {
 
 func testLeaderElection(t *testing.T, preVote bool) {
 	var cfg func(*Config)
-	candState := StateType(StateCandidate)
+	candState := StateCandidate
 	candTerm := uint64(1)
 	if preVote {
 		cfg = preVoteConfig
@@ -1675,7 +1675,7 @@ func TestAllServerStepdown(t *testing.T) {
 			if sm.Term != tt.wterm {
 				t.Errorf("#%d.%d term = %v , want %v", i, j, sm.Term, tt.wterm)
 			}
-			if uint64(sm.raftLog.lastIndex()) != tt.windex {
+			if sm.raftLog.lastIndex() != tt.windex {
 				t.Errorf("#%d.%d index = %v , want %v", i, j, sm.raftLog.lastIndex(), tt.windex)
 			}
 			if uint64(len(sm.raftLog.allEntries())) != tt.windex {