Handle nil network member in consensus for test
@@ -224,6 +224,7 @@ func (cs *consensus) _resetForNewHeight(prevBlock module.Block, votes *voteSet)
if cs.members == nil || !cs.members.Equal(nextMembers) {
cs.members = nextMembers
var peerIDs []module.PeerID
+ if nextMembers != nil {
for it := nextMembers.Iterator(); it.Has(); cs.log.Must(it.Next()) {
addr, _ := it.Get()
peerIDs = append(peerIDs, network.NewPeerIDFromAddress(addr))
@@ -231,6 +232,7 @@ func (cs *consensus) _resetForNewHeight(prevBlock module.Block, votes *voteSet)
cs.c.NetworkManager().SetRole(cs.height, module.ROLE_NORMAL, peerIDs...)
}
}
+ }
cs.minimizeBlockGen = cs.c.ServiceManager().GetMinimizeBlockGen(cs.lastBlock.Result())
cs.roundLimit = int32(cs.c.ServiceManager().GetRoundLimit(cs.lastBlock.Result(), cs.validators.Len()))
cs.sentPatch = false
