fix tests: propose and full round suites

This commit is contained in:
Ethan Buchman
2015-12-12 01:28:53 -05:00
parent 736bc1f02f
commit 334cab82c2
2 changed files with 125 additions and 128 deletions

View File

@ -137,7 +137,7 @@ func addVoteToFromMany(to *ConsensusState, votes []*types.Vote, froms ...*valida
func addVoteToFrom(to *ConsensusState, from *validatorStub, vote *types.Vote) {
valIndex, _ := to.Validators.GetByAddress(from.PrivValidator.Address)
to.msgQueue <- msgInfo{msg: &VoteMessage{valIndex, vote}}
to.peerMsgQueue <- msgInfo{msg: &VoteMessage{valIndex, vote}}
// added, err := to.TryAddVote(valIndex, vote, "")
/*
if _, ok := err.(*types.ErrVoteConflictingSignature); ok {
@ -298,14 +298,20 @@ func simpleConsensusState(nValidators int) (*ConsensusState, []*validatorStub) {
cs := NewConsensusState(state, proxyAppCtxCon, blockStore, mempool)
cs.SetPrivValidator(privVals[0])
evsw := events.NewEventSwitch()
cs.SetFireable(evsw)
// read off the NewHeightStep from updateToState
// from the updateToState in NewConsensusState
<-cs.NewStepCh()
evsw := events.NewEventSwitch()
cs.SetFireable(evsw)
evsw.OnStart()
go func() {
for {
<-cs.NewStepCh()
}
}()
// start the transition routines
cs.startRoutines()
// cs.startRoutines()
for i := 0; i < nValidators; i++ {
vss[i] = NewValidatorStub(privVals[i])
@ -316,6 +322,16 @@ func simpleConsensusState(nValidators int) (*ConsensusState, []*validatorStub) {
return cs, vss
}
func subscribeToEvent(cs *ConsensusState, eventID string) chan interface{} {
evsw := cs.evsw.(*events.EventSwitch)
// listen for new round
ch := make(chan interface{}, 10)
evsw.AddListenerForEvent("tester", eventID, func(data types.EventData) {
ch <- data
})
return ch
}
func randGenesisState(numValidators int, randPower bool, minPower int64) (*sm.State, []*types.PrivValidator) {
db := dbm.NewMemDB()
genDoc, privValidators := randGenesisDoc(numValidators, randPower, minPower)
@ -343,3 +359,8 @@ func randGenesisDoc(numValidators int, randPower bool, minPower int64) (*types.G
}, privValidators
}
func startTestRound(cs *ConsensusState, height, round int) {
cs.EnterNewRound(height, round)
cs.startRoutines(0)
}