From 45a30f9868714d0afea39d3d948ec1dbbfadfc1c Mon Sep 17 00:00:00 2001 From: Joshua Kim <20001595+joshua-kim@users.noreply.github.com> Date: Thu, 4 Jul 2024 14:46:57 -0400 Subject: [PATCH 1/2] Send AppErrors from p2p SDK (#2753) Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com> Co-authored-by: Stephen Buttolph --- go.mod | 2 +- go.sum | 4 +- network/p2p/error.go | 33 ++++++++ network/p2p/gossip/handler.go | 16 ++-- network/p2p/handler.go | 18 ++--- network/p2p/handler_test.go | 3 +- network/p2p/network_test.go | 108 +++++++++++++++++++++++--- network/p2p/router.go | 12 ++- network/p2p/throttler_handler.go | 12 +-- network/p2p/throttler_handler_test.go | 3 +- vms/avm/network/gossip.go | 3 +- vms/platformvm/network/gossip.go | 3 +- vms/platformvm/vm_test.go | 3 + 13 files changed, 174 insertions(+), 46 deletions(-) create mode 100644 network/p2p/error.go diff --git a/go.mod b/go.mod index 3c251d2fc54c..4eef73478aa4 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/DataDog/zstd v1.5.2 github.com/NYTimes/gziphandler v1.1.1 github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/ava-labs/coreth v0.13.6-rc.1 + github.com/ava-labs/coreth v0.13.6-rc.1.0.20240702201359-ba2ce5367874 github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 diff --git a/go.sum b/go.sum index 49e67f0213d6..0642e3c0e5fa 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/coreth v0.13.6-rc.1 h1:gRXRokmu0WOlPqyx+mTLWB655e8/w++u6qFcq9Mo7qA= -github.com/ava-labs/coreth v0.13.6-rc.1/go.mod h1:vm9T8qzP7RLo/jR2MKkliPfaiGgWeEpu/PG6fvvPmog= +github.com/ava-labs/coreth v0.13.6-rc.1.0.20240702201359-ba2ce5367874 h1:aTDg0jvO07EvUvBYebmLO25bffe1DAaZZPPL0ooGhIA= +github.com/ava-labs/coreth v0.13.6-rc.1.0.20240702201359-ba2ce5367874/go.mod h1:VhNDxZBsqZQQaUTmIkzdyY8UicIsoTDXlRmPaPL9lkA= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 h1:dOVbtdnZL++pENdTCNZ1nu41eYDQkTML4sWebDnnq8c= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= diff --git a/network/p2p/error.go b/network/p2p/error.go new file mode 100644 index 000000000000..07207319a041 --- /dev/null +++ b/network/p2p/error.go @@ -0,0 +1,33 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package p2p + +import "github.com/ava-labs/avalanchego/snow/engine/common" + +var ( + // ErrUnexpected should be used to indicate that a request failed due to a + // generic error + ErrUnexpected = &common.AppError{ + Code: -1, + Message: "unexpected error", + } + // ErrUnregisteredHandler should be used to indicate that a request failed + // due to it not matching a registered handler + ErrUnregisteredHandler = &common.AppError{ + Code: -2, + Message: "unregistered handler", + } + // ErrNotValidator should be used to indicate that a request failed due to + // the requesting peer not being a validator + ErrNotValidator = &common.AppError{ + Code: -3, + Message: "not a validator", + } + // ErrThrottled should be used to indicate that a request failed due to the + // requesting peer exceeding a rate limit + ErrThrottled = &common.AppError{ + Code: -4, + Message: "throttled", + } +) diff --git a/network/p2p/gossip/handler.go b/network/p2p/gossip/handler.go index 7f5f7b380ed7..1205a5f2b7df 100644 --- a/network/p2p/gossip/handler.go +++ b/network/p2p/gossip/handler.go @@ -11,6 +11,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" + "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/utils/bloom" "github.com/ava-labs/avalanchego/utils/logging" ) @@ -43,10 +44,10 @@ type Handler[T Gossipable] struct { targetResponseSize int } -func (h Handler[T]) AppRequest(_ context.Context, _ ids.NodeID, _ time.Time, requestBytes []byte) ([]byte, error) { +func (h Handler[T]) AppRequest(_ context.Context, _ ids.NodeID, _ time.Time, requestBytes []byte) ([]byte, *common.AppError) { filter, salt, err := ParseAppRequest(requestBytes) if err != nil { - return nil, err + return nil, p2p.ErrUnexpected } responseSize := 0 @@ -73,14 +74,19 @@ func (h Handler[T]) AppRequest(_ context.Context, _ ids.NodeID, _ time.Time, req return responseSize <= h.targetResponseSize }) if err != nil { - return nil, err + return nil, p2p.ErrUnexpected } if err := h.metrics.observeMessage(sentPullLabels, len(gossipBytes), responseSize); err != nil { - return nil, err + return nil, p2p.ErrUnexpected } - return MarshalAppResponse(gossipBytes) + response, err := MarshalAppResponse(gossipBytes) + if err != nil { + return nil, p2p.ErrUnexpected + } + + return response, nil } func (h Handler[_]) AppGossip(_ context.Context, nodeID ids.NodeID, gossipBytes []byte) { diff --git a/network/p2p/handler.go b/network/p2p/handler.go index ed005fb761c0..3afeb3eb9a46 100644 --- a/network/p2p/handler.go +++ b/network/p2p/handler.go @@ -5,7 +5,6 @@ package p2p import ( "context" - "errors" "time" "go.uber.org/zap" @@ -17,8 +16,6 @@ import ( ) var ( - ErrNotValidator = errors.New("not a validator") - _ Handler = (*NoOpHandler)(nil) _ Handler = (*TestHandler)(nil) _ Handler = (*ValidatorHandler)(nil) @@ -33,13 +30,14 @@ type Handler interface { gossipBytes []byte, ) // AppRequest is called when handling an AppRequest message. - // Returns the bytes for the response corresponding to [requestBytes] + // Sends a response with the response corresponding to [requestBytes] or + // an application-defined error. AppRequest( ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte, - ) ([]byte, error) + ) ([]byte, *common.AppError) // CrossChainAppRequest is called when handling a CrossChainAppRequest // message. // Returns the bytes for the response corresponding to [requestBytes] @@ -56,7 +54,7 @@ type NoOpHandler struct{} func (NoOpHandler) AppGossip(context.Context, ids.NodeID, []byte) {} -func (NoOpHandler) AppRequest(context.Context, ids.NodeID, time.Time, []byte) ([]byte, error) { +func (NoOpHandler) AppRequest(context.Context, ids.NodeID, time.Time, []byte) ([]byte, *common.AppError) { return nil, nil } @@ -95,7 +93,7 @@ func (v ValidatorHandler) AppGossip(ctx context.Context, nodeID ids.NodeID, goss v.handler.AppGossip(ctx, nodeID, gossipBytes) } -func (v ValidatorHandler) AppRequest(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, error) { +func (v ValidatorHandler) AppRequest(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, *common.AppError) { if !v.validatorSet.Has(ctx, nodeID) { return nil, ErrNotValidator } @@ -128,7 +126,7 @@ func (r *responder) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID zap.Binary("message", request), zap.Error(err), ) - return nil + return r.sender.SendAppError(ctx, nodeID, requestID, err.Code, err.Message) } return r.sender.SendAppResponse(ctx, nodeID, requestID, appResponse) @@ -155,7 +153,7 @@ func (r *responder) CrossChainAppRequest(ctx context.Context, chainID ids.ID, re type TestHandler struct { AppGossipF func(ctx context.Context, nodeID ids.NodeID, gossipBytes []byte) - AppRequestF func(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, error) + AppRequestF func(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, *common.AppError) CrossChainAppRequestF func(ctx context.Context, chainID ids.ID, deadline time.Time, requestBytes []byte) ([]byte, error) } @@ -167,7 +165,7 @@ func (t TestHandler) AppGossip(ctx context.Context, nodeID ids.NodeID, gossipByt t.AppGossipF(ctx, nodeID, gossipBytes) } -func (t TestHandler) AppRequest(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, error) { +func (t TestHandler) AppRequest(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, *common.AppError) { if t.AppRequestF == nil { return nil, nil } diff --git a/network/p2p/handler_test.go b/network/p2p/handler_test.go index 0633b70f00a8..f933215ca6ee 100644 --- a/network/p2p/handler_test.go +++ b/network/p2p/handler_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/set" ) @@ -79,7 +80,7 @@ func TestValidatorHandlerAppRequest(t *testing.T) { name string validatorSet ValidatorSet nodeID ids.NodeID - expected error + expected *common.AppError }{ { name: "message dropped", diff --git a/network/p2p/network_test.go b/network/p2p/network_test.go index 5339a6eeb315..5346a9255a00 100644 --- a/network/p2p/network_test.go +++ b/network/p2p/network_test.go @@ -43,7 +43,7 @@ func TestMessageRouting(t *testing.T) { require.Equal(wantNodeID, nodeID) require.Equal(wantMsg, msg) }, - AppRequestF: func(_ context.Context, nodeID ids.NodeID, _ time.Time, msg []byte) ([]byte, error) { + AppRequestF: func(_ context.Context, nodeID ids.NodeID, _ time.Time, msg []byte) ([]byte, *common.AppError) { appRequestCalled = true require.Equal(wantNodeID, nodeID) require.Equal(wantMsg, msg) @@ -352,7 +352,7 @@ func TestCrossChainAppRequestFailed(t *testing.T) { } // Messages for unregistered handlers should be dropped gracefully -func TestMessageForUnregisteredHandler(t *testing.T) { +func TestAppGossipMessageForUnregisteredHandler(t *testing.T) { tests := []struct { name string msg []byte @@ -379,26 +379,110 @@ func TestMessageForUnregisteredHandler(t *testing.T) { AppGossipF: func(context.Context, ids.NodeID, []byte) { require.Fail("should not be called") }, - AppRequestF: func(context.Context, ids.NodeID, time.Time, []byte) ([]byte, error) { - require.Fail("should not be called") - return nil, nil - }, - CrossChainAppRequestF: func(context.Context, ids.ID, time.Time, []byte) ([]byte, error) { + } + network, err := NewNetwork(logging.NoLog{}, nil, prometheus.NewRegistry(), "") + require.NoError(err) + require.NoError(network.AddHandler(handlerID, handler)) + require.NoError(network.AppGossip(ctx, ids.EmptyNodeID, tt.msg)) + }) + } +} + +// An unregistered handler should gracefully drop messages by responding +// to the requester with a common.AppError +func TestAppRequestMessageForUnregisteredHandler(t *testing.T) { + tests := []struct { + name string + msg []byte + }{ + { + name: "nil", + msg: nil, + }, + { + name: "empty", + msg: []byte{}, + }, + { + name: "non-empty", + msg: []byte("foobar"), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require := require.New(t) + ctx := context.Background() + handler := &TestHandler{ + AppRequestF: func(context.Context, ids.NodeID, time.Time, []byte) ([]byte, *common.AppError) { require.Fail("should not be called") return nil, nil }, } - network, err := NewNetwork(logging.NoLog{}, nil, prometheus.NewRegistry(), "") + + wantNodeID := ids.GenerateTestNodeID() + wantRequestID := uint32(111) + + done := make(chan struct{}) + sender := &common.SenderTest{} + sender.SendAppErrorF = func(_ context.Context, nodeID ids.NodeID, requestID uint32, errorCode int32, errorMessage string) error { + defer close(done) + + require.Equal(wantNodeID, nodeID) + require.Equal(wantRequestID, requestID) + require.Equal(ErrUnregisteredHandler.Code, errorCode) + require.Equal(ErrUnregisteredHandler.Message, errorMessage) + + return nil + } + network, err := NewNetwork(logging.NoLog{}, sender, prometheus.NewRegistry(), "") require.NoError(err) require.NoError(network.AddHandler(handlerID, handler)) - require.NoError(network.AppRequest(ctx, ids.EmptyNodeID, 0, time.Time{}, tt.msg)) - require.NoError(network.AppGossip(ctx, ids.EmptyNodeID, tt.msg)) - require.NoError(network.CrossChainAppRequest(ctx, ids.Empty, 0, time.Time{}, tt.msg)) + require.NoError(network.AppRequest(ctx, wantNodeID, wantRequestID, time.Time{}, tt.msg)) + <-done }) } } +// A handler that errors should send an AppError to the requesting peer +func TestAppError(t *testing.T) { + require := require.New(t) + ctx := context.Background() + appError := &common.AppError{ + Code: 123, + Message: "foo", + } + handler := &TestHandler{ + AppRequestF: func(context.Context, ids.NodeID, time.Time, []byte) ([]byte, *common.AppError) { + return nil, appError + }, + } + + wantNodeID := ids.GenerateTestNodeID() + wantRequestID := uint32(111) + + done := make(chan struct{}) + sender := &common.SenderTest{} + sender.SendAppErrorF = func(_ context.Context, nodeID ids.NodeID, requestID uint32, errorCode int32, errorMessage string) error { + defer close(done) + + require.Equal(wantNodeID, nodeID) + require.Equal(wantRequestID, requestID) + require.Equal(appError.Code, errorCode) + require.Equal(appError.Message, errorMessage) + + return nil + } + network, err := NewNetwork(logging.NoLog{}, sender, prometheus.NewRegistry(), "") + require.NoError(err) + require.NoError(network.AddHandler(handlerID, handler)) + msg := PrefixMessage(ProtocolPrefix(handlerID), []byte("message")) + + require.NoError(network.AppRequest(ctx, wantNodeID, wantRequestID, time.Time{}, msg)) + <-done +} + // A response or timeout for a request we never made should return an error func TestResponseForUnrequestedRequest(t *testing.T) { tests := []struct { @@ -427,7 +511,7 @@ func TestResponseForUnrequestedRequest(t *testing.T) { AppGossipF: func(context.Context, ids.NodeID, []byte) { require.Fail("should not be called") }, - AppRequestF: func(context.Context, ids.NodeID, time.Time, []byte) ([]byte, error) { + AppRequestF: func(context.Context, ids.NodeID, time.Time, []byte) ([]byte, *common.AppError) { require.Fail("should not be called") return nil, nil }, diff --git a/network/p2p/router.go b/network/p2p/router.go index 6d4c7efe4d47..8f099ddb0b64 100644 --- a/network/p2p/router.go +++ b/network/p2p/router.go @@ -128,14 +128,18 @@ func (r *router) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID ui start := time.Now() parsedMsg, handler, handlerID, ok := r.parse(request) if !ok { - r.log.Debug("failed to process message", + r.log.Debug("received message for unregistered handler", zap.Stringer("messageOp", message.AppRequestOp), zap.Stringer("nodeID", nodeID), zap.Uint32("requestID", requestID), zap.Time("deadline", deadline), zap.Binary("message", request), ) - return nil + + // Send an error back to the requesting peer. Invalid requests that we + // cannot parse a handler id for are handled the same way as requests + // for which we do not have a registered handler. + return r.sender.SendAppError(ctx, nodeID, requestID, ErrUnregisteredHandler.Code, ErrUnregisteredHandler.Message) } // call the corresponding handler and send back a response to nodeID @@ -209,7 +213,7 @@ func (r *router) AppGossip(ctx context.Context, nodeID ids.NodeID, gossip []byte start := time.Now() parsedMsg, handler, handlerID, ok := r.parse(gossip) if !ok { - r.log.Debug("failed to process message", + r.log.Debug("received message for unregistered handler", zap.Stringer("messageOp", message.AppGossipOp), zap.Stringer("nodeID", nodeID), zap.Binary("message", gossip), @@ -244,7 +248,7 @@ func (r *router) CrossChainAppRequest( start := time.Now() parsedMsg, handler, handlerID, ok := r.parse(msg) if !ok { - r.log.Debug("failed to process message", + r.log.Debug("received message for unregistered handler", zap.Stringer("messageOp", message.CrossChainAppRequestOp), zap.Stringer("chainID", chainID), zap.Uint32("requestID", requestID), diff --git a/network/p2p/throttler_handler.go b/network/p2p/throttler_handler.go index df0200482ef6..2718f733223c 100644 --- a/network/p2p/throttler_handler.go +++ b/network/p2p/throttler_handler.go @@ -5,20 +5,16 @@ package p2p import ( "context" - "errors" - "fmt" "time" "go.uber.org/zap" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/utils/logging" ) -var ( - ErrThrottled = errors.New("throttled") - _ Handler = (*ThrottlerHandler)(nil) -) +var _ Handler = (*ThrottlerHandler)(nil) func NewThrottlerHandler(handler Handler, throttler Throttler, log logging.Logger) *ThrottlerHandler { return &ThrottlerHandler{ @@ -46,9 +42,9 @@ func (t ThrottlerHandler) AppGossip(ctx context.Context, nodeID ids.NodeID, goss t.handler.AppGossip(ctx, nodeID, gossipBytes) } -func (t ThrottlerHandler) AppRequest(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, error) { +func (t ThrottlerHandler) AppRequest(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, *common.AppError) { if !t.throttler.Handle(nodeID) { - return nil, fmt.Errorf("dropping message from %s: %w", nodeID, ErrThrottled) + return nil, ErrThrottled } return t.handler.AppRequest(ctx, nodeID, deadline, requestBytes) diff --git a/network/p2p/throttler_handler_test.go b/network/p2p/throttler_handler_test.go index 1f5a07069d8e..52dd964f1013 100644 --- a/network/p2p/throttler_handler_test.go +++ b/network/p2p/throttler_handler_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/utils/logging" ) @@ -57,7 +58,7 @@ func TestThrottlerHandlerAppRequest(t *testing.T) { tests := []struct { name string Throttler Throttler - expectedErr error + expectedErr *common.AppError }{ { name: "not throttled", diff --git a/vms/avm/network/gossip.go b/vms/avm/network/gossip.go index 6ea5f1448485..131cc51688fa 100644 --- a/vms/avm/network/gossip.go +++ b/vms/avm/network/gossip.go @@ -14,6 +14,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/network/p2p/gossip" + "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/txs/mempool" @@ -51,7 +52,7 @@ func (t txGossipHandler) AppRequest( nodeID ids.NodeID, deadline time.Time, requestBytes []byte, -) ([]byte, error) { +) ([]byte, *common.AppError) { return t.appRequestHandler.AppRequest(ctx, nodeID, deadline, requestBytes) } diff --git a/vms/platformvm/network/gossip.go b/vms/platformvm/network/gossip.go index c8cfefceed48..7e6e7adc341c 100644 --- a/vms/platformvm/network/gossip.go +++ b/vms/platformvm/network/gossip.go @@ -14,6 +14,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/network/p2p/gossip" + "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/txs/mempool" @@ -51,7 +52,7 @@ func (t txGossipHandler) AppRequest( nodeID ids.NodeID, deadline time.Time, requestBytes []byte, -) ([]byte, error) { +) ([]byte, *common.AppError) { return t.appRequestHandler.AppRequest(ctx, nodeID, deadline, requestBytes) } diff --git a/vms/platformvm/vm_test.go b/vms/platformvm/vm_test.go index 24fa707a8e32..9153ee6548bf 100644 --- a/vms/platformvm/vm_test.go +++ b/vms/platformvm/vm_test.go @@ -291,6 +291,9 @@ func defaultVM(t *testing.T, f fork) (*VM, *txstest.WalletFactory, database.Data appSender.SendAppGossipF = func(context.Context, common.SendConfig, []byte) error { return nil } + appSender.SendAppErrorF = func(context.Context, ids.NodeID, uint32, int32, string) error { + return nil + } dynamicConfigBytes := []byte(`{"network":{"max-validator-set-staleness":0}}`) require.NoError(vm.Initialize( From 2af3890f79d49aacd2de4c090433fdf614398dc9 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg <519948+ARR4N@users.noreply.github.com> Date: Mon, 8 Jul 2024 17:41:21 +0100 Subject: [PATCH 2/2] build(tests): require `//go:build test` tag if importing test packages outside of `_test.go` files (#3173) --- .golangci.yml | 5 ++++ .vscode/settings.json | 11 ++++++++ cache/test_cacher.go | 2 ++ chains/atomic/test_shared_memory.go | 2 ++ codec/test_codec.go | 2 ++ database/benchmark_database.go | 2 ++ database/test_database.go | 2 ++ ids/test_aliases.go | 2 ++ scripts/build_fuzz.sh | 2 +- scripts/build_test.sh | 2 +- scripts/lint.sh | 27 ++++++++++++++++++- scripts/tests.e2e.existing.sh | 2 +- scripts/tests.e2e.sh | 4 +-- scripts/tests.upgrade.sh | 2 +- snow/consensus/snowball/test_snowflake.go | 2 ++ .../avalanche/bootstrap/queue/test_job.go | 2 ++ .../avalanche/bootstrap/queue/test_parser.go | 2 ++ snow/engine/avalanche/vertex/test_builder.go | 2 ++ snow/engine/avalanche/vertex/test_manager.go | 2 ++ snow/engine/avalanche/vertex/test_parser.go | 2 ++ snow/engine/avalanche/vertex/test_storage.go | 2 ++ snow/engine/avalanche/vertex/test_vm.go | 2 ++ snow/engine/common/test_bootstrap_tracker.go | 2 ++ snow/engine/common/test_bootstrapper.go | 2 ++ snow/engine/common/test_engine.go | 2 ++ snow/engine/common/test_sender.go | 2 ++ snow/engine/common/test_timer.go | 2 ++ snow/engine/common/test_vm.go | 2 ++ snow/engine/snowman/block/test_batched_vm.go | 2 ++ .../snowman/block/test_state_summary.go | 2 ++ .../snowman/block/test_state_syncable_vm.go | 2 ++ snow/engine/snowman/block/test_vm.go | 2 ++ snow/networking/benchlist/test_benchable.go | 2 ++ .../networking/sender/test_external_sender.go | 2 ++ snow/snowtest/snowtest.go | 2 ++ snow/validators/test_state.go | 3 +++ tests/e2e/banff/suites.go | 2 ++ tests/e2e/c/dynamic_fees.go | 2 ++ tests/e2e/c/interchain_workflow.go | 2 ++ tests/e2e/faultinjection/duplicate_node_id.go | 2 ++ tests/e2e/p/interchain_workflow.go | 2 ++ tests/e2e/p/permissionless_subnets.go | 2 ++ tests/e2e/p/staking_rewards.go | 2 ++ tests/e2e/p/validator_sets.go | 2 ++ tests/e2e/p/workflow.go | 2 ++ tests/e2e/vms/xsvm.go | 2 ++ tests/e2e/x/interchain_workflow.go | 2 ++ tests/e2e/x/transfer/virtuous.go | 2 ++ tests/fixture/e2e/env.go | 2 ++ tests/fixture/e2e/helpers.go | 2 ++ vms/platformvm/warp/test_signer.go | 2 ++ wallet/subnet/primary/common/test_utxos.go | 2 ++ 52 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.golangci.yml b/.golangci.yml index a1991abd29aa..1809a5fa6609 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,6 +15,11 @@ run: # By default, it isn't set. modules-download-mode: readonly + # Include non-test files tagged as test-only. + # Context: https://github.com/ava-labs/avalanchego/pull/3173 + build-tags: + - test + output: # Make issues output unique by line. # Default: true diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000000..0abd38ef2982 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "gopls": { + "build.buildFlags": [ + // Context: https://github.com/ava-labs/avalanchego/pull/3173 + // Without this tag, the language server won't build the test-only + // code in non-_test.go files. + "--tags='test'", + ], + }, + "go.testTags": "test", +} \ No newline at end of file diff --git a/cache/test_cacher.go b/cache/test_cacher.go index 2e85502e4a55..35b1ad9c1711 100644 --- a/cache/test_cacher.go +++ b/cache/test_cacher.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package cache import ( diff --git a/chains/atomic/test_shared_memory.go b/chains/atomic/test_shared_memory.go index 82b1cbeff3a5..f1c7b44ae30c 100644 --- a/chains/atomic/test_shared_memory.go +++ b/chains/atomic/test_shared_memory.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package atomic import ( diff --git a/codec/test_codec.go b/codec/test_codec.go index 2dc8b3e2add9..974168dd4829 100644 --- a/codec/test_codec.go +++ b/codec/test_codec.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package codec import ( diff --git a/database/benchmark_database.go b/database/benchmark_database.go index 43af10db1c2b..479035c126cb 100644 --- a/database/benchmark_database.go +++ b/database/benchmark_database.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package database import ( diff --git a/database/test_database.go b/database/test_database.go index e35a98dca36f..4e5bc174ae85 100644 --- a/database/test_database.go +++ b/database/test_database.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package database import ( diff --git a/ids/test_aliases.go b/ids/test_aliases.go index ce9991f5f737..3943fce16023 100644 --- a/ids/test_aliases.go +++ b/ids/test_aliases.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package ids import "github.com/stretchr/testify/require" diff --git a/scripts/build_fuzz.sh b/scripts/build_fuzz.sh index 49378e2e0878..520b244bc631 100755 --- a/scripts/build_fuzz.sh +++ b/scripts/build_fuzz.sh @@ -28,7 +28,7 @@ do echo "Fuzzing $func in $file" parentDir=$(dirname "$file") # If any of the fuzz tests fail, return exit code 1 - if ! go test "$parentDir" -run="$func" -fuzz="$func" -fuzztime="${fuzzTime}"s; then + if ! go test -tags test "$parentDir" -run="$func" -fuzz="$func" -fuzztime="${fuzzTime}"s; then failed=true fi done diff --git a/scripts/build_test.sh b/scripts/build_test.sh index c0c9b72e3230..4a7cbd04f746 100755 --- a/scripts/build_test.sh +++ b/scripts/build_test.sh @@ -18,4 +18,4 @@ fi TEST_TARGETS="$(eval "go list ./... ${EXCLUDED_TARGETS}")" # shellcheck disable=SC2086 -go test -shuffle=on -race -timeout="${TIMEOUT:-120s}" -coverprofile="coverage.out" -covermode="atomic" ${TEST_TARGETS} +go test -tags test -shuffle=on -race -timeout="${TIMEOUT:-120s}" -coverprofile="coverage.out" -covermode="atomic" ${TEST_TARGETS} diff --git a/scripts/lint.sh b/scripts/lint.sh index 9fb23ae325be..7f2111d6f96e 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -29,7 +29,7 @@ fi # by default, "./scripts/lint.sh" runs all lint tests # to run only "license_header" test # TESTS='license_header' ./scripts/lint.sh -TESTS=${TESTS:-"golangci_lint license_header require_error_is_no_funcs_as_params single_import interface_compliance_nil require_no_error_inline_func"} +TESTS=${TESTS:-"golangci_lint license_header require_error_is_no_funcs_as_params single_import interface_compliance_nil require_no_error_inline_func import_testing_only_in_tests"} function test_golangci_lint { go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.58.1 @@ -86,6 +86,31 @@ function test_interface_compliance_nil { fi } +function test_import_testing_only_in_tests { + ROOT=$( git rev-parse --show-toplevel ) + NON_TEST_GO_FILES=$( find "${ROOT}" -iname '*.go' ! -iname '*_test.go'); + + IMPORT_TESTING=$( echo "${NON_TEST_GO_FILES}" | xargs grep -lP '^\s*(import\s+)?"testing"'); + IMPORT_TESTIFY=$( echo "${NON_TEST_GO_FILES}" | xargs grep -l '"github.com/stretchr/testify'); + # TODO(arr4n): send a PR to add support for build tags in `mockgen` and then enable this. + # IMPORT_GOMOCK=$( echo "${NON_TEST_GO_FILES}" | xargs grep -l '"go.uber.org/mock'); + HAVE_TEST_LOGIC=$( printf "%s\n%s" "${IMPORT_TESTING}" "${IMPORT_TESTIFY}" ); + + TAGGED_AS_TEST=$( echo "${NON_TEST_GO_FILES}" | xargs grep -lP '^\/\/go:build\s+(.+(,|\s+))?test[,\s]?'); + + # -3 suppresses files that have test logic and have the "test" build tag + # -2 suppresses files that are tagged despite not having detectable test logic + UNTAGGED=$( comm -23 <( echo "${HAVE_TEST_LOGIC}" | sort -u ) <( echo "${TAGGED_AS_TEST}" | sort -u ) ); + if [ -z "${UNTAGGED}" ]; + then + return 0; + fi + + echo "Non-test Go files importing test-only packages MUST have '//go:build test' tag:"; + echo "${UNTAGGED}"; + return 1; +} + function run { local test="${1}" shift 1 diff --git a/scripts/tests.e2e.existing.sh b/scripts/tests.e2e.existing.sh index 4b28fc1ad271..dbe41ec003d1 100755 --- a/scripts/tests.e2e.existing.sh +++ b/scripts/tests.e2e.existing.sh @@ -22,7 +22,7 @@ function print_separator { function cleanup { print_separator echo "cleaning up reusable network" - ginkgo -v ./tests/e2e/e2e.test -- --stop-network + ginkgo -v --tags test ./tests/e2e/e2e.test -- --stop-network } trap cleanup EXIT diff --git a/scripts/tests.e2e.sh b/scripts/tests.e2e.sh index 564116b40fda..efc1889af5ac 100755 --- a/scripts/tests.e2e.sh +++ b/scripts/tests.e2e.sh @@ -23,7 +23,7 @@ source ./scripts/constants.sh echo "building e2e.test" # to install the ginkgo binary (required for test build and run) go install -v github.com/onsi/ginkgo/v2/ginkgo@v2.13.1 -ACK_GINKGO_RC=true ginkgo build ./tests/e2e +ACK_GINKGO_RC=true ginkgo build --tags test ./tests/e2e ./tests/e2e/e2e.test --help # Enable subnet testing by building xsvm @@ -57,4 +57,4 @@ fi ################################# # - Execute in random order to identify unwanted dependency -ginkgo ${GINKGO_ARGS} -v --randomize-all ./tests/e2e/e2e.test -- "${E2E_ARGS[@]}" "${@}" +ginkgo ${GINKGO_ARGS} -v --tags test --randomize-all ./tests/e2e/e2e.test -- "${E2E_ARGS[@]}" "${@}" diff --git a/scripts/tests.upgrade.sh b/scripts/tests.upgrade.sh index 8cc158d87d49..1adab23248b9 100755 --- a/scripts/tests.upgrade.sh +++ b/scripts/tests.upgrade.sh @@ -66,7 +66,7 @@ source ./scripts/constants.sh echo "building upgrade.test" # to install the ginkgo binary (required for test build and run) go install -v github.com/onsi/ginkgo/v2/ginkgo@v2.13.1 -ACK_GINKGO_RC=true ginkgo build ./tests/upgrade +ACK_GINKGO_RC=true ginkgo build --tags test ./tests/upgrade ./tests/upgrade/upgrade.test --help ################################# diff --git a/snow/consensus/snowball/test_snowflake.go b/snow/consensus/snowball/test_snowflake.go index 78ce95b27e3d..8688ee82c09b 100644 --- a/snow/consensus/snowball/test_snowflake.go +++ b/snow/consensus/snowball/test_snowflake.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package snowball import "testing" diff --git a/snow/engine/avalanche/bootstrap/queue/test_job.go b/snow/engine/avalanche/bootstrap/queue/test_job.go index 91a370b96d81..8884ee0a2357 100644 --- a/snow/engine/avalanche/bootstrap/queue/test_job.go +++ b/snow/engine/avalanche/bootstrap/queue/test_job.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package queue import ( diff --git a/snow/engine/avalanche/bootstrap/queue/test_parser.go b/snow/engine/avalanche/bootstrap/queue/test_parser.go index 1cc1cfd2973f..2787973d267e 100644 --- a/snow/engine/avalanche/bootstrap/queue/test_parser.go +++ b/snow/engine/avalanche/bootstrap/queue/test_parser.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package queue import ( diff --git a/snow/engine/avalanche/vertex/test_builder.go b/snow/engine/avalanche/vertex/test_builder.go index 534629372249..90d603fc10a9 100644 --- a/snow/engine/avalanche/vertex/test_builder.go +++ b/snow/engine/avalanche/vertex/test_builder.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package vertex import ( diff --git a/snow/engine/avalanche/vertex/test_manager.go b/snow/engine/avalanche/vertex/test_manager.go index 6954161cdd46..22bb6ce696eb 100644 --- a/snow/engine/avalanche/vertex/test_manager.go +++ b/snow/engine/avalanche/vertex/test_manager.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package vertex import "testing" diff --git a/snow/engine/avalanche/vertex/test_parser.go b/snow/engine/avalanche/vertex/test_parser.go index 2ee10add6090..d3c2b0b8d8a2 100644 --- a/snow/engine/avalanche/vertex/test_parser.go +++ b/snow/engine/avalanche/vertex/test_parser.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package vertex import ( diff --git a/snow/engine/avalanche/vertex/test_storage.go b/snow/engine/avalanche/vertex/test_storage.go index 8e0b8bc1e84d..3e00dbdda879 100644 --- a/snow/engine/avalanche/vertex/test_storage.go +++ b/snow/engine/avalanche/vertex/test_storage.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package vertex import ( diff --git a/snow/engine/avalanche/vertex/test_vm.go b/snow/engine/avalanche/vertex/test_vm.go index ee17c8b13ae0..49948b81d516 100644 --- a/snow/engine/avalanche/vertex/test_vm.go +++ b/snow/engine/avalanche/vertex/test_vm.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package vertex import ( diff --git a/snow/engine/common/test_bootstrap_tracker.go b/snow/engine/common/test_bootstrap_tracker.go index 2e940f1a43b1..59aea61c5549 100644 --- a/snow/engine/common/test_bootstrap_tracker.go +++ b/snow/engine/common/test_bootstrap_tracker.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package common import ( diff --git a/snow/engine/common/test_bootstrapper.go b/snow/engine/common/test_bootstrapper.go index 259fcb07fb3e..ae1aef57abdf 100644 --- a/snow/engine/common/test_bootstrapper.go +++ b/snow/engine/common/test_bootstrapper.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package common import ( diff --git a/snow/engine/common/test_engine.go b/snow/engine/common/test_engine.go index e07352d43713..80470fa0509c 100644 --- a/snow/engine/common/test_engine.go +++ b/snow/engine/common/test_engine.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package common import ( diff --git a/snow/engine/common/test_sender.go b/snow/engine/common/test_sender.go index e3cb44165c54..9f4e5689751d 100644 --- a/snow/engine/common/test_sender.go +++ b/snow/engine/common/test_sender.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package common import ( diff --git a/snow/engine/common/test_timer.go b/snow/engine/common/test_timer.go index 6da0d9251712..c189dd15c237 100644 --- a/snow/engine/common/test_timer.go +++ b/snow/engine/common/test_timer.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package common import ( diff --git a/snow/engine/common/test_vm.go b/snow/engine/common/test_vm.go index 828b49f5e1fe..bbad058e13ff 100644 --- a/snow/engine/common/test_vm.go +++ b/snow/engine/common/test_vm.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package common import ( diff --git a/snow/engine/snowman/block/test_batched_vm.go b/snow/engine/snowman/block/test_batched_vm.go index e5d654ec4a87..92e766b86137 100644 --- a/snow/engine/snowman/block/test_batched_vm.go +++ b/snow/engine/snowman/block/test_batched_vm.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package block import ( diff --git a/snow/engine/snowman/block/test_state_summary.go b/snow/engine/snowman/block/test_state_summary.go index 7287cff10120..5921acb3e8dc 100644 --- a/snow/engine/snowman/block/test_state_summary.go +++ b/snow/engine/snowman/block/test_state_summary.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package block import ( diff --git a/snow/engine/snowman/block/test_state_syncable_vm.go b/snow/engine/snowman/block/test_state_syncable_vm.go index f1eeb9606642..2bf5fe425941 100644 --- a/snow/engine/snowman/block/test_state_syncable_vm.go +++ b/snow/engine/snowman/block/test_state_syncable_vm.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package block import ( diff --git a/snow/engine/snowman/block/test_vm.go b/snow/engine/snowman/block/test_vm.go index 503d3f9d4851..cdbeabacc4f1 100644 --- a/snow/engine/snowman/block/test_vm.go +++ b/snow/engine/snowman/block/test_vm.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package block import ( diff --git a/snow/networking/benchlist/test_benchable.go b/snow/networking/benchlist/test_benchable.go index dabfab564829..57a611a3765a 100644 --- a/snow/networking/benchlist/test_benchable.go +++ b/snow/networking/benchlist/test_benchable.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package benchlist import ( diff --git a/snow/networking/sender/test_external_sender.go b/snow/networking/sender/test_external_sender.go index 3d5e688492b9..da91edb54db1 100644 --- a/snow/networking/sender/test_external_sender.go +++ b/snow/networking/sender/test_external_sender.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package sender import ( diff --git a/snow/snowtest/snowtest.go b/snow/snowtest/snowtest.go index 3cacc8e873bf..be08ae75b21e 100644 --- a/snow/snowtest/snowtest.go +++ b/snow/snowtest/snowtest.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package snowtest import ( diff --git a/snow/validators/test_state.go b/snow/validators/test_state.go index ee4102cf7194..378f3e8a8780 100644 --- a/snow/validators/test_state.go +++ b/snow/validators/test_state.go @@ -1,6 +1,9 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +// TODO: https://github.com/ava-labs/avalanchego/issues/3174 +//go:build test || !test + package validators import ( diff --git a/tests/e2e/banff/suites.go b/tests/e2e/banff/suites.go index b6da324c98ea..1f61eaa7ad92 100644 --- a/tests/e2e/banff/suites.go +++ b/tests/e2e/banff/suites.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + // Implements tests for the banff network upgrade. package banff diff --git a/tests/e2e/c/dynamic_fees.go b/tests/e2e/c/dynamic_fees.go index c3dda77b985c..8a65ca910667 100644 --- a/tests/e2e/c/dynamic_fees.go +++ b/tests/e2e/c/dynamic_fees.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package c import ( diff --git a/tests/e2e/c/interchain_workflow.go b/tests/e2e/c/interchain_workflow.go index bfb342818a5f..89330ccd68a7 100644 --- a/tests/e2e/c/interchain_workflow.go +++ b/tests/e2e/c/interchain_workflow.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package c import ( diff --git a/tests/e2e/faultinjection/duplicate_node_id.go b/tests/e2e/faultinjection/duplicate_node_id.go index 288583c7e09b..13daafad2b86 100644 --- a/tests/e2e/faultinjection/duplicate_node_id.go +++ b/tests/e2e/faultinjection/duplicate_node_id.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package faultinjection import ( diff --git a/tests/e2e/p/interchain_workflow.go b/tests/e2e/p/interchain_workflow.go index 548c82ac1211..c74a7d6757eb 100644 --- a/tests/e2e/p/interchain_workflow.go +++ b/tests/e2e/p/interchain_workflow.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package p import ( diff --git a/tests/e2e/p/permissionless_subnets.go b/tests/e2e/p/permissionless_subnets.go index dc92bdd60d5c..4e91569e9256 100644 --- a/tests/e2e/p/permissionless_subnets.go +++ b/tests/e2e/p/permissionless_subnets.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package p import ( diff --git a/tests/e2e/p/staking_rewards.go b/tests/e2e/p/staking_rewards.go index e988cf43c2c4..7e8178c53a32 100644 --- a/tests/e2e/p/staking_rewards.go +++ b/tests/e2e/p/staking_rewards.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package p import ( diff --git a/tests/e2e/p/validator_sets.go b/tests/e2e/p/validator_sets.go index a3f3e1e9f075..6ecbe42d1452 100644 --- a/tests/e2e/p/validator_sets.go +++ b/tests/e2e/p/validator_sets.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package p import ( diff --git a/tests/e2e/p/workflow.go b/tests/e2e/p/workflow.go index 3708c6b82c0a..c4e597d27263 100644 --- a/tests/e2e/p/workflow.go +++ b/tests/e2e/p/workflow.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package p import ( diff --git a/tests/e2e/vms/xsvm.go b/tests/e2e/vms/xsvm.go index 5d3557acd405..b7ac0dc0b0b9 100644 --- a/tests/e2e/vms/xsvm.go +++ b/tests/e2e/vms/xsvm.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package vms import ( diff --git a/tests/e2e/x/interchain_workflow.go b/tests/e2e/x/interchain_workflow.go index ecc52f41f032..c096b6e39228 100644 --- a/tests/e2e/x/interchain_workflow.go +++ b/tests/e2e/x/interchain_workflow.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package x import ( diff --git a/tests/e2e/x/transfer/virtuous.go b/tests/e2e/x/transfer/virtuous.go index 58a0351ba123..5e6ed2a90b98 100644 --- a/tests/e2e/x/transfer/virtuous.go +++ b/tests/e2e/x/transfer/virtuous.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + // Implements X-chain transfer tests. package transfer diff --git a/tests/fixture/e2e/env.go b/tests/fixture/e2e/env.go index 05fbbd97ac86..f56b9e9bce03 100644 --- a/tests/fixture/e2e/env.go +++ b/tests/fixture/e2e/env.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package e2e import ( diff --git a/tests/fixture/e2e/helpers.go b/tests/fixture/e2e/helpers.go index 6f6e5382dc7a..9bc773cbd6c1 100644 --- a/tests/fixture/e2e/helpers.go +++ b/tests/fixture/e2e/helpers.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package e2e import ( diff --git a/vms/platformvm/warp/test_signer.go b/vms/platformvm/warp/test_signer.go index e30423edf1ed..3cd3802af3f9 100644 --- a/vms/platformvm/warp/test_signer.go +++ b/vms/platformvm/warp/test_signer.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package warp import ( diff --git a/wallet/subnet/primary/common/test_utxos.go b/wallet/subnet/primary/common/test_utxos.go index 094c57d53705..0ab6b6decb8f 100644 --- a/wallet/subnet/primary/common/test_utxos.go +++ b/wallet/subnet/primary/common/test_utxos.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package common import (