2020-06-23 16:46:48 +00:00
|
|
|
package testing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-03-17 18:52:56 +00:00
|
|
|
eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
2020-06-23 16:46:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// MockProtector mocks the protector.
|
|
|
|
type MockProtector struct {
|
|
|
|
AllowAttestation bool
|
|
|
|
AllowBlock bool
|
|
|
|
VerifyAttestationCalled bool
|
|
|
|
VerifyBlockCalled 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 {
|
2021-12-07 17:52:39 +00:00
|
|
|
mp.VerifyAttestationCalled = true // skipcq: RVV-B0006
|
2020-06-23 16:46:48 +00:00
|
|
|
return mp.AllowAttestation
|
|
|
|
}
|
|
|
|
|
2020-07-03 19:54:42 +00:00
|
|
|
// CheckBlockSafety returns bool with allow block value.
|
2021-09-29 18:17:37 +00:00
|
|
|
func (mp MockProtector) CheckBlockSafety(_ context.Context, _ *eth.SignedBeaconBlockHeader) bool {
|
2021-12-07 17:52:39 +00:00
|
|
|
mp.VerifyBlockCalled = true // skipcq: RVV-B0006
|
2020-06-23 16:46:48 +00:00
|
|
|
return mp.AllowBlock
|
|
|
|
}
|
|
|
|
|
2020-07-27 20:06:49 +00:00
|
|
|
// Status returns nil.
|
|
|
|
func (mp MockProtector) Status() error {
|
2021-12-07 17:52:39 +00:00
|
|
|
mp.StatusCalled = true // skipcq: RVV-B0006
|
2020-07-27 20:06:49 +00:00
|
|
|
return nil
|
|
|
|
}
|