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:
Victor Farazdagi 2020-10-10 03:36:48 +03:00 committed by GitHub
parent 8aaa5b6ad0
commit d98a6dda8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 37 additions and 37 deletions

View File

@ -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)

View File

@ -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"

View File

@ -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()

View File

@ -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{}

View File

@ -2,4 +2,4 @@ package db
import "github.com/prysmaticlabs/prysm/beacon-chain/db/kv"
var _ = Database(&kv.Store{})
var _ Database = (*kv.Store)(nil)

View File

@ -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{}

View File

@ -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.

View File

@ -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.

View File

@ -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.

View 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) {

View File

@ -4,4 +4,4 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations/kv"
)
var _ = Pool(&kv.AttCaches{})
var _ Pool = (*kv.AttCaches)(nil)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -2,4 +2,4 @@ package beaconv1
import ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1"
var _ = ethpb.BeaconChainServer(&Server{})
var _ ethpb.BeaconChainServer = (*Server)(nil)

View File

@ -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 {

View File

@ -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

View File

@ -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) {}

View File

@ -5,7 +5,7 @@ import (
"time"
)
var _ = Ticker(&SlotTicker{})
var _ Ticker = (*SlotTicker)(nil)
func TestSlotTicker(t *testing.T) {
ticker := &SlotTicker{

View File

@ -2,4 +2,4 @@ package testing
import "github.com/prysmaticlabs/prysm/shared/slotutil"
var _ = slotutil.Ticker(&MockTicker{})
var _ slotutil.Ticker = (*MockTicker)(nil)

View File

@ -2,4 +2,4 @@ package db
import "github.com/prysmaticlabs/prysm/slasher/db/kv"
var _ = Database(&kv.Store{})
var _ Database = (*kv.Store)(nil)

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -4,4 +4,4 @@ import (
pb "github.com/prysmaticlabs/prysm/proto/cluster"
)
var _ = pb.PrivateKeyServiceServer(&server{})
var _ pb.PrivateKeyServiceServer = (*server)(nil)

View File

@ -8,7 +8,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/timeutils"
)
var _ = Validator(&FakeValidator{})
var _ Validator = (*FakeValidator)(nil)
// FakeValidator for mocking.
type FakeValidator struct {

View File

@ -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

View File

@ -28,7 +28,7 @@ func init() {
logrus.SetOutput(ioutil.Discard)
}
var _ = Validator(&validator{})
var _ Validator = (*validator)(nil)
const cancelledCtx = "context has been canceled"

View File

@ -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

View File

@ -4,4 +4,4 @@ import (
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
)
var _ = pb.AuthServer(&Server{})
var _ pb.AuthServer = (*Server)(nil)