2020-06-23 16:46:48 +00:00
|
|
|
package testing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
|
|
)
|
|
|
|
|
|
|
|
// MockProtector mocks the protector.
|
|
|
|
type MockProtector struct {
|
|
|
|
AllowAttestation bool
|
|
|
|
AllowBlock bool
|
|
|
|
VerifyAttestationCalled bool
|
|
|
|
CommitAttestationCalled bool
|
|
|
|
VerifyBlockCalled bool
|
|
|
|
CommitBlockCalled bool
|
2020-07-27 20:06:49 +00:00
|
|
|
StatusCalled bool
|
2020-06-23 16:46:48 +00:00
|
|
|
}
|
|
|
|
|
2020-07-03 19:54:42 +00:00
|
|
|
// CheckAttestationSafety returns bool with allow attestation value.
|
2020-10-12 08:11:05 +00:00
|
|
|
func (mp MockProtector) CheckAttestationSafety(_ context.Context, _ *eth.IndexedAttestation) bool {
|
2020-06-23 16:46:48 +00:00
|
|
|
mp.VerifyAttestationCalled = true
|
|
|
|
return mp.AllowAttestation
|
|
|
|
}
|
|
|
|
|
|
|
|
// CommitAttestation returns bool with allow attestation value.
|
2020-10-12 08:11:05 +00:00
|
|
|
func (mp MockProtector) CommitAttestation(_ context.Context, _ *eth.IndexedAttestation) bool {
|
2020-06-23 16:46:48 +00:00
|
|
|
mp.CommitAttestationCalled = true
|
|
|
|
return mp.AllowAttestation
|
|
|
|
}
|
|
|
|
|
2020-07-03 19:54:42 +00:00
|
|
|
// CheckBlockSafety returns bool with allow block value.
|
2020-10-12 08:11:05 +00:00
|
|
|
func (mp MockProtector) CheckBlockSafety(_ context.Context, _ *eth.BeaconBlockHeader) bool {
|
2020-06-23 16:46:48 +00:00
|
|
|
mp.VerifyBlockCalled = true
|
|
|
|
return mp.AllowBlock
|
|
|
|
}
|
|
|
|
|
|
|
|
// CommitBlock returns bool with allow block value.
|
2020-10-12 08:11:05 +00:00
|
|
|
func (mp MockProtector) CommitBlock(_ context.Context, _ *eth.SignedBeaconBlockHeader) (bool, error) {
|
2020-06-23 16:46:48 +00:00
|
|
|
mp.CommitBlockCalled = true
|
2020-09-11 14:53:53 +00:00
|
|
|
return mp.AllowBlock, nil
|
2020-06-23 16:46:48 +00:00
|
|
|
}
|
2020-07-27 20:06:49 +00:00
|
|
|
|
|
|
|
// Status returns nil.
|
|
|
|
func (mp MockProtector) Status() error {
|
|
|
|
mp.StatusCalled = true
|
|
|
|
return nil
|
|
|
|
}
|