diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index f7fac9e1ec..0ec86abeab 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -316,126 +316,6 @@ func TestReactorReceivePanicsIfInitPeerHasntBeenCalledYet(t *testing.T) { }) } -// TestSwitchToConsensusVoteExtensions tests that the SwitchToConsensus correctly -// checks for vote extension data when required. -func TestSwitchToConsensusVoteExtensions(t *testing.T) { - for _, testCase := range []struct { - name string - storedHeight int64 - initialRequiredHeight int64 - includeExtensions bool - shouldPanic bool - }{ - { - name: "no vote extensions but not required", - initialRequiredHeight: 0, - storedHeight: 2, - includeExtensions: false, - shouldPanic: false, - }, - { - name: "no vote extensions but required this height", - initialRequiredHeight: 2, - storedHeight: 2, - includeExtensions: false, - shouldPanic: true, - }, - { - name: "no vote extensions and required in future", - initialRequiredHeight: 3, - storedHeight: 2, - includeExtensions: false, - shouldPanic: false, - }, - { - name: "no vote extensions and required previous height", - initialRequiredHeight: 1, - storedHeight: 2, - includeExtensions: false, - shouldPanic: true, - }, - { - name: "vote extensions and required previous height", - initialRequiredHeight: 1, - storedHeight: 2, - includeExtensions: true, - shouldPanic: false, - }, - } { - t.Run(testCase.name, func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - cs, vs := randState(1) - validator := vs[0] - validator.Height = testCase.storedHeight - - cs.state.LastBlockHeight = testCase.storedHeight - cs.state.LastValidators = cs.state.Validators.Copy() - cs.state.ConsensusParams.ABCI.VoteExtensionsEnableHeight = testCase.initialRequiredHeight - - propBlock, blockParts, err := cs.createProposalBlock(ctx) - require.NoError(t, err) - - // Consensus is preparing to do the next height after the stored height. - cs.rs.Height = testCase.storedHeight + 1 - propBlock.Height = testCase.storedHeight - - var voteSet *types.VoteSet - if testCase.includeExtensions { - voteSet = types.NewExtendedVoteSet(cs.state.ChainID, testCase.storedHeight, 0, cmtproto.PrecommitType, cs.state.Validators) - } else { - voteSet = types.NewVoteSet(cs.state.ChainID, testCase.storedHeight, 0, cmtproto.PrecommitType, cs.state.Validators) - } - signedVote := signVote(validator, cmtproto.PrecommitType, propBlock.Hash(), blockParts.Header(), testCase.includeExtensions) - - var veHeight int64 - if testCase.includeExtensions { - require.NotNil(t, signedVote.ExtensionSignature) - veHeight = testCase.storedHeight - } else { - require.Nil(t, signedVote.Extension) - require.Nil(t, signedVote.ExtensionSignature) - } - - added, err := voteSet.AddVote(signedVote) - require.NoError(t, err) - require.True(t, added) - - veHeightParam := types.ABCIParams{VoteExtensionsEnableHeight: veHeight} - if testCase.includeExtensions { - cs.blockStore.SaveBlockWithExtendedCommit(propBlock, blockParts, voteSet.MakeExtendedCommit(veHeightParam)) - } else { - cs.blockStore.SaveBlock(propBlock, blockParts, voteSet.MakeExtendedCommit(veHeightParam).ToCommit()) - } - blockDB := dbm.NewMemDB() - blockStore := store.NewBlockStore(blockDB) - key, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile()) - require.NoError(t, err) - propagator := propagation.NewReactor(key.ID(), propagation.Config{ - Store: blockStore, - Mempool: &emptyMempool{}, - Privval: cs.privValidator, - ChainID: cs.state.ChainID, - BlockMaxBytes: cs.state.ConsensusParams.Block.MaxBytes, - }) - reactor := NewReactor( - cs, - propagator, - true, - ) - - if testCase.shouldPanic { - assert.Panics(t, func() { - reactor.SwitchToConsensus(cs.state, false) - }) - } else { - reactor.SwitchToConsensus(cs.state, false) - } - }) - } -} - // Test we record stats about votes and block parts from other peers. func TestReactorRecordsVotesAndBlockParts(t *testing.T) { N := 4 diff --git a/consensus/state.go b/consensus/state.go index 0f3bc2c2de..2f716165bb 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -927,6 +927,7 @@ func (cs *State) receiveRoutine(maxSteps int) { // some console or secure RPC system, but for now, halting the chain upon // unexpected consensus bugs sounds like the better option. onExit(cs) + panic(r) } }()