mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
|
package slasher
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/prysmaticlabs/prysm/config/params"
|
||
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||
|
)
|
||
|
|
||
|
type MockSlashingChecker struct {
|
||
|
AttesterSlashingFound bool
|
||
|
ProposerSlashingFound bool
|
||
|
}
|
||
|
|
||
|
func (s *MockSlashingChecker) IsSlashableBlock(ctx context.Context, proposal *ethpb.SignedBeaconBlockHeader) (*ethpb.ProposerSlashing, error) {
|
||
|
if s.ProposerSlashingFound {
|
||
|
return ðpb.ProposerSlashing{
|
||
|
Header_1: ðpb.SignedBeaconBlockHeader{
|
||
|
Header: ðpb.BeaconBlockHeader{
|
||
|
Slot: 0,
|
||
|
ProposerIndex: 0,
|
||
|
ParentRoot: params.BeaconConfig().ZeroHash[:],
|
||
|
StateRoot: params.BeaconConfig().ZeroHash[:],
|
||
|
BodyRoot: params.BeaconConfig().ZeroHash[:],
|
||
|
},
|
||
|
Signature: params.BeaconConfig().EmptySignature[:],
|
||
|
},
|
||
|
Header_2: ðpb.SignedBeaconBlockHeader{
|
||
|
Header: ðpb.BeaconBlockHeader{
|
||
|
Slot: 0,
|
||
|
ProposerIndex: 0,
|
||
|
ParentRoot: params.BeaconConfig().ZeroHash[:],
|
||
|
StateRoot: params.BeaconConfig().ZeroHash[:],
|
||
|
BodyRoot: params.BeaconConfig().ZeroHash[:],
|
||
|
},
|
||
|
Signature: params.BeaconConfig().EmptySignature[:],
|
||
|
},
|
||
|
}, nil
|
||
|
}
|
||
|
return nil, nil
|
||
|
}
|
||
|
|
||
|
func (s *MockSlashingChecker) IsSlashableAttestation(ctx context.Context, attestation *ethpb.IndexedAttestation) ([]*ethpb.AttesterSlashing, error) {
|
||
|
if s.AttesterSlashingFound {
|
||
|
return []*ethpb.AttesterSlashing{
|
||
|
{
|
||
|
Attestation_1: ðpb.IndexedAttestation{
|
||
|
Data: ðpb.AttestationData{},
|
||
|
},
|
||
|
Attestation_2: ðpb.IndexedAttestation{
|
||
|
Data: ðpb.AttestationData{},
|
||
|
},
|
||
|
},
|
||
|
}, nil
|
||
|
}
|
||
|
return nil, nil
|
||
|
}
|