mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-20 22:26:15 +00:00
tests: remove panics from test fixtures (#7522)
This commit is contained in:
@@ -37,7 +37,7 @@ func TestValidator_Sets(t *testing.T) {
|
||||
}
|
||||
|
||||
valSchedule := newValidatorSchedule(*node.Testnet)
|
||||
valSchedule.Increment(first - node.Testnet.InitialHeight)
|
||||
require.NoError(t, valSchedule.Increment(first-node.Testnet.InitialHeight))
|
||||
|
||||
for h := first; h <= last; h++ {
|
||||
validators := []*types.Validator{}
|
||||
@@ -52,7 +52,7 @@ func TestValidator_Sets(t *testing.T) {
|
||||
}
|
||||
require.Equal(t, valSchedule.Set.Validators, validators,
|
||||
"incorrect validator set at height %v", h)
|
||||
valSchedule.Increment(1)
|
||||
require.NoError(t, valSchedule.Increment(1))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func TestValidator_Propose(t *testing.T) {
|
||||
proposeCount++
|
||||
}
|
||||
}
|
||||
valSchedule.Increment(1)
|
||||
require.NoError(t, valSchedule.Increment(1))
|
||||
}
|
||||
|
||||
require.False(t, proposeCount == 0 && expectCount > 0,
|
||||
@@ -123,7 +123,7 @@ func TestValidator_Sign(t *testing.T) {
|
||||
} else {
|
||||
require.False(t, signed, "unexpected signature for block %v", block.LastCommit.Height)
|
||||
}
|
||||
valSchedule.Increment(1)
|
||||
require.NoError(t, valSchedule.Increment(1))
|
||||
}
|
||||
|
||||
require.False(t, signCount == 0 && expectCount > 0,
|
||||
@@ -154,7 +154,7 @@ func newValidatorSchedule(testnet e2e.Testnet) *validatorSchedule {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *validatorSchedule) Increment(heights int64) {
|
||||
func (s *validatorSchedule) Increment(heights int64) error {
|
||||
for i := int64(0); i < heights; i++ {
|
||||
s.height++
|
||||
if s.height > 2 {
|
||||
@@ -162,12 +162,13 @@ func (s *validatorSchedule) Increment(heights int64) {
|
||||
// two blocks after they're returned.
|
||||
if update, ok := s.updates[s.height-2]; ok {
|
||||
if err := s.Set.UpdateWithChangeSet(makeVals(update)); err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
s.Set.IncrementProposerPriority(1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeVals(valMap map[*e2e.Node]int64) []*types.Validator {
|
||||
|
||||
Reference in New Issue
Block a user