github.com/prysmaticlabs/prysm@v1.4.4/validator/testing/mock_protector.go (about)

     1  package testing
     2  
     3  import (
     4  	"context"
     5  
     6  	eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
     7  )
     8  
     9  // MockProtector mocks the protector.
    10  type MockProtector struct {
    11  	AllowAttestation        bool
    12  	AllowBlock              bool
    13  	VerifyAttestationCalled bool
    14  	CommitAttestationCalled bool
    15  	VerifyBlockCalled       bool
    16  	CommitBlockCalled       bool
    17  	StatusCalled            bool
    18  }
    19  
    20  // CheckAttestationSafety returns bool with allow attestation value.
    21  func (mp MockProtector) CheckAttestationSafety(_ context.Context, _ *eth.IndexedAttestation) bool {
    22  	mp.VerifyAttestationCalled = true
    23  	return mp.AllowAttestation
    24  }
    25  
    26  // CommitAttestation returns bool with allow attestation value.
    27  func (mp MockProtector) CommitAttestation(_ context.Context, _ *eth.IndexedAttestation) bool {
    28  	mp.CommitAttestationCalled = true
    29  	return mp.AllowAttestation
    30  }
    31  
    32  // CheckBlockSafety returns bool with allow block value.
    33  func (mp MockProtector) CheckBlockSafety(_ context.Context, _ *eth.BeaconBlockHeader) bool {
    34  	mp.VerifyBlockCalled = true
    35  	return mp.AllowBlock
    36  }
    37  
    38  // CommitBlock returns bool with allow block value.
    39  func (mp MockProtector) CommitBlock(_ context.Context, _ *eth.SignedBeaconBlockHeader) (bool, error) {
    40  	mp.CommitBlockCalled = true
    41  	return mp.AllowBlock, nil
    42  }
    43  
    44  // Status returns nil.
    45  func (mp MockProtector) Status() error {
    46  	mp.StatusCalled = true
    47  	return nil
    48  }