prysm-pulse/beacon-chain/state/helpers_test.go
Raul Jordan b1c047b9ee
Prevent Panics in Field Trie Helpers (#7613)
* add tests to prevent panics

* if > 0

* fix typ
2020-10-23 21:41:45 +00:00

31 lines
1010 B
Go

package state
import (
"testing"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
)
func Test_handleValidatorSlice_OutOfRange(t *testing.T) {
vals := make([]*ethpb.Validator, 1)
indices := []uint64{3}
_, err := handleValidatorSlice(vals, indices, false)
assert.ErrorContains(t, "index 3 greater than number of validators 1", err)
}
func Test_handlePendingAttestation_OutOfRange(t *testing.T) {
items := make([]*pb.PendingAttestation, 1)
indices := []uint64{3}
_, err := handlePendingAttestation(items, indices, false)
assert.ErrorContains(t, "index 3 greater than number of pending attestations 1", err)
}
func Test_handleEth1DataSlice_OutOfRange(t *testing.T) {
items := make([]*ethpb.Eth1Data, 1)
indices := []uint64{3}
_, err := handleEth1DataSlice(items, indices, false)
assert.ErrorContains(t, "index 3 greater than number of items in eth1 data slice 1", err)
}