Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suggest] TestRecvMessageType_MsgBeat2AA use becomeXXX instead of directly set state #357

Open
iefnaf opened this issue Dec 24, 2021 · 1 comment

Comments

@iefnaf
Copy link

iefnaf commented Dec 24, 2021

It is too rough to set the state directly, it is recommended to use becomeXXX

for i, tt := range tests {
  sm := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
  sm.RaftLog = newLog(newMemoryStorageWithEnts([]pb.Entry{{}, {Index: 1, Term: 0}, {Index: 2, Term: 1}}))
  sm.Term = 1
  sm.State = tt.state
  ...
}

suggest:

switch tt.state {
case StateFollower:
	sm.becomeFollower(1, None)
case StateCandidate:
	sm.becomeCandidate()
case StateLeader:
	sm.becomeCandidate()
	sm.becomeLeader()
}
sm.Term = 1
@Connor1996 Connor1996 assigned NingLin-P and unassigned NingLin-P Dec 27, 2021
@Connor1996
Copy link
Collaborator

PTAL @NingLin-P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants