mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Verify interface compliance using typed nil instead of dereferencing and conversion (#7489)
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
8aaa5b6ad0
commit
d98a6dda8f
@ -18,9 +18,9 @@ import (
|
||||
)
|
||||
|
||||
// Ensure Service implements chain info interface.
|
||||
var _ = ChainInfoFetcher(&Service{})
|
||||
var _ = TimeFetcher(&Service{})
|
||||
var _ = ForkFetcher(&Service{})
|
||||
var _ ChainInfoFetcher = (*Service)(nil)
|
||||
var _ TimeFetcher = (*Service)(nil)
|
||||
var _ ForkFetcher = (*Service)(nil)
|
||||
|
||||
func TestFinalizedCheckpt_Nil(t *testing.T) {
|
||||
db, sc := testDB.SetupDB(t)
|
||||
|
@ -67,7 +67,7 @@ func (mb *mockBroadcaster) BroadcastAttestation(_ context.Context, _ uint64, _ *
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ = p2p.Broadcaster(&mockBroadcaster{})
|
||||
var _ p2p.Broadcaster = (*mockBroadcaster)(nil)
|
||||
|
||||
func setupBeaconChain(t *testing.T, beaconDB db.Database, sc *cache.StateSummaryCache) *Service {
|
||||
endpoint := "http://127.0.0.1"
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
|
||||
const nilDepositErr = "Ignoring nil deposit insertion"
|
||||
|
||||
var _ = DepositFetcher(&DepositCache{})
|
||||
var _ DepositFetcher = (*DepositCache)(nil)
|
||||
|
||||
func TestInsertDeposit_LogsOnNilDepositInsertion(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
)
|
||||
|
||||
var _ = PendingDepositsFetcher(&DepositCache{})
|
||||
var _ PendingDepositsFetcher = (*DepositCache)(nil)
|
||||
|
||||
func TestInsertPendingDeposit_OK(t *testing.T) {
|
||||
dc := DepositCache{}
|
||||
|
@ -2,4 +2,4 @@ package db
|
||||
|
||||
import "github.com/prysmaticlabs/prysm/beacon-chain/db/kv"
|
||||
|
||||
var _ = Database(&kv.Store{})
|
||||
var _ Database = (*kv.Store)(nil)
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
_ "gopkg.in/confluentinc/confluent-kafka-go.v1/kafka/librdkafka" // Required for c++ kafka library.
|
||||
)
|
||||
|
||||
var _ = iface.Database(&Exporter{})
|
||||
var _ iface.Database = (*Exporter)(nil)
|
||||
var log = logrus.WithField("prefix", "exporter")
|
||||
var marshaler = &jsonpb.Marshaler{}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
bolt "go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
var _ = iface.Database(&Store{})
|
||||
var _ iface.Database = (*Store)(nil)
|
||||
|
||||
const (
|
||||
// VotesCacheSize with 1M validators will be 8MB.
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
"google.golang.org/grpc/connectivity"
|
||||
)
|
||||
|
||||
var _ = shared.Service(&Gateway{})
|
||||
var _ shared.Service = (*Gateway)(nil)
|
||||
|
||||
// Gateway is the gRPC gateway to serve HTTP JSON traffic as a proxy and forward
|
||||
// it to the beacon-chain gRPC server.
|
||||
|
@ -22,9 +22,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/slotutil"
|
||||
)
|
||||
|
||||
var _ = shared.Service(&Service{})
|
||||
var _ = depositcache.DepositFetcher(&Service{})
|
||||
var _ = powchain.ChainStartFetcher(&Service{})
|
||||
var _ shared.Service = (*Service)(nil)
|
||||
var _ depositcache.DepositFetcher = (*Service)(nil)
|
||||
var _ powchain.ChainStartFetcher = (*Service)(nil)
|
||||
|
||||
// Service spins up an client interoperability service that handles responsibilities such
|
||||
// as kickstarting a genesis state for the beacon node from cli flags or a genesis.ssz file.
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
// Ensure BeaconNode implements interfaces.
|
||||
var _ = statefeed.Notifier(&BeaconNode{})
|
||||
var _ statefeed.Notifier = (*BeaconNode)(nil)
|
||||
|
||||
// Test that beacon chain node can close.
|
||||
func TestNodeClose_OK(t *testing.T) {
|
||||
|
@ -4,4 +4,4 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations/kv"
|
||||
)
|
||||
|
||||
var _ = Pool(&kv.AttCaches{})
|
||||
var _ Pool = (*kv.AttCaches)(nil)
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
var _ = NetworkEncoding(&SszNetworkEncoder{})
|
||||
var _ NetworkEncoding = (*SszNetworkEncoder)(nil)
|
||||
|
||||
// MaxGossipSize allowed for gossip messages.
|
||||
var MaxGossipSize = params.BeaconNetworkConfig().GossipMaxSize // 1 Mib
|
||||
|
@ -37,7 +37,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/slotutil"
|
||||
)
|
||||
|
||||
var _ = shared.Service(&Service{})
|
||||
var _ shared.Service = (*Service)(nil)
|
||||
|
||||
// In the event that we are at our peer limit, we
|
||||
// stop looking for new peers and instead poll
|
||||
|
@ -27,10 +27,10 @@ import (
|
||||
logTest "github.com/sirupsen/logrus/hooks/test"
|
||||
)
|
||||
|
||||
var _ = ChainStartFetcher(&Service{})
|
||||
var _ = ChainInfoFetcher(&Service{})
|
||||
var _ = POWBlockFetcher(&Service{})
|
||||
var _ = Chain(&Service{})
|
||||
var _ ChainStartFetcher = (*Service)(nil)
|
||||
var _ ChainInfoFetcher = (*Service)(nil)
|
||||
var _ POWBlockFetcher = (*Service)(nil)
|
||||
var _ Chain = (*Service)(nil)
|
||||
|
||||
type goodLogger struct {
|
||||
backend *backends.SimulatedBackend
|
||||
|
@ -2,4 +2,4 @@ package beaconv1
|
||||
|
||||
import ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1"
|
||||
|
||||
var _ = ethpb.BeaconChainServer(&Server{})
|
||||
var _ ethpb.BeaconChainServer = (*Server)(nil)
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var _ = shared.Service(&Service{})
|
||||
var _ shared.Service = (*Service)(nil)
|
||||
|
||||
// blockchainService defines the interface for interaction with block chain service.
|
||||
type blockchainService interface {
|
||||
|
@ -32,7 +32,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/timeutils"
|
||||
)
|
||||
|
||||
var _ = shared.Service(&Service{})
|
||||
var _ shared.Service = (*Service)(nil)
|
||||
|
||||
const rangeLimit = 1024
|
||||
const seenBlockSize = 1000
|
||||
|
@ -37,7 +37,7 @@ import (
|
||||
|
||||
type source struct{}
|
||||
|
||||
var _ = mrand.Source64(&source{})
|
||||
var _ mrand.Source64 = (*source)(nil)
|
||||
|
||||
// Seed does nothing when crypto/rand is used as source.
|
||||
func (s *source) Seed(seed int64) {}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ = Ticker(&SlotTicker{})
|
||||
var _ Ticker = (*SlotTicker)(nil)
|
||||
|
||||
func TestSlotTicker(t *testing.T) {
|
||||
ticker := &SlotTicker{
|
||||
|
@ -2,4 +2,4 @@ package testing
|
||||
|
||||
import "github.com/prysmaticlabs/prysm/shared/slotutil"
|
||||
|
||||
var _ = slotutil.Ticker(&MockTicker{})
|
||||
var _ slotutil.Ticker = (*MockTicker)(nil)
|
||||
|
@ -2,4 +2,4 @@ package db
|
||||
|
||||
import "github.com/prysmaticlabs/prysm/slasher/db/kv"
|
||||
|
||||
var _ = Database(&kv.Store{})
|
||||
var _ Database = (*kv.Store)(nil)
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/slasher/detection/attestations/types"
|
||||
)
|
||||
|
||||
var _ = iface.SpanDetector(&MockSpanDetector{})
|
||||
var _ iface.SpanDetector = (*MockSpanDetector)(nil)
|
||||
|
||||
// MockSpanDetector defines a struct which can detect slashable
|
||||
// attestation offenses by tracking validator min-max
|
||||
|
@ -35,7 +35,7 @@ var (
|
||||
// TODO(#5040): Remove lookback and handle min spans properly.
|
||||
const epochLookback = 128
|
||||
|
||||
var _ = iface.SpanDetector(&SpanDetector{})
|
||||
var _ iface.SpanDetector = (*SpanDetector)(nil)
|
||||
|
||||
// SpanDetector defines a struct which can detect slashable
|
||||
// attestation offenses by tracking validator min-max
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
testDetect "github.com/prysmaticlabs/prysm/slasher/detection/testing"
|
||||
)
|
||||
|
||||
var _ = iface.ProposalsDetector(&ProposeDetector{})
|
||||
var _ iface.ProposalsDetector = (*ProposeDetector)(nil)
|
||||
|
||||
func TestProposalsDetector_DetectSlashingsForBlockHeaders(t *testing.T) {
|
||||
type testStruct struct {
|
||||
|
@ -4,4 +4,4 @@ import (
|
||||
pb "github.com/prysmaticlabs/prysm/proto/cluster"
|
||||
)
|
||||
|
||||
var _ = pb.PrivateKeyServiceServer(&server{})
|
||||
var _ pb.PrivateKeyServiceServer = (*server)(nil)
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/timeutils"
|
||||
)
|
||||
|
||||
var _ = Validator(&FakeValidator{})
|
||||
var _ Validator = (*FakeValidator)(nil)
|
||||
|
||||
// FakeValidator for mocking.
|
||||
type FakeValidator struct {
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
logTest "github.com/sirupsen/logrus/hooks/test"
|
||||
)
|
||||
|
||||
var _ = shared.Service(&ValidatorService{})
|
||||
var _ shared.Service = (*ValidatorService)(nil)
|
||||
var validatorKey *keystore.Key
|
||||
var validatorPubKey [48]byte
|
||||
var keyMap map[[48]byte]*keystore.Key
|
||||
|
@ -28,7 +28,7 @@ func init() {
|
||||
logrus.SetOutput(ioutil.Discard)
|
||||
}
|
||||
|
||||
var _ = Validator(&validator{})
|
||||
var _ Validator = (*validator)(nil)
|
||||
|
||||
const cancelledCtx = "context has been canceled"
|
||||
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/validator/keymanager/v2/derived"
|
||||
)
|
||||
|
||||
var _ = accountCreator(&mockAccountCreator{})
|
||||
var _ accountCreator = (*mockAccountCreator)(nil)
|
||||
|
||||
type mockAccountCreator struct {
|
||||
data *ethpb.Deposit_Data
|
||||
|
@ -4,4 +4,4 @@ import (
|
||||
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
|
||||
)
|
||||
|
||||
var _ = pb.AuthServer(&Server{})
|
||||
var _ pb.AuthServer = (*Server)(nil)
|
||||
|
Loading…
Reference in New Issue
Block a user