mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 03:01:19 +00:00
d17996f8b0
* Update V3 from V4 * Fix build v3 -> v4 * Update ssz * Update beacon_chain.pb.go * Fix formatter import * Update update-mockgen.sh comment to v4 * Fix conflicts. Pass build and tests * Fix test
55 lines
1.7 KiB
Go
55 lines
1.7 KiB
Go
package slasher
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/slasher/mock"
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
|
)
|
|
|
|
func TestServer_IsSlashableAttestation_SlashingFound(t *testing.T) {
|
|
mockSlasher := &mock.MockSlashingChecker{
|
|
AttesterSlashingFound: true,
|
|
}
|
|
s := Server{SlashingChecker: mockSlasher}
|
|
ctx := context.Background()
|
|
slashing, err := s.IsSlashableAttestation(ctx, ðpb.IndexedAttestation{})
|
|
require.NoError(t, err)
|
|
require.Equal(t, true, len(slashing.AttesterSlashings) > 0)
|
|
}
|
|
|
|
func TestServer_IsSlashableAttestation_SlashingNotFound(t *testing.T) {
|
|
mockSlasher := &mock.MockSlashingChecker{
|
|
AttesterSlashingFound: false,
|
|
}
|
|
s := Server{SlashingChecker: mockSlasher}
|
|
ctx := context.Background()
|
|
slashing, err := s.IsSlashableAttestation(ctx, ðpb.IndexedAttestation{})
|
|
require.NoError(t, err)
|
|
require.Equal(t, true, len(slashing.AttesterSlashings) == 0)
|
|
}
|
|
|
|
func TestServer_IsSlashableBlock_SlashingFound(t *testing.T) {
|
|
mockSlasher := &mock.MockSlashingChecker{
|
|
ProposerSlashingFound: true,
|
|
}
|
|
s := Server{SlashingChecker: mockSlasher}
|
|
ctx := context.Background()
|
|
slashing, err := s.IsSlashableBlock(ctx, ðpb.SignedBeaconBlockHeader{})
|
|
require.NoError(t, err)
|
|
require.Equal(t, true, len(slashing.ProposerSlashings) > 0)
|
|
}
|
|
|
|
func TestServer_IsSlashableBlock_SlashingNotFound(t *testing.T) {
|
|
mockSlasher := &mock.MockSlashingChecker{
|
|
ProposerSlashingFound: false,
|
|
}
|
|
s := Server{SlashingChecker: mockSlasher}
|
|
ctx := context.Background()
|
|
slashing, err := s.IsSlashableBlock(ctx, ðpb.SignedBeaconBlockHeader{})
|
|
require.NoError(t, err)
|
|
require.Equal(t, true, len(slashing.ProposerSlashings) == 0)
|
|
}
|