From 738da2b3fa6fc12fa337d952e7ad010604e59e58 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 29 Oct 2014 14:57:39 -0700 Subject: [PATCH] raft: fix a incorrect in testMaybeAppend --- raft/log.go | 2 +- raft/log_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/raft/log.go b/raft/log.go index 94258a149..cb3e26e6d 100644 --- a/raft/log.go +++ b/raft/log.go @@ -50,7 +50,7 @@ func (l *raftLog) String() string { } // maybeAppend returns (0, false) if the entries cannot be appended. Otherwise, -// it returns (last index of entries, true). +// it returns (last index of new entries, true). func (l *raftLog) maybeAppend(index, logTerm, committed uint64, ents ...pb.Entry) (lastnewi uint64, ok bool) { lastnewi = index + uint64(len(ents)) if l.matchTerm(index, logTerm) { diff --git a/raft/log_test.go b/raft/log_test.go index 3aef2e1b3..46072f376 100644 --- a/raft/log_test.go +++ b/raft/log_test.go @@ -202,8 +202,8 @@ func TestLogMaybeAppend(t *testing.T) { lastindex, true, commit, false, // commit do not decrease }, { - lastterm - 3, lastindex - 3, lastindex, nil, - 1, true, commit, false, // commit do not decrease + 0, 0, lastindex, nil, + 0, true, commit, false, // commit do not decrease }, { lastterm, lastindex, lastindex, []pb.Entry{{Term: 4}},