prysm-pulse/validator/testing/protector_mock.go

49 lines
1.4 KiB
Go
Raw Normal View History

External slashing protection not requiring signature (#6252) * validation without signature * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * validation and update funcs * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge branch 'master' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * change order error handling * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * ivan feedback * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * add tests to blocks utils * terence feedback * reduce visibility * Merge branch 'master' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign # Conflicts: # validator/client/polling/validator_attest.go # validator/client/polling/validator_propose.go * fix metrics * fix error * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * copy behaviour to streaming * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign
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
Make external slasher protection fail on load if slasher is not reachable (#6704) * external slasher protection fails loudly * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge branch 'master' of github.com:prysmaticlabs/prysm into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * ivan feedback * Merge branch 'external-slasher-fail-loud' of github.com:prysmaticlabs/prysm into external-slasher-fail-loud * lint fix * ivan feedback
2020-07-27 20:06:49 +00:00
StatusCalled bool
External slashing protection not requiring signature (#6252) * validation without signature * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * validation and update funcs * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge branch 'master' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * change order error handling * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * ivan feedback * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * add tests to blocks utils * terence feedback * reduce visibility * Merge branch 'master' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign # Conflicts: # validator/client/polling/validator_attest.go # validator/client/polling/validator_propose.go * fix metrics * fix error * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * copy behaviour to streaming * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign
2020-06-23 16:46:48 +00:00
}
// CheckAttestationSafety returns bool with allow attestation value.
func (mp MockProtector) CheckAttestationSafety(ctx context.Context, attestation *eth.IndexedAttestation) bool {
External slashing protection not requiring signature (#6252) * validation without signature * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * validation and update funcs * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge branch 'master' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * change order error handling * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * ivan feedback * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * add tests to blocks utils * terence feedback * reduce visibility * Merge branch 'master' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign # Conflicts: # validator/client/polling/validator_attest.go # validator/client/polling/validator_propose.go * fix metrics * fix error * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * copy behaviour to streaming * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign
2020-06-23 16:46:48 +00:00
mp.VerifyAttestationCalled = true
return mp.AllowAttestation
}
// CommitAttestation returns bool with allow attestation value.
func (mp MockProtector) CommitAttestation(ctx context.Context, attestation *eth.IndexedAttestation) bool {
mp.CommitAttestationCalled = true
return mp.AllowAttestation
}
// CheckBlockSafety returns bool with allow block value.
func (mp MockProtector) CheckBlockSafety(ctx context.Context, blockHeader *eth.BeaconBlockHeader) bool {
External slashing protection not requiring signature (#6252) * validation without signature * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * validation and update funcs * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge branch 'master' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * change order error handling * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * ivan feedback * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * add tests to blocks utils * terence feedback * reduce visibility * Merge branch 'master' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign # Conflicts: # validator/client/polling/validator_attest.go # validator/client/polling/validator_propose.go * fix metrics * fix error * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * copy behaviour to streaming * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign
2020-06-23 16:46:48 +00:00
mp.VerifyBlockCalled = true
return mp.AllowBlock
}
// CommitBlock returns bool with allow block value.
func (mp MockProtector) CommitBlock(ctx context.Context, blockHeader *eth.SignedBeaconBlockHeader) bool {
mp.CommitBlockCalled = true
return mp.AllowBlock
}
Make external slasher protection fail on load if slasher is not reachable (#6704) * external slasher protection fails loudly * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge branch 'master' of github.com:prysmaticlabs/prysm into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * Merge refs/heads/master into external-slasher-fail-loud * ivan feedback * Merge branch 'external-slasher-fail-loud' of github.com:prysmaticlabs/prysm into external-slasher-fail-loud * lint fix * ivan feedback
2020-07-27 20:06:49 +00:00
// Status returns nil.
func (mp MockProtector) Status() error {
mp.StatusCalled = true
return nil
}