diff --git a/pkg/appgateserver/config/appgate_configs_reader_test.go b/pkg/appgateserver/config/appgate_configs_reader_test.go index 82ee6e53f..bc2c88472 100644 --- a/pkg/appgateserver/config/appgate_configs_reader_test.go +++ b/pkg/appgateserver/config/appgate_configs_reader_test.go @@ -18,7 +18,7 @@ func Test_ParseAppGateConfigs(t *testing.T) { inputConfigYAML string - expectedError *sdkerrors.Error + expectedErr *sdkerrors.Error expectedConfig *config.AppGateServerConfig }{ // Valid Configs @@ -33,7 +33,7 @@ func Test_ParseAppGateConfigs(t *testing.T) { listening_endpoint: http://localhost:42069 `, - expectedError: nil, + expectedErr: nil, expectedConfig: &config.AppGateServerConfig{ QueryNodeRPCUrl: &url.URL{Scheme: "tcp", Host: "127.0.0.1:36657"}, QueryNodeGRPCUrl: &url.URL{Scheme: "tcp", Host: "127.0.0.1:36658"}, @@ -52,7 +52,7 @@ func Test_ParseAppGateConfigs(t *testing.T) { listening_endpoint: http://localhost:42069 `, - expectedError: nil, + expectedErr: nil, expectedConfig: &config.AppGateServerConfig{ QueryNodeRPCUrl: &url.URL{Scheme: "tcp", Host: "127.0.0.1:36657"}, QueryNodeGRPCUrl: &url.URL{Scheme: "tcp", Host: "127.0.0.1:36658"}, @@ -67,7 +67,7 @@ func Test_ParseAppGateConfigs(t *testing.T) { inputConfigYAML: ``, - expectedError: config.ErrAppGateConfigEmpty, + expectedErr: config.ErrAppGateConfigEmpty, }, { desc: "invalid: no signing key", @@ -80,7 +80,7 @@ func Test_ParseAppGateConfigs(t *testing.T) { listening_endpoint: http://localhost:42069 `, - expectedError: config.ErrAppGateConfigEmptySigningKey, + expectedErr: config.ErrAppGateConfigEmptySigningKey, }, { desc: "invalid: invalid listening endpoint", @@ -93,7 +93,7 @@ func Test_ParseAppGateConfigs(t *testing.T) { listening_endpoint: l&ocalhost:42069 `, - expectedError: config.ErrAppGateConfigInvalidListeningEndpoint, + expectedErr: config.ErrAppGateConfigInvalidListeningEndpoint, }, { desc: "invalid: invalid query node grpc url", @@ -106,7 +106,7 @@ func Test_ParseAppGateConfigs(t *testing.T) { listening_endpoint: http://localhost:42069 `, - expectedError: config.ErrAppGateConfigInvalidQueryNodeGRPCUrl, + expectedErr: config.ErrAppGateConfigInvalidQueryNodeGRPCUrl, }, { desc: "invalid: missing query node grpc url", @@ -119,7 +119,7 @@ func Test_ParseAppGateConfigs(t *testing.T) { listening_endpoint: http://localhost:42069 `, - expectedError: config.ErrAppGateConfigInvalidQueryNodeGRPCUrl, + expectedErr: config.ErrAppGateConfigInvalidQueryNodeGRPCUrl, }, { desc: "invalid: invalid query node rpc url", @@ -132,7 +132,7 @@ func Test_ParseAppGateConfigs(t *testing.T) { listening_endpoint: http://localhost:42069 `, - expectedError: config.ErrAppGateConfigInvalidQueryNodeRPCUrl, + expectedErr: config.ErrAppGateConfigInvalidQueryNodeRPCUrl, }, { desc: "invalid: missing query node rpc url", @@ -145,32 +145,32 @@ func Test_ParseAppGateConfigs(t *testing.T) { listening_endpoint: http://localhost:42069 `, - expectedError: config.ErrAppGateConfigInvalidQueryNodeRPCUrl, + expectedErr: config.ErrAppGateConfigInvalidQueryNodeRPCUrl, }, } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - normalizedConfig := yaml.NormalizeYAMLIndentation(tt.inputConfigYAML) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + normalizedConfig := yaml.NormalizeYAMLIndentation(test.inputConfigYAML) config, err := config.ParseAppGateServerConfigs([]byte(normalizedConfig)) - if tt.expectedError != nil { - require.ErrorIs(t, err, tt.expectedError) + if test.expectedErr != nil { + require.ErrorIs(t, err, test.expectedErr) require.Nil(t, config) - stat, ok := status.FromError(tt.expectedError) + stat, ok := status.FromError(test.expectedErr) require.True(t, ok) - require.Contains(t, stat.Message(), tt.expectedError.Error()) + require.Contains(t, stat.Message(), test.expectedErr.Error()) require.Nil(t, config) return } require.NoError(t, err) - require.Equal(t, tt.expectedConfig.SelfSigning, config.SelfSigning) - require.Equal(t, tt.expectedConfig.SigningKey, config.SigningKey) - require.Equal(t, tt.expectedConfig.ListeningEndpoint.String(), config.ListeningEndpoint.String()) - require.Equal(t, tt.expectedConfig.QueryNodeGRPCUrl.String(), config.QueryNodeGRPCUrl.String()) - require.Equal(t, tt.expectedConfig.QueryNodeGRPCUrl.String(), config.QueryNodeGRPCUrl.String()) + require.Equal(t, test.expectedConfig.SelfSigning, config.SelfSigning) + require.Equal(t, test.expectedConfig.SigningKey, config.SigningKey) + require.Equal(t, test.expectedConfig.ListeningEndpoint.String(), config.ListeningEndpoint.String()) + require.Equal(t, test.expectedConfig.QueryNodeGRPCUrl.String(), config.QueryNodeGRPCUrl.String()) + require.Equal(t, test.expectedConfig.QueryNodeGRPCUrl.String(), config.QueryNodeGRPCUrl.String()) }) } } diff --git a/pkg/appgateserver/config/errors.go b/pkg/appgateserver/config/errors.go index 450c75378..882c70a18 100644 --- a/pkg/appgateserver/config/errors.go +++ b/pkg/appgateserver/config/errors.go @@ -4,10 +4,10 @@ import sdkerrors "cosmossdk.io/errors" var ( codespace = "appgate_config" - ErrAppGateConfigUnmarshalYAML = sdkerrors.Register(codespace, 1, "config reader cannot unmarshal yaml content") - ErrAppGateConfigEmptySigningKey = sdkerrors.Register(codespace, 2, "empty signing key in AppGateServer config") - ErrAppGateConfigInvalidListeningEndpoint = sdkerrors.Register(codespace, 3, "invalid listening endpoint in AppGateServer config") - ErrAppGateConfigInvalidQueryNodeGRPCUrl = sdkerrors.Register(codespace, 4, "invalid query node grpc url in AppGateServer config") - ErrAppGateConfigInvalidQueryNodeRPCUrl = sdkerrors.Register(codespace, 5, "invalid query node rpc url in AppGateServer config") - ErrAppGateConfigEmpty = sdkerrors.Register(codespace, 6, "empty AppGateServer config") + ErrAppGateConfigUnmarshalYAML = sdkerrors.Register(codespace, 2100, "config reader cannot unmarshal yaml content") + ErrAppGateConfigEmptySigningKey = sdkerrors.Register(codespace, 2101, "empty signing key in AppGateServer config") + ErrAppGateConfigInvalidListeningEndpoint = sdkerrors.Register(codespace, 2102, "invalid listening endpoint in AppGateServer config") + ErrAppGateConfigInvalidQueryNodeGRPCUrl = sdkerrors.Register(codespace, 2103, "invalid query node grpc url in AppGateServer config") + ErrAppGateConfigInvalidQueryNodeRPCUrl = sdkerrors.Register(codespace, 2104, "invalid query node rpc url in AppGateServer config") + ErrAppGateConfigEmpty = sdkerrors.Register(codespace, 2105, "empty AppGateServer config") ) diff --git a/pkg/appgateserver/options.go b/pkg/appgateserver/options.go index fb164029b..890e6c5bf 100644 --- a/pkg/appgateserver/options.go +++ b/pkg/appgateserver/options.go @@ -1,8 +1,6 @@ package appgateserver -import ( - "net/url" -) +import "net/url" // WithSigningInformation sets the signing information for the appgate server. func WithSigningInformation(signingInfo *SigningInformation) appGateServerOption { diff --git a/pkg/client/block/client_test.go b/pkg/client/block/client_test.go index 862bed75e..b50dd05b8 100644 --- a/pkg/client/block/client_test.go +++ b/pkg/client/block/client_test.go @@ -92,8 +92,8 @@ func TestBlockClient(t *testing.T) { }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { actualBlockCh := make(chan client.Block, 10) // Run test functions asynchronously because they can block, leading @@ -102,7 +102,7 @@ func TestBlockClient(t *testing.T) { go func(fn func() client.Block) { actualBlockCh <- fn() close(actualBlockCh) - }(tt.fn) + }(test.fn) select { case actualBlock := <-actualBlockCh: diff --git a/pkg/client/delegation/client_test.go b/pkg/client/delegation/client_test.go index f9b82ffb5..d34f53118 100644 --- a/pkg/client/delegation/client_test.go +++ b/pkg/client/delegation/client_test.go @@ -74,8 +74,8 @@ func TestDelegationClient(t *testing.T) { }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { actualRedelegationCh := make(chan client.Redelegation, 10) // Run test functions asynchronously because they can block, leading @@ -84,7 +84,7 @@ func TestDelegationClient(t *testing.T) { go func(fn func() client.Redelegation) { actualRedelegationCh <- fn() close(actualRedelegationCh) - }(tt.fn) + }(test.fn) select { case actualRedelegation := <-actualRedelegationCh: diff --git a/pkg/client/events/errors.go b/pkg/client/events/errors.go index 838b9dbec..abca55a84 100644 --- a/pkg/client/events/errors.go +++ b/pkg/client/events/errors.go @@ -1,8 +1,6 @@ package events -import ( - sdkerrors "cosmossdk.io/errors" -) +import sdkerrors "cosmossdk.io/errors" var ( codespace = "events" diff --git a/pkg/client/events/websocket/errors.go b/pkg/client/events/websocket/errors.go index 85f8953fd..710f25fd0 100644 --- a/pkg/client/events/websocket/errors.go +++ b/pkg/client/events/websocket/errors.go @@ -1,8 +1,6 @@ package websocket -import ( - sdkerrors "cosmossdk.io/errors" -) +import sdkerrors "cosmossdk.io/errors" var ( codespace = "events_query_client_websocket_connection" diff --git a/pkg/client/query/appquerier.go b/pkg/client/query/appquerier.go index 9998a64f7..9477c35f9 100644 --- a/pkg/client/query/appquerier.go +++ b/pkg/client/query/appquerier.go @@ -55,10 +55,10 @@ func (aq *appQuerier) GetApplication( // GetAllApplications returns all staked applications func (aq *appQuerier) GetAllApplications(ctx context.Context) ([]apptypes.Application, error) { - req := apptypes.QueryAllApplicationRequest{} - res, err := aq.applicationQuerier.ApplicationAll(ctx, &req) + req := apptypes.QueryAllApplicationsRequest{} + res, err := aq.applicationQuerier.AllApplications(ctx, &req) if err != nil { return []apptypes.Application{}, err } - return res.Application, nil + return res.Applications, nil } diff --git a/pkg/client/query/errors.go b/pkg/client/query/errors.go index f395a9997..7d28cff84 100644 --- a/pkg/client/query/errors.go +++ b/pkg/client/query/errors.go @@ -1,8 +1,6 @@ package query -import ( - sdkerrors "cosmossdk.io/errors" -) +import sdkerrors "cosmossdk.io/errors" var ( codespace = "query" diff --git a/pkg/client/query/types/context.go b/pkg/client/query/types/context.go index d0f56fe6f..1af9d02c7 100644 --- a/pkg/client/query/types/context.go +++ b/pkg/client/query/types/context.go @@ -1,8 +1,6 @@ package types -import ( - cosmosclient "github.com/cosmos/cosmos-sdk/client" -) +import cosmosclient "github.com/cosmos/cosmos-sdk/client" // Context is used to distinguish a cosmosclient.Context intended for use in // queries from others. This is because the same cosmosclient.Context can be diff --git a/pkg/client/supplier/client_test.go b/pkg/client/supplier/client_test.go index b40fc3430..03fc27567 100644 --- a/pkg/client/supplier/client_test.go +++ b/pkg/client/supplier/client_test.go @@ -60,13 +60,13 @@ func TestNewSupplierClient(t *testing.T) { }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - signingKeyOpt := supplier.WithSigningKeyName(tt.signingKeyName) + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + signingKeyOpt := supplier.WithSigningKeyName(test.signingKeyName) supplierClient, err := supplier.NewSupplierClient(deps, signingKeyOpt) - if tt.expectedErr != nil { - require.ErrorIs(t, err, tt.expectedErr) + if test.expectedErr != nil { + require.ErrorIs(t, err, test.expectedErr) require.Nil(t, supplierClient) } else { require.NoError(t, err) diff --git a/pkg/client/supplier/options.go b/pkg/client/supplier/options.go index f4460c8c9..424cf7420 100644 --- a/pkg/client/supplier/options.go +++ b/pkg/client/supplier/options.go @@ -1,8 +1,6 @@ package supplier -import ( - "github.com/pokt-network/poktroll/pkg/client" -) +import "github.com/pokt-network/poktroll/pkg/client" // WithSigningKeyName sets the name of the key which the supplier client should // retrieve from the keyring to use for authoring and signing CreateClaim and diff --git a/pkg/client/tx/client_test.go b/pkg/client/tx/client_test.go index bfefbc3a6..86e7de0a2 100644 --- a/pkg/client/tx/client_test.go +++ b/pkg/client/tx/client_test.go @@ -165,8 +165,8 @@ func TestTxClient_NewTxClient_Error(t *testing.T) { // }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { var ( ctrl = gomock.NewController(t) ctx = context.Background() @@ -192,11 +192,11 @@ func TestTxClient_NewTxClient_Error(t *testing.T) { ) // Construct a signing key option using the test signing key name. - signingKeyOpt := tx.WithSigningKeyName(tt.signingKeyName) + signingKeyOpt := tx.WithSigningKeyName(test.signingKeyName) // Attempt to create the transactions client. txClient, err := tx.NewTxClient(ctx, txClientDeps, signingKeyOpt) - require.ErrorIs(t, err, tt.expectedErr) + require.ErrorIs(t, err, test.expectedErr) require.Nil(t, txClient) }) } diff --git a/pkg/client/tx/options.go b/pkg/client/tx/options.go index 34e782b6d..5364008a5 100644 --- a/pkg/client/tx/options.go +++ b/pkg/client/tx/options.go @@ -1,8 +1,6 @@ package tx -import ( - "github.com/pokt-network/poktroll/pkg/client" -) +import "github.com/pokt-network/poktroll/pkg/client" // WithCommitTimeoutBlocks sets the timeout duration in terms of number of blocks // for the client to wait for broadcast transactions to be committed before diff --git a/pkg/client/tx/types/context.go b/pkg/client/tx/types/context.go index 7dd15cd7f..73723b011 100644 --- a/pkg/client/tx/types/context.go +++ b/pkg/client/tx/types/context.go @@ -1,8 +1,6 @@ package types -import ( - cosmosclient "github.com/cosmos/cosmos-sdk/client" -) +import cosmosclient "github.com/cosmos/cosmos-sdk/client" // Context is used to distinguish a cosmosclient.Context intended for use in // transactions from others. This is because the same cosmosclient.Context can diff --git a/pkg/crypto/rings/errors.go b/pkg/crypto/rings/errors.go index 8aae1ad9d..cd85b519b 100644 --- a/pkg/crypto/rings/errors.go +++ b/pkg/crypto/rings/errors.go @@ -1,8 +1,6 @@ package rings -import ( - sdkerrors "cosmossdk.io/errors" -) +import sdkerrors "cosmossdk.io/errors" var ( codespace = "rings" diff --git a/pkg/observable/channel/map_test.go b/pkg/observable/channel/map_test.go index aa7507a71..e12c3f9c7 100644 --- a/pkg/observable/channel/map_test.go +++ b/pkg/observable/channel/map_test.go @@ -29,8 +29,8 @@ func TestMap_Word_BytesToPalindrome(t *testing.T) { }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { var ( wordCounter int32 ctx, cancel = context.WithCancel(context.Background()) @@ -45,7 +45,7 @@ func TestMap_Word_BytesToPalindrome(t *testing.T) { palindromeObserver := palindromeObservable.Subscribe(ctx) // publish a word in bytes - bzPublishCh <- tt.wordBz + bzPublishCh <- test.wordBz // concurrently consume the palindrome observer's channel go func() { @@ -53,13 +53,13 @@ func TestMap_Word_BytesToPalindrome(t *testing.T) { atomic.AddInt32(&wordCounter, 1) // word.forwards should always match the original word - require.Equal(t, string(tt.wordBz), word.forwards) + require.Equal(t, string(test.wordBz), word.forwards) - if tt.isValid { - require.Equal(t, string(tt.wordBz), word.backwards) + if test.isValid { + require.Equal(t, string(test.wordBz), word.backwards) require.Truef(t, word.IsValid(), "palindrome should be valid") } else { - require.NotEmptyf(t, string(tt.wordBz), word.backwards) + require.NotEmptyf(t, string(test.wordBz), word.backwards) require.Falsef(t, word.IsValid(), "palindrome should be invalid") } } diff --git a/pkg/observable/channel/observable_test.go b/pkg/observable/channel/observable_test.go index b278546fc..0f017ae83 100644 --- a/pkg/observable/channel/observable_test.go +++ b/pkg/observable/channel/observable_test.go @@ -92,17 +92,17 @@ func TestChannelObservable_NotifyObservers(t *testing.T) { // }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.setupFn != nil { - tt.setupFn(tt) + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + if test.setupFn != nil { + test.setupFn(test) } ctx, cancel := context.WithCancel(context.Background()) t.Cleanup(cancel) obsvbl, publishCh := channel.NewObservable[int]( - channel.WithPublisher(tt.publishCh), + channel.WithPublisher(test.publishCh), ) require.NotNil(t, obsvbl) require.NotNil(t, publishCh) @@ -121,7 +121,7 @@ func TestChannelObservable_NotifyObservers(t *testing.T) { onNext := func(outputIndex int, output int) error { // obsvr channel should receive notified input if !assert.Equalf( - t, tt.expectedOutputs[outputIndex], + t, test.expectedOutputs[outputIndex], output, "obsvr Idx: %d", obsvrIdx, ) { @@ -133,7 +133,7 @@ func TestChannelObservable_NotifyObservers(t *testing.T) { // onDone is called when the observer channel closes onDone := func(outputs []int) error { if !assert.ElementsMatch( - t, tt.expectedOutputs, outputs, + t, test.expectedOutputs, outputs, "obsvr addr: %p", obsvr, ) { return testerrors.ErrAsync @@ -148,7 +148,7 @@ func TestChannelObservable_NotifyObservers(t *testing.T) { // notify with test input publish := delayedPublishFactory(publishCh, publishDelay) - for _, input := range tt.inputs { + for _, input := range test.inputs { // simulating IO delay in sequential message publishing publish(input) } @@ -234,9 +234,9 @@ func TestChannelObservable_UnsubscribeObservers(t *testing.T) { }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - observer := tt.lifecycleFn() + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + observer := test.lifecycleFn() select { case value, ok := <-observer.Ch(): diff --git a/pkg/observable/channel/replay_test.go b/pkg/observable/channel/replay_test.go index 6e01f123e..8a06b9161 100644 --- a/pkg/observable/channel/replay_test.go +++ b/pkg/observable/channel/replay_test.go @@ -127,20 +127,20 @@ func TestReplayObservable_Last_Full_ReplayBuffer(t *testing.T) { }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { var ctx = context.Background() replayObsvbl, publishCh := - channel.NewReplayObservable[int](ctx, tt.replayBufferSize) + channel.NewReplayObservable[int](ctx, test.replayBufferSize) for _, value := range values { publishCh <- value time.Sleep(time.Millisecond) } - actualValues := replayObsvbl.Last(ctx, tt.lastN) - require.ElementsMatch(t, tt.expectedValues, actualValues) + actualValues := replayObsvbl.Last(ctx, test.lastN) + require.ElementsMatch(t, test.expectedValues, actualValues) }) } } diff --git a/pkg/partials/errors.go b/pkg/partials/errors.go index 8f3d84885..887a3f34c 100644 --- a/pkg/partials/errors.go +++ b/pkg/partials/errors.go @@ -1,8 +1,6 @@ package partials -import ( - sdkerrors "cosmossdk.io/errors" -) +import sdkerrors "cosmossdk.io/errors" var ( codespace = "partial" diff --git a/pkg/relayer/config/errors.go b/pkg/relayer/config/errors.go index eace596e3..16544e209 100644 --- a/pkg/relayer/config/errors.go +++ b/pkg/relayer/config/errors.go @@ -4,11 +4,11 @@ import sdkerrors "cosmossdk.io/errors" var ( codespace = "relayminer_config" - ErrRelayMinerConfigUnmarshalYAML = sdkerrors.Register(codespace, 1, "config reader cannot unmarshal yaml content") - ErrRelayMinerConfigInvalidNodeUrl = sdkerrors.Register(codespace, 2, "invalid node url in RelayMiner config") - ErrRelayMinerConfigInvalidSigningKeyName = sdkerrors.Register(codespace, 3, "invalid signing key name in RelayMiner config") - ErrRelayMinerConfigInvalidSmtStorePath = sdkerrors.Register(codespace, 4, "invalid smt store path in RelayMiner config") - ErrRelayMinerConfigEmpty = sdkerrors.Register(codespace, 5, "empty RelayMiner config") - ErrRelayMinerConfigInvalidSupplier = sdkerrors.Register(codespace, 6, "invalid supplier in RelayMiner config") - ErrRelayMinerConfigInvalidProxy = sdkerrors.Register(codespace, 7, "invalid proxy in RelayMiner config") + ErrRelayMinerConfigUnmarshalYAML = sdkerrors.Register(codespace, 2100, "config reader cannot unmarshal yaml content") + ErrRelayMinerConfigInvalidNodeUrl = sdkerrors.Register(codespace, 2101, "invalid node url in RelayMiner config") + ErrRelayMinerConfigInvalidSigningKeyName = sdkerrors.Register(codespace, 2102, "invalid signing key name in RelayMiner config") + ErrRelayMinerConfigInvalidSmtStorePath = sdkerrors.Register(codespace, 2103, "invalid smt store path in RelayMiner config") + ErrRelayMinerConfigEmpty = sdkerrors.Register(codespace, 2104, "empty RelayMiner config") + ErrRelayMinerConfigInvalidSupplier = sdkerrors.Register(codespace, 2105, "invalid supplier in RelayMiner config") + ErrRelayMinerConfigInvalidProxy = sdkerrors.Register(codespace, 2106, "invalid proxy in RelayMiner config") ) diff --git a/pkg/relayer/config/relayminer_configs_reader_test.go b/pkg/relayer/config/relayminer_configs_reader_test.go index 6b8bc3c60..777e908da 100644 --- a/pkg/relayer/config/relayminer_configs_reader_test.go +++ b/pkg/relayer/config/relayminer_configs_reader_test.go @@ -18,7 +18,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { inputConfigYAML string - expectedError *sdkerrors.Error + expectedErr *sdkerrors.Error expectedConfig *config.RelayMinerConfig }{ // Valid Configs @@ -52,7 +52,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: nil, + expectedErr: nil, expectedConfig: &config.RelayMinerConfig{ PocketNode: &config.RelayMinerPocketNodeConfig{ QueryNodeRPCUrl: &url.URL{Scheme: "tcp", Host: "127.0.0.1:36657"}, @@ -127,7 +127,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: nil, + expectedErr: nil, expectedConfig: &config.RelayMinerConfig{ PocketNode: &config.RelayMinerPocketNodeConfig{ QueryNodeRPCUrl: &url.URL{Scheme: "tcp", Host: "127.0.0.1:36657"}, @@ -204,7 +204,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - second-proxy `, - expectedError: nil, + expectedErr: nil, expectedConfig: &config.RelayMinerConfig{ PocketNode: &config.RelayMinerPocketNodeConfig{ QueryNodeRPCUrl: &url.URL{Scheme: "tcp", Host: "127.0.0.1:36657"}, @@ -278,7 +278,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: nil, + expectedErr: nil, expectedConfig: &config.RelayMinerConfig{ PocketNode: &config.RelayMinerPocketNodeConfig{ QueryNodeRPCUrl: &url.URL{Scheme: "tcp", Host: "127.0.0.1:36659"}, @@ -337,7 +337,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: nil, + expectedErr: nil, expectedConfig: &config.RelayMinerConfig{ PocketNode: &config.RelayMinerPocketNodeConfig{ QueryNodeRPCUrl: &url.URL{Scheme: "tcp", Host: "127.0.0.1:36657"}, @@ -395,7 +395,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidNodeUrl, + expectedErr: config.ErrRelayMinerConfigInvalidNodeUrl, }, { desc: "invalid: missing tx node grpc url", @@ -422,7 +422,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidNodeUrl, + expectedErr: config.ErrRelayMinerConfigInvalidNodeUrl, }, { desc: "invalid: invalid query node grpc url", @@ -449,7 +449,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidNodeUrl, + expectedErr: config.ErrRelayMinerConfigInvalidNodeUrl, }, { desc: "invalid: invalid query node rpc url", @@ -476,7 +476,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidNodeUrl, + expectedErr: config.ErrRelayMinerConfigInvalidNodeUrl, }, { desc: "invalid: missing query node grpc url", @@ -503,7 +503,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidNodeUrl, + expectedErr: config.ErrRelayMinerConfigInvalidNodeUrl, }, { desc: "invalid: missing signing key name", @@ -530,7 +530,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSigningKeyName, + expectedErr: config.ErrRelayMinerConfigInvalidSigningKeyName, }, { desc: "invalid: missing smt store path", @@ -557,7 +557,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSmtStorePath, + expectedErr: config.ErrRelayMinerConfigInvalidSmtStorePath, }, { desc: "invalid: missing proxies section", @@ -581,7 +581,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidProxy, + expectedErr: config.ErrRelayMinerConfigInvalidProxy, }, { desc: "invalid: empty proxies section", @@ -605,7 +605,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidProxy, + expectedErr: config.ErrRelayMinerConfigInvalidProxy, }, { desc: "invalid: omitted proxy name", @@ -632,7 +632,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidProxy, + expectedErr: config.ErrRelayMinerConfigInvalidProxy, }, { desc: "invalid: empty proxy name", @@ -659,7 +659,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidProxy, + expectedErr: config.ErrRelayMinerConfigInvalidProxy, }, { desc: "invalid: missing http proxy host", @@ -686,7 +686,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidProxy, + expectedErr: config.ErrRelayMinerConfigInvalidProxy, }, { desc: "invalid: empty http proxy host", @@ -713,7 +713,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidProxy, + expectedErr: config.ErrRelayMinerConfigInvalidProxy, }, { desc: "invalid: missing proxy type", @@ -740,7 +740,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidProxy, + expectedErr: config.ErrRelayMinerConfigInvalidProxy, }, { desc: "invalid: empty proxy type", @@ -767,7 +767,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidProxy, + expectedErr: config.ErrRelayMinerConfigInvalidProxy, }, { desc: "invalid: unsupported proxy type", @@ -794,7 +794,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidProxy, + expectedErr: config.ErrRelayMinerConfigInvalidProxy, }, { desc: "invalid: missing supplier name", @@ -821,7 +821,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: empty supplier name", @@ -848,7 +848,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: unsupported supplier type", @@ -875,7 +875,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: missing supplier type", @@ -902,7 +902,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: empty supplier type", @@ -929,7 +929,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: bad supplier service config url", @@ -956,7 +956,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: empty supplier service config url", @@ -983,7 +983,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: missing supplier service config url", @@ -1010,7 +1010,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: bad supplier host", @@ -1037,7 +1037,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: blank supplier host", @@ -1064,7 +1064,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: empty supplier proxy references", @@ -1091,7 +1091,7 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - bad-proxy-name `, - expectedError: config.ErrRelayMinerConfigInvalidSupplier, + expectedErr: config.ErrRelayMinerConfigInvalidSupplier, }, { desc: "invalid: empty supplier proxy references", @@ -1126,30 +1126,30 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { - http-example `, - expectedError: config.ErrRelayMinerConfigInvalidProxy, + expectedErr: config.ErrRelayMinerConfigInvalidProxy, }, { desc: "invalid: empty RelayMiner config file", inputConfigYAML: ``, - expectedError: config.ErrRelayMinerConfigEmpty, + expectedErr: config.ErrRelayMinerConfigEmpty, }, // TODO_NB: Test for supplier and proxy types mismatch once we have more // than one proxy type. } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - normalizedConfig := yaml.NormalizeYAMLIndentation(tt.inputConfigYAML) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + normalizedConfig := yaml.NormalizeYAMLIndentation(test.inputConfigYAML) config, err := config.ParseRelayMinerConfigs([]byte(normalizedConfig)) - if tt.expectedError != nil { - require.ErrorIs(t, err, tt.expectedError) + if test.expectedErr != nil { + require.ErrorIs(t, err, test.expectedErr) require.Nil(t, config) - stat, ok := status.FromError(tt.expectedError) + stat, ok := status.FromError(test.expectedErr) require.True(t, ok) - require.Contains(t, stat.Message(), tt.expectedError.Error()) + require.Contains(t, stat.Message(), test.expectedErr.Error()) require.Nil(t, config) return } @@ -1158,35 +1158,35 @@ func Test_ParseRelayMinerConfigs(t *testing.T) { require.Equal( t, - tt.expectedConfig.SigningKeyName, + test.expectedConfig.SigningKeyName, config.SigningKeyName, ) require.Equal( t, - tt.expectedConfig.SmtStorePath, + test.expectedConfig.SmtStorePath, config.SmtStorePath, ) require.Equal( t, - tt.expectedConfig.PocketNode.QueryNodeGRPCUrl.String(), + test.expectedConfig.PocketNode.QueryNodeGRPCUrl.String(), config.PocketNode.QueryNodeGRPCUrl.String(), ) require.Equal( t, - tt.expectedConfig.PocketNode.QueryNodeRPCUrl.String(), + test.expectedConfig.PocketNode.QueryNodeRPCUrl.String(), config.PocketNode.QueryNodeRPCUrl.String(), ) require.Equal( t, - tt.expectedConfig.PocketNode.TxNodeRPCUrl.String(), + test.expectedConfig.PocketNode.TxNodeRPCUrl.String(), config.PocketNode.TxNodeRPCUrl.String(), ) - for proxyName, proxy := range tt.expectedConfig.Proxies { + for proxyName, proxy := range test.expectedConfig.Proxies { require.Equal( t, proxy.ProxyName, diff --git a/pkg/relayer/protocol/difficulty.go b/pkg/relayer/protocol/difficulty.go index a33c4bac6..0d57c9158 100644 --- a/pkg/relayer/protocol/difficulty.go +++ b/pkg/relayer/protocol/difficulty.go @@ -1,8 +1,6 @@ package protocol -import ( - "math/bits" -) +import "math/bits" // TODO_BLOCKER: Revisit this part of the algorithm after initial TestNet Launch. // TODO_TEST: Add extensive tests for the core relay mining business logic. diff --git a/pkg/relayer/protocol/difficulty_test.go b/pkg/relayer/protocol/difficulty_test.go index ae5548634..8b5aad2d5 100644 --- a/pkg/relayer/protocol/difficulty_test.go +++ b/pkg/relayer/protocol/difficulty_test.go @@ -40,11 +40,11 @@ func TestCountDifficultyBits(t *testing.T) { }, } - for _, tt := range tests { - t.Run(fmt.Sprintf("difficulty_%d_zero_bits", tt.difficulty), func(t *testing.T) { - actualDifficulty, err := protocol.CountDifficultyBits(tt.bz) + for _, test := range tests { + t.Run(fmt.Sprintf("difficulty_%d_zero_bits", test.difficulty), func(t *testing.T) { + actualDifficulty, err := protocol.CountDifficultyBits(test.bz) require.NoError(t, err) - require.Equal(t, tt.difficulty, actualDifficulty) + require.Equal(t, test.difficulty, actualDifficulty) }) } } diff --git a/pkg/relayer/proxy/errors.go b/pkg/relayer/proxy/errors.go index 84604e836..5a4d81af7 100644 --- a/pkg/relayer/proxy/errors.go +++ b/pkg/relayer/proxy/errors.go @@ -1,8 +1,6 @@ package proxy -import ( - sdkerrors "cosmossdk.io/errors" -) +import sdkerrors "cosmossdk.io/errors" var ( codespace = "relayer_proxy" diff --git a/pkg/relayer/proxy/proxy_test.go b/pkg/relayer/proxy/proxy_test.go index 58ca8e3cc..5ddba5d5f 100644 --- a/pkg/relayer/proxy/proxy_test.go +++ b/pkg/relayer/proxy/proxy_test.go @@ -529,13 +529,13 @@ func TestRelayerProxy_Relays(t *testing.T) { } ctx := context.TODO() - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { ctx, cancel := context.WithCancel(ctx) - test := testproxy.NewRelayerProxyTestBehavior(ctx, t, tt.relayerProxyBehavior...) + testBehavior := testproxy.NewRelayerProxyTestBehavior(ctx, t, test.relayerProxyBehavior...) rp, err := proxy.NewRelayerProxy( - test.Deps, + testBehavior.Deps, proxy.WithSigningKeyName(supplierKeyName), proxy.WithProxiedServicesEndpoints(proxiedServices), ) @@ -545,9 +545,9 @@ func TestRelayerProxy_Relays(t *testing.T) { // Block so relayerProxy has sufficient time to start time.Sleep(100 * time.Millisecond) - errCode, errMsg := tt.inputScenario(t, test) - require.Equal(t, tt.expectedErrCode, errCode) - require.True(t, strings.HasPrefix(errMsg, tt.expectedErrMsg)) + errCode, errMsg := test.inputScenario(t, testBehavior) + require.Equal(t, test.expectedErrCode, errCode) + require.True(t, strings.HasPrefix(errMsg, test.expectedErrMsg)) cancel() }) diff --git a/pkg/relayer/proxy/relay_signer.go b/pkg/relayer/proxy/relay_signer.go index 347bf6228..96b8f0b96 100644 --- a/pkg/relayer/proxy/relay_signer.go +++ b/pkg/relayer/proxy/relay_signer.go @@ -1,8 +1,6 @@ package proxy import ( - sdkerrors "cosmossdk.io/errors" - "github.com/pokt-network/poktroll/pkg/signer" "github.com/pokt-network/poktroll/x/service/types" ) @@ -19,13 +17,13 @@ func (rp *relayerProxy) SignRelayResponse(relayResponse *types.RelayResponse) er // extract and hash the relay response's signable bytes signableBz, err := relayResponse.GetSignableBytesHash() if err != nil { - return sdkerrors.Wrapf(ErrRelayerProxyInvalidRelayResponse, "error getting signable bytes: %v", err) + return ErrRelayerProxyInvalidRelayResponse.Wrapf("error getting signable bytes: %v", err) } // sign the relay response responseSig, err := signer.Sign(signableBz) if err != nil { - return sdkerrors.Wrapf(ErrRelayerProxyInvalidRelayResponse, "error signing relay response: %v", err) + return ErrRelayerProxyInvalidRelayResponse.Wrapf("error signing relay response: %v", err) } // set the relay response's signature diff --git a/pkg/relayer/proxy/relay_verifier.go b/pkg/relayer/proxy/relay_verifier.go index 60c1458e0..29924ee13 100644 --- a/pkg/relayer/proxy/relay_verifier.go +++ b/pkg/relayer/proxy/relay_verifier.go @@ -76,7 +76,7 @@ func (rp *relayerProxy) VerifyRelayRequest( // get and hash the signable bytes of the relay request requestSignableBz, err := relayRequest.GetSignableBytesHash() if err != nil { - return sdkerrors.Wrapf(ErrRelayerProxyInvalidRelayRequest, "error getting signable bytes: %v", err) + return ErrRelayerProxyInvalidRelayRequest.Wrapf("error getting signable bytes: %v", err) } // verify the relay request's signature diff --git a/pkg/relayer/session/options.go b/pkg/relayer/session/options.go index 1edadc132..b171a2e74 100644 --- a/pkg/relayer/session/options.go +++ b/pkg/relayer/session/options.go @@ -1,8 +1,6 @@ package session -import ( - "github.com/pokt-network/poktroll/pkg/relayer" -) +import "github.com/pokt-network/poktroll/pkg/relayer" // WithStoresDirectory sets the path on disk where KVStore data files used to store // SMST of work sessions are created. diff --git a/pkg/retry/retry_test.go b/pkg/retry/retry_test.go index d328bda73..c9dab961c 100644 --- a/pkg/retry/retry_test.go +++ b/pkg/retry/retry_test.go @@ -118,12 +118,12 @@ func TestOnError(t *testing.T) { } // Verify the error messages logged during the retries. - expectedErrorLine := "ERROR: retrying TestOnError after error: test error" + expectedErrLine := "ERROR: retrying TestOnError after error: test error" trimmedLogOutput := strings.Trim(logOutput.String(), "\n") logOutputLines := strings.Split(trimmedLogOutput, "\n") require.Lenf(t, logOutputLines, expectedRetryLimit, "unexpected number of log lines") for _, line := range logOutputLines { - require.Contains(t, line, expectedErrorLine, "log line does not contain the expected prefix") + require.Contains(t, line, expectedErrLine, "log line does not contain the expected prefix") } } @@ -213,11 +213,11 @@ func TestOnError_ExitsWhenErrChCloses(t *testing.T) { // Verify the logged error messages var ( - logOutputLines = strings.Split(strings.Trim(logOutput.String(), "\n"), "\n") - errorLines = logOutputLines[:len(logOutputLines)-1] - warnLine = logOutputLines[len(logOutputLines)-1] - expectedWarnMsg = "WARN: error channel for TestOnError_ExitsWhenErrChCloses closed, will no longer retry on error" - expectedErrorMsg = "ERROR: retrying TestOnError_ExitsWhenErrChCloses after error: test error" + logOutputLines = strings.Split(strings.Trim(logOutput.String(), "\n"), "\n") + errorLines = logOutputLines[:len(logOutputLines)-1] + warnLine = logOutputLines[len(logOutputLines)-1] + expectedWarnMsg = "WARN: error channel for TestOnError_ExitsWhenErrChCloses closed, will no longer retry on error" + expectedErrMsg = "ERROR: retrying TestOnError_ExitsWhenErrChCloses after error: test error" ) require.Lenf( @@ -227,7 +227,7 @@ func TestOnError_ExitsWhenErrChCloses(t *testing.T) { expectedRetryLimit, len(logOutputLines), ) for _, line := range errorLines { - require.Contains(t, line, expectedErrorMsg) + require.Contains(t, line, expectedErrMsg) } require.Contains(t, warnLine, expectedWarnMsg) } diff --git a/pkg/sdk/application.go b/pkg/sdk/application.go index 9509e02dc..226e0fecb 100644 --- a/pkg/sdk/application.go +++ b/pkg/sdk/application.go @@ -26,7 +26,7 @@ func (sdk *poktrollSDK) GetApplications(ctx context.Context, options GetApplicat return applications, nil } - // TODO_CONSIDERATION: Look into updating the on-chain `QueryAllApplicationRequest` for filtering + // TODO_CONSIDERATION: Look into updating the on-chain `QueryAllApplicationsRequest` for filtering // options to avoid needing to do it on the client side. for _, app := range applications { for _, delegatedGatewayAddress := range app.DelegateeGatewayAddresses { diff --git a/pkg/sdk/errors.go b/pkg/sdk/errors.go index fa42d684a..774fdf2f0 100644 --- a/pkg/sdk/errors.go +++ b/pkg/sdk/errors.go @@ -1,8 +1,6 @@ package sdk -import ( - sdkerrors "cosmossdk.io/errors" -) +import sdkerrors "cosmossdk.io/errors" // TODO_TECHDEBT: Do a source code wise find-replace using regex pattern match // of `sdkerrors\.Wrapf\(([a-zA-Z]+), ` with `$1.Wrapf(` diff --git a/proto/poktroll/service/relay.proto b/proto/poktroll/service/relay.proto index 37ca25e2f..9b94a4d91 100644 --- a/proto/poktroll/service/relay.proto +++ b/proto/poktroll/service/relay.proto @@ -1,10 +1,10 @@ syntax = "proto3"; package poktroll.service; -import "poktroll/session/session.proto"; - option go_package = "github.com/pokt-network/poktroll/x/service/types"; +import "poktroll/session/session.proto"; + // Relay contains both the RelayRequest (signed by the Application) and the RelayResponse (signed by the Supplier). // The serialized tuple is inserted into the SMST leaves as values in the Claim/Proof lifecycle. message Relay { diff --git a/testutil/testkeyring/gen_accounts/gen.go b/testutil/testkeyring/gen_accounts/gen.go index 56b047fec..b4e6c5466 100644 --- a/testutil/testkeyring/gen_accounts/gen.go +++ b/testutil/testkeyring/gen_accounts/gen.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import (