fix #171 let newRaft take care of peers and Prs (#172)

* let newRaft take care of peers and Prs
This commit is contained in:
Lin ZiHao 2020-05-14 13:24:12 +08:00 committed by GitHub
parent 38dfb05303
commit e01d729bd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,7 +118,9 @@ func TestLeaderCycle2AA(t *testing.T) {
// log entries, and must overwrite higher-term log entries with
// lower-term ones.
func TestLeaderElectionOverwriteNewerLogs2AB(t *testing.T) {
var cfg func(*Config)
cfg := func(c *Config) {
c.peers = idsBySize(5)
}
// This network represents the results of the following sequence of
// events:
// - Node 1 won the election in term 1.
@ -1594,10 +1596,6 @@ func newNetworkWithConfig(configFunc func(*Config), peers ...stateMachine) *netw
npeers[id] = sm
case *Raft:
v.id = id
v.Prs = make(map[uint64]*Progress)
for i := 0; i < size; i++ {
v.Prs[peerAddrs[i]] = &Progress{}
}
npeers[id] = v
case *blackHole:
npeers[id] = v