|
|
@ -31,6 +31,37 @@ func TestNoProgressUntilTxsAvailable(t *testing.T) { |
|
|
|
ensureNewStep(newBlockCh) // commit txs
|
|
|
|
ensureNewStep(newBlockCh) // commit updated app hash
|
|
|
|
ensureNoNewStep(newBlockCh) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func TestProgressInHigherRound(t *testing.T) { |
|
|
|
config := ResetConfig("consensus_mempool_txs_available_test") |
|
|
|
config.Consensus.NoEmptyBlocks = true |
|
|
|
state, privVals := randGenesisState(1, false, 10) |
|
|
|
cs := newConsensusStateWithConfig(config, state, privVals[0], NewCounterApplication()) |
|
|
|
cs.mempool.EnableTxsAvailable() |
|
|
|
height, round := cs.Height, cs.Round |
|
|
|
newBlockCh := subscribeToEvent(cs.evsw, "tester", types.EventStringNewBlock(), 1) |
|
|
|
newRoundCh := subscribeToEvent(cs.evsw, "tester", types.EventStringNewRound(), 1) |
|
|
|
timeoutCh := subscribeToEvent(cs.evsw, "tester", types.EventStringTimeoutPropose(), 1) |
|
|
|
cs.setProposal = func(proposal *types.Proposal) error { |
|
|
|
if cs.Height == 2 && cs.Round == 0 { |
|
|
|
// dont set the proposal in round 0 so we timeout and
|
|
|
|
// go to next round
|
|
|
|
cs.Logger.Info("Ignoring set proposal at height 2, round 0") |
|
|
|
return nil |
|
|
|
} |
|
|
|
return cs.defaultSetProposal(proposal) |
|
|
|
} |
|
|
|
startTestRound(cs, height, round) |
|
|
|
|
|
|
|
ensureNewStep(newRoundCh) // first round at first height
|
|
|
|
ensureNewStep(newBlockCh) // first block gets committed
|
|
|
|
ensureNewStep(newRoundCh) // first round at next height
|
|
|
|
deliverTxsRange(cs, 0, 2) // we deliver txs, but dont set a proposal so we get the next round
|
|
|
|
<-timeoutCh |
|
|
|
ensureNewStep(newRoundCh) // wait for the next round
|
|
|
|
ensureNewStep(newBlockCh) // now we can commit the block
|
|
|
|
} |
|
|
|
|
|
|
|
func deliverTxsRange(cs *ConsensusState, start, end int) { |
|
|
|