test: dont start cs until all peers connected

This commit is contained in:
Ethan Buchman
2016-12-19 19:50:40 -05:00
parent 6bc3b8dc6d
commit 706dd1d6c5

View File

@ -62,7 +62,7 @@ func TestValidatorSetChanges(t *testing.T) {
reactors := make([]*ConsensusReactor, nPeers)
eventChans := make([]chan interface{}, nPeers)
for i := 0; i < nPeers; i++ {
reactors[i] = NewConsensusReactor(css[i], false)
reactors[i] = NewConsensusReactor(css[i], true) // so we dont start the consensus states
eventSwitch := events.NewEventSwitch()
_, err := eventSwitch.Start()
@ -78,6 +78,14 @@ func TestValidatorSetChanges(t *testing.T) {
return s
}, p2p.Connect2Switches)
// now that everyone is connected, start the state machines
// (otherwise, we could block forever in firing new block while a peer is trying to
// access state info for AddPeer)
for i := 0; i < nPeers; i++ {
s := reactors[i].conS.GetState()
reactors[i].SwitchToConsensus(s)
}
// map of active validators
activeVals := make(map[string]struct{})
for i := 0; i < nVals; i++ {