Skip to content

Commit 1fe7577

Browse files
crodriguezvegaDimitrisJimchatton
authoredSep 26, 2023
test: run tests of all go.mods (cosmos#4468)
* test: run tests of all go.mods Co-authored-by: Carlos Rodriguez <[email protected]> * Remove +build directive which is deprecated, remove tparse hadnling in Makefile. * Add sdk script, remove LINT_DIFF. * Fix linting issues that popped up. * Add script to run tests for all modules. * chore: add executible permissions to script, rename to avoid shadowing dir builtin * chore: use python3 instead of python * chore: add venv to gitignore * Disallow env vars not being set, clean up minor issues. --------- Co-authored-by: DimitrisJim <[email protected]> Co-authored-by: chatton <[email protected]> Co-authored-by: Cian Hatton <[email protected]>

26 files changed

+190
-81
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ dependency-graph.png
6161
# Go
6262
go.work
6363
go.work.sum
64+
65+
# Python
66+
venv

‎Makefile

+8-9
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-
176176
# Test runs-specific rules. To add a new test target, just add
177177
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
178178
# append the new rule to the TEST_TARGETS list.
179-
test-unit: ARGS=-tags='cgo ledger test_ledger_mock'
179+
test-unit: ARGS=-tags='cgo ledger test_ledger_mock test_e2e'
180180
test-unit-amino: ARGS=-tags='ledger test_ledger_mock test_amino'
181181
test-ledger: ARGS=-tags='cgo ledger'
182182
test-ledger-mock: ARGS=-tags='ledger test_ledger_mock'
@@ -192,12 +192,9 @@ check-test-unit-amino: ARGS=-tags='ledger test_ledger_mock test_amino'
192192
$(CHECK_TEST_TARGETS): EXTRA_ARGS=-run=none
193193
$(CHECK_TEST_TARGETS): run-tests
194194

195-
run-tests:
196-
ifneq (,$(shell which tparse 2>/dev/null))
197-
go test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
198-
else
199-
go test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
200-
endif
195+
ARGS += -tags "$(test_tags)"
196+
run-tests:
197+
@ARGS="$(ARGS)" TEST_PACKAGES=$(TEST_PACKAGES) EXTRA_ARGS="$(EXTRA_ARGS)" python3 ./scripts/go-test-all.py
201198

202199
.PHONY: run-tests test test-all $(TEST_TARGETS)
203200

@@ -283,10 +280,12 @@ setup-pre-commit:
283280
@ln -sf ../../scripts/hooks/pre-commit.sh .git/hooks/pre-commit
284281

285282
lint:
286-
golangci-lint run --out-format=tab
283+
@echo "--> Running linter"
284+
@./scripts/go-lint-all.sh --timeout=15m
287285

288286
lint-fix:
289-
golangci-lint run --fix --out-format=tab --issues-exit-code=0
287+
@echo "--> Running linter"
288+
@./scripts/go-lint-all.sh --fix
290289

291290
format:
292291
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./docs/client/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' -not -name '*.pb.gw.go' | xargs gofumpt -w

‎e2e/tests/core/02-client/client_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package client
24

35
import (

‎e2e/tests/core/03-connection/connection_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package connection
24

35
import (

‎e2e/tests/interchain_accounts/base_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package interchainaccounts
24

35
import (

‎e2e/tests/interchain_accounts/gov_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package interchainaccounts
24

35
import (

‎e2e/tests/interchain_accounts/groups_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package interchainaccounts
24

35
import (

‎e2e/tests/interchain_accounts/incentivized_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package interchainaccounts
24

35
import (

‎e2e/tests/interchain_accounts/localhost_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package interchainaccounts
24

35
import (

‎e2e/tests/interchain_accounts/params_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package interchainaccounts
24

35
import (

‎e2e/tests/transfer/authz_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package transfer
24

35
import (

‎e2e/tests/transfer/base_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package transfer
24

35
import (

‎e2e/tests/transfer/incentivized_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package transfer
24

35
import (

‎e2e/tests/transfer/localhost_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package transfer
24

35
import (

‎e2e/tests/upgrades/genesis_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package upgrades
24

35
import (
@@ -194,7 +196,7 @@ func (s *GenesisTestSuite) HaltChainAndExportGenesis(ctx context.Context, chain
194196
err = chain.StopAllNodes(ctx)
195197
s.Require().NoError(err, "error stopping node(s)")
196198

197-
state, err := chain.ExportState(ctx, int64(haltHeight))
199+
state, err := chain.ExportState(ctx, haltHeight)
198200
s.Require().NoError(err)
199201

200202
appTomlOverrides := make(test.Toml)

‎e2e/tests/upgrades/upgrade_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !test_e2e
2+
13
package upgrades
24

35
import (
@@ -6,9 +8,7 @@ import (
68
"testing"
79
"time"
810

9-
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
1011
"github.com/cosmos/gogoproto/proto"
11-
1212
interchaintest "github.com/strangelove-ventures/interchaintest/v8"
1313
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
1414
"github.com/strangelove-ventures/interchaintest/v8/ibc"
@@ -19,6 +19,7 @@ import (
1919
upgradetypes "cosmossdk.io/x/upgrade/types"
2020

2121
sdk "github.com/cosmos/cosmos-sdk/types"
22+
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
2223

2324
e2erelayer "github.com/cosmos/ibc-go/e2e/relayer"
2425
"github.com/cosmos/ibc-go/e2e/testsuite"

‎e2e/testsuite/codec.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import (
55
"encoding/hex"
66
"fmt"
77

8-
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
98
"github.com/cosmos/gogoproto/jsonpb"
109
"github.com/cosmos/gogoproto/proto"
1110

1211
upgradetypes "cosmossdk.io/x/upgrade/types"
1312

1413
"github.com/cosmos/cosmos-sdk/codec"
14+
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
1515
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
1616
sdk "github.com/cosmos/cosmos-sdk/types"
1717
"github.com/cosmos/cosmos-sdk/types/module/testutil"

‎e2e/testsuite/grpc_query.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ func (s *E2ETestSuite) InitGRPCClients(chain *cosmos.CosmosChain) {
8585
FeeQueryClient: feetypes.NewQueryClient(grpcConn),
8686
ICAControllerQueryClient: controllertypes.NewQueryClient(grpcConn),
8787
ICAHostQueryClient: hosttypes.NewQueryClient(grpcConn),
88-
BankQueryClient: banktypes.NewQueryClient(grpcConn),
89-
GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn),
90-
GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn),
91-
GroupsQueryClient: grouptypes.NewQueryClient(grpcConn),
92-
ParamsQueryClient: paramsproposaltypes.NewQueryClient(grpcConn),
93-
AuthQueryClient: authtypes.NewQueryClient(grpcConn),
94-
AuthZQueryClient: authz.NewQueryClient(grpcConn),
95-
ConsensusServiceClient: cmtservice.NewServiceClient(grpcConn),
96-
UpgradeQueryClient: upgradetypes.NewQueryClient(grpcConn),
88+
BankQueryClient: banktypes.NewQueryClient(grpcConn),
89+
GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn),
90+
GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn),
91+
GroupsQueryClient: grouptypes.NewQueryClient(grpcConn),
92+
ParamsQueryClient: paramsproposaltypes.NewQueryClient(grpcConn),
93+
AuthQueryClient: authtypes.NewQueryClient(grpcConn),
94+
AuthZQueryClient: authz.NewQueryClient(grpcConn),
95+
ConsensusServiceClient: cmtservice.NewServiceClient(grpcConn),
96+
UpgradeQueryClient: upgradetypes.NewQueryClient(grpcConn),
9797
}
9898
}
9999

‎e2e/testsuite/testconfig.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"path"
99
"strings"
1010

11-
tmjson "github.com/cometbft/cometbft/libs/json"
1211
"github.com/strangelove-ventures/interchaintest/v8/ibc"
1312
interchaintestutil "github.com/strangelove-ventures/interchaintest/v8/testutil"
1413
"gopkg.in/yaml.v2"
@@ -21,6 +20,8 @@ import (
2120
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
2221
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
2322

23+
tmjson "github.com/cometbft/cometbft/libs/json"
24+
2425
"github.com/cosmos/ibc-go/e2e/relayer"
2526
"github.com/cosmos/ibc-go/e2e/semverutil"
2627
"github.com/cosmos/ibc-go/e2e/testvalues"

‎e2e/testsuite/testsuite.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, ibcrelayer ibc
273273
// StartRelayer starts the given ibcrelayer.
274274
func (s *E2ETestSuite) StartRelayer(ibcrelayer ibc.Relayer) {
275275
if s.startRelayerFn == nil {
276-
panic(errors.New("cannot start relayer before it is created!"))
276+
panic(errors.New("cannot start relayer before it is created"))
277277
}
278278

279279
s.startRelayerFn(ibcrelayer)

‎modules/capability/keeper/keeper.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ func (k Keeper) GetOwners(ctx sdk.Context, index uint64) (types.CapabilityOwners
206206
func (k Keeper) InitializeCapability(ctx sdk.Context, index uint64, owners types.CapabilityOwners) {
207207
memStore := ctx.KVStore(k.memKey)
208208

209-
cap := types.NewCapability(index)
209+
capability := types.NewCapability(index)
210210
for _, owner := range owners.Owners {
211211
// Set the forward mapping between the module and capability tuple and the
212212
// capability name in the memKVStore
213-
memStore.Set(types.FwdCapabilityKey(owner.Module, cap), []byte(owner.Name))
213+
memStore.Set(types.FwdCapabilityKey(owner.Module, capability), []byte(owner.Name))
214214

215215
// Set the reverse mapping between the module and capability name and the
216216
// index in the in-memory store. Since marshalling and unmarshalling into a store
@@ -219,7 +219,7 @@ func (k Keeper) InitializeCapability(ctx sdk.Context, index uint64, owners types
219219
memStore.Set(types.RevCapabilityKey(owner.Module, owner.Name), sdk.Uint64ToBigEndian(index))
220220

221221
// Set the mapping from index from index to in-memory capability in the go map
222-
k.capMap[index] = cap
222+
k.capMap[index] = capability
223223
}
224224
}
225225

@@ -244,10 +244,10 @@ func (sk ScopedKeeper) NewCapability(ctx sdk.Context, name string) (*types.Capab
244244

245245
// create new capability with the current global index
246246
index := types.IndexFromKey(store.Get(types.KeyIndex))
247-
cap := types.NewCapability(index)
247+
capability := types.NewCapability(index)
248248

249249
// update capability owner set
250-
if err := sk.addOwner(ctx, cap, name); err != nil {
250+
if err := sk.addOwner(ctx, capability, name); err != nil {
251251
return nil, err
252252
}
253253

@@ -258,7 +258,7 @@ func (sk ScopedKeeper) NewCapability(ctx sdk.Context, name string) (*types.Capab
258258

259259
// Set the forward mapping between the module and capability tuple and the
260260
// capability name in the memKVStore
261-
memStore.Set(types.FwdCapabilityKey(sk.module, cap), []byte(name))
261+
memStore.Set(types.FwdCapabilityKey(sk.module, capability), []byte(name))
262262

263263
// Set the reverse mapping between the module and capability name and the
264264
// index in the in-memory store. Since marshalling and unmarshalling into a store
@@ -267,11 +267,11 @@ func (sk ScopedKeeper) NewCapability(ctx sdk.Context, name string) (*types.Capab
267267
memStore.Set(types.RevCapabilityKey(sk.module, name), sdk.Uint64ToBigEndian(index))
268268

269269
// Set the mapping from index from index to in-memory capability in the go map
270-
sk.capMap[index] = cap
270+
sk.capMap[index] = capability
271271

272272
logger(ctx).Info("created new capability", "module", sk.module, "name", name)
273273

274-
return cap, nil
274+
return capability, nil
275275
}
276276

277277
// AuthenticateCapability attempts to authenticate a given capability and name
@@ -389,12 +389,12 @@ func (sk ScopedKeeper) GetCapability(ctx sdk.Context, name string) (*types.Capab
389389
return nil, false
390390
}
391391

392-
cap := sk.capMap[index]
393-
if cap == nil {
392+
capability := sk.capMap[index]
393+
if capability == nil {
394394
panic(errors.New("capability found in memstore is missing from map"))
395395
}
396396

397-
return cap, true
397+
return capability, true
398398
}
399399

400400
// GetCapabilityName allows a module to retrieve the name under which it stored a given
@@ -414,13 +414,13 @@ func (sk ScopedKeeper) GetOwners(ctx sdk.Context, name string) (*types.Capabilit
414414
if strings.TrimSpace(name) == "" {
415415
return nil, false
416416
}
417-
cap, ok := sk.GetCapability(ctx, name)
417+
capability, ok := sk.GetCapability(ctx, name)
418418
if !ok {
419419
return nil, false
420420
}
421421

422422
prefixStore := prefix.NewStore(ctx.KVStore(sk.storeKey), types.KeyPrefixIndexCapability)
423-
indexKey := types.IndexToKey(cap.GetIndex())
423+
indexKey := types.IndexToKey(capability.GetIndex())
424424

425425
var capOwners types.CapabilityOwners
426426

@@ -442,7 +442,7 @@ func (sk ScopedKeeper) LookupModules(ctx sdk.Context, name string) ([]string, *t
442442
if strings.TrimSpace(name) == "" {
443443
return nil, nil, errorsmod.Wrap(types.ErrInvalidCapabilityName, "cannot lookup modules with empty capability name")
444444
}
445-
cap, ok := sk.GetCapability(ctx, name)
445+
capability, ok := sk.GetCapability(ctx, name)
446446
if !ok {
447447
return nil, nil, errorsmod.Wrap(types.ErrCapabilityNotFound, name)
448448
}
@@ -457,7 +457,7 @@ func (sk ScopedKeeper) LookupModules(ctx sdk.Context, name string) ([]string, *t
457457
mods[i] = co.Module
458458
}
459459

460-
return mods, cap, nil
460+
return mods, capability, nil
461461
}
462462

463463
func (sk ScopedKeeper) addOwner(ctx sdk.Context, cap *types.Capability, name string) error {

0 commit comments

Comments
 (0)
Please sign in to comment.