mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
42 lines
1.5 KiB
Go
42 lines
1.5 KiB
Go
package blockchain
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
eth "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
|
)
|
|
|
|
func TestReportEpochMetrics_BadHeadState(t *testing.T) {
|
|
s, err := util.NewBeaconState()
|
|
require.NoError(t, err)
|
|
h, err := util.NewBeaconState()
|
|
require.NoError(t, err)
|
|
require.NoError(t, h.SetValidators(nil))
|
|
err = reportEpochMetrics(context.Background(), s, h)
|
|
require.ErrorContains(t, "failed to initialize precompute: nil validators in state", err)
|
|
}
|
|
|
|
func TestReportEpochMetrics_BadAttestation(t *testing.T) {
|
|
s, err := util.NewBeaconState()
|
|
require.NoError(t, err)
|
|
h, err := util.NewBeaconState()
|
|
require.NoError(t, err)
|
|
require.NoError(t, h.AppendCurrentEpochAttestations(ð.PendingAttestation{InclusionDelay: 0}))
|
|
err = reportEpochMetrics(context.Background(), s, h)
|
|
require.ErrorContains(t, "attestation with inclusion delay of 0", err)
|
|
}
|
|
|
|
func TestReportEpochMetrics_SlashedValidatorOutOfBound(t *testing.T) {
|
|
h, _ := util.DeterministicGenesisState(t, 1)
|
|
v, err := h.ValidatorAtIndex(0)
|
|
require.NoError(t, err)
|
|
v.Slashed = true
|
|
require.NoError(t, h.UpdateValidatorAtIndex(0, v))
|
|
require.NoError(t, h.AppendCurrentEpochAttestations(ð.PendingAttestation{InclusionDelay: 1, Data: util.HydrateAttestationData(ð.AttestationData{})}))
|
|
err = reportEpochMetrics(context.Background(), h, h)
|
|
require.ErrorContains(t, "slot 0 out of bounds", err)
|
|
}
|