Skip to content

Commit 479fed1

Browse files
committed
chore: remove test and propagate panic
1 parent 2c6b5c5 commit 479fed1

File tree

2 files changed

+1
-121
lines changed

2 files changed

+1
-121
lines changed

consensus/reactor_test.go

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -316,126 +316,6 @@ func TestReactorReceivePanicsIfInitPeerHasntBeenCalledYet(t *testing.T) {
316316
})
317317
}
318318

319-
// TestSwitchToConsensusVoteExtensions tests that the SwitchToConsensus correctly
320-
// checks for vote extension data when required.
321-
func TestSwitchToConsensusVoteExtensions(t *testing.T) {
322-
for _, testCase := range []struct {
323-
name string
324-
storedHeight int64
325-
initialRequiredHeight int64
326-
includeExtensions bool
327-
shouldPanic bool
328-
}{
329-
{
330-
name: "no vote extensions but not required",
331-
initialRequiredHeight: 0,
332-
storedHeight: 2,
333-
includeExtensions: false,
334-
shouldPanic: false,
335-
},
336-
{
337-
name: "no vote extensions but required this height",
338-
initialRequiredHeight: 2,
339-
storedHeight: 2,
340-
includeExtensions: false,
341-
shouldPanic: true,
342-
},
343-
{
344-
name: "no vote extensions and required in future",
345-
initialRequiredHeight: 3,
346-
storedHeight: 2,
347-
includeExtensions: false,
348-
shouldPanic: false,
349-
},
350-
{
351-
name: "no vote extensions and required previous height",
352-
initialRequiredHeight: 1,
353-
storedHeight: 2,
354-
includeExtensions: false,
355-
shouldPanic: true,
356-
},
357-
{
358-
name: "vote extensions and required previous height",
359-
initialRequiredHeight: 1,
360-
storedHeight: 2,
361-
includeExtensions: true,
362-
shouldPanic: false,
363-
},
364-
} {
365-
t.Run(testCase.name, func(t *testing.T) {
366-
ctx, cancel := context.WithCancel(context.Background())
367-
defer cancel()
368-
369-
cs, vs := randState(1)
370-
validator := vs[0]
371-
validator.Height = testCase.storedHeight
372-
373-
cs.state.LastBlockHeight = testCase.storedHeight
374-
cs.state.LastValidators = cs.state.Validators.Copy()
375-
cs.state.ConsensusParams.ABCI.VoteExtensionsEnableHeight = testCase.initialRequiredHeight
376-
377-
propBlock, blockParts, err := cs.createProposalBlock(ctx)
378-
require.NoError(t, err)
379-
380-
// Consensus is preparing to do the next height after the stored height.
381-
cs.rs.Height = testCase.storedHeight + 1
382-
propBlock.Height = testCase.storedHeight
383-
384-
var voteSet *types.VoteSet
385-
if testCase.includeExtensions {
386-
voteSet = types.NewExtendedVoteSet(cs.state.ChainID, testCase.storedHeight, 0, cmtproto.PrecommitType, cs.state.Validators)
387-
} else {
388-
voteSet = types.NewVoteSet(cs.state.ChainID, testCase.storedHeight, 0, cmtproto.PrecommitType, cs.state.Validators)
389-
}
390-
signedVote := signVote(validator, cmtproto.PrecommitType, propBlock.Hash(), blockParts.Header(), testCase.includeExtensions)
391-
392-
var veHeight int64
393-
if testCase.includeExtensions {
394-
require.NotNil(t, signedVote.ExtensionSignature)
395-
veHeight = testCase.storedHeight
396-
} else {
397-
require.Nil(t, signedVote.Extension)
398-
require.Nil(t, signedVote.ExtensionSignature)
399-
}
400-
401-
added, err := voteSet.AddVote(signedVote)
402-
require.NoError(t, err)
403-
require.True(t, added)
404-
405-
veHeightParam := types.ABCIParams{VoteExtensionsEnableHeight: veHeight}
406-
if testCase.includeExtensions {
407-
cs.blockStore.SaveBlockWithExtendedCommit(propBlock, blockParts, voteSet.MakeExtendedCommit(veHeightParam))
408-
} else {
409-
cs.blockStore.SaveBlock(propBlock, blockParts, voteSet.MakeExtendedCommit(veHeightParam).ToCommit())
410-
}
411-
blockDB := dbm.NewMemDB()
412-
blockStore := store.NewBlockStore(blockDB)
413-
key, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile())
414-
require.NoError(t, err)
415-
propagator := propagation.NewReactor(key.ID(), propagation.Config{
416-
Store: blockStore,
417-
Mempool: &emptyMempool{},
418-
Privval: cs.privValidator,
419-
ChainID: cs.state.ChainID,
420-
BlockMaxBytes: cs.state.ConsensusParams.Block.MaxBytes,
421-
})
422-
reactor := NewReactor(
423-
cs,
424-
propagator,
425-
true,
426-
)
427-
428-
if testCase.shouldPanic {
429-
assert.Panics(t, func() {
430-
reactor.SwitchToConsensus(cs.state, false)
431-
})
432-
} else {
433-
reactor.SwitchToConsensus(cs.state, false)
434-
}
435-
})
436-
}
437-
}
438-
439319
// Test we record stats about votes and block parts from other peers.
440320
func TestReactorRecordsVotesAndBlockParts(t *testing.T) {
441321
N := 4

consensus/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ func (cs *State) receiveRoutine(maxSteps int) {
927927
// some console or secure RPC system, but for now, halting the chain upon
928928
// unexpected consensus bugs sounds like the better option.
929929
onExit(cs)
930-
os.Exit(1)
930+
panic(r)
931931
}
932932
}()
933933

0 commit comments

Comments
 (0)