From b96d28a42bc67e4107a122e57c95c6144bfcf408 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Fri, 28 Jul 2017 23:39:10 -0400 Subject: [PATCH] test progress in higher round --- consensus/mempool_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/consensus/mempool_test.go b/consensus/mempool_test.go index 843a85aa6..fdb4349ad 100644 --- a/consensus/mempool_test.go +++ b/consensus/mempool_test.go @@ -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) {