tests: remove panics from test fixtures (#7522)

This commit is contained in:
Sam Kleinman
2022-01-06 17:34:32 -05:00
committed by GitHub
parent a91d3cb894
commit 569629486b
27 changed files with 815 additions and 858 deletions
+7 -6
View File
@@ -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 {