prysm-pulse/beacon-chain/rpc/prysm/v1alpha1/slasher/server_test.go
Raul Jordan df33ce3309
Remaining Slasher Beacon Node Changes (#9701)
* slasher beacon node changes

* remaining beacon node items

* moar changes

* gaz

* flag fix

* rem slashable

* builds

* imports

* fix up

* pruning faster test

* deepsource

* fix wrong item

* node node feature flags

* broken test

* preston review

* more preston comments

* comment

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2021-09-29 18:17:37 +00:00

55 lines
1.7 KiB
Go

package slasher
import (
"context"
"testing"
"github.com/prysmaticlabs/prysm/beacon-chain/slasher"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/testing/require"
)
func TestServer_IsSlashableAttestation_SlashingFound(t *testing.T) {
mockSlasher := &slasher.MockSlashingChecker{
AttesterSlashingFound: true,
}
s := Server{SlashingChecker: mockSlasher}
ctx := context.Background()
slashing, err := s.IsSlashableAttestation(ctx, &ethpb.IndexedAttestation{})
require.NoError(t, err)
require.Equal(t, true, len(slashing.AttesterSlashings) > 0)
}
func TestServer_IsSlashableAttestation_SlashingNotFound(t *testing.T) {
mockSlasher := &slasher.MockSlashingChecker{
AttesterSlashingFound: false,
}
s := Server{SlashingChecker: mockSlasher}
ctx := context.Background()
slashing, err := s.IsSlashableAttestation(ctx, &ethpb.IndexedAttestation{})
require.NoError(t, err)
require.Equal(t, true, len(slashing.AttesterSlashings) == 0)
}
func TestServer_IsSlashableBlock_SlashingFound(t *testing.T) {
mockSlasher := &slasher.MockSlashingChecker{
ProposerSlashingFound: true,
}
s := Server{SlashingChecker: mockSlasher}
ctx := context.Background()
slashing, err := s.IsSlashableBlock(ctx, &ethpb.SignedBeaconBlockHeader{})
require.NoError(t, err)
require.Equal(t, true, len(slashing.ProposerSlashings) > 0)
}
func TestServer_IsSlashableBlock_SlashingNotFound(t *testing.T) {
mockSlasher := &slasher.MockSlashingChecker{
ProposerSlashingFound: false,
}
s := Server{SlashingChecker: mockSlasher}
ctx := context.Background()
slashing, err := s.IsSlashableBlock(ctx, &ethpb.SignedBeaconBlockHeader{})
require.NoError(t, err)
require.Equal(t, true, len(slashing.ProposerSlashings) == 0)
}