Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: run tests of all go.mods #4468

Merged
merged 14 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ dependency-graph.png
# Go
go.work
go.work.sum

# Python
venv
17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-
# Test runs-specific rules. To add a new test target, just add
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
# append the new rule to the TEST_TARGETS list.
test-unit: ARGS=-tags='cgo ledger test_ledger_mock'
test-unit: ARGS=-tags='cgo ledger test_ledger_mock test_e2e'
test-unit-amino: ARGS=-tags='ledger test_ledger_mock test_amino'
test-ledger: ARGS=-tags='cgo ledger'
test-ledger-mock: ARGS=-tags='ledger test_ledger_mock'
Expand All @@ -192,12 +192,9 @@ check-test-unit-amino: ARGS=-tags='ledger test_ledger_mock test_amino'
$(CHECK_TEST_TARGETS): EXTRA_ARGS=-run=none
$(CHECK_TEST_TARGETS): run-tests

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

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

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

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

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

format:
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
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/core/02-client/client_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package client

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/core/03-connection/connection_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package connection

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/interchain_accounts/base_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package interchainaccounts

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/interchain_accounts/gov_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package interchainaccounts

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/interchain_accounts/groups_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package interchainaccounts

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/interchain_accounts/incentivized_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package interchainaccounts

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/interchain_accounts/localhost_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package interchainaccounts

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/interchain_accounts/params_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package interchainaccounts

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/transfer/authz_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package transfer

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/transfer/base_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package transfer

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/transfer/incentivized_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package transfer

import (
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/transfer/localhost_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package transfer

import (
Expand Down
4 changes: 3 additions & 1 deletion e2e/tests/upgrades/genesis_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package upgrades

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

state, err := chain.ExportState(ctx, int64(haltHeight))
state, err := chain.ExportState(ctx, haltHeight)
s.Require().NoError(err)

appTomlOverrides := make(test.Toml)
Expand Down
5 changes: 3 additions & 2 deletions e2e/tests/upgrades/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !test_e2e

package upgrades

import (
Expand All @@ -6,9 +8,7 @@ import (
"testing"
"time"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/gogoproto/proto"

interchaintest "github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
Expand All @@ -19,6 +19,7 @@ import (
upgradetypes "cosmossdk.io/x/upgrade/types"

sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

e2erelayer "github.com/cosmos/ibc-go/e2e/relayer"
"github.com/cosmos/ibc-go/e2e/testsuite"
Expand Down
2 changes: 1 addition & 1 deletion e2e/testsuite/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"encoding/hex"
"fmt"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/gogoproto/jsonpb"
"github.com/cosmos/gogoproto/proto"

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

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
Expand Down
18 changes: 9 additions & 9 deletions e2e/testsuite/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ func (s *E2ETestSuite) InitGRPCClients(chain *cosmos.CosmosChain) {
FeeQueryClient: feetypes.NewQueryClient(grpcConn),
ICAControllerQueryClient: controllertypes.NewQueryClient(grpcConn),
ICAHostQueryClient: hosttypes.NewQueryClient(grpcConn),
BankQueryClient: banktypes.NewQueryClient(grpcConn),
GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn),
GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn),
GroupsQueryClient: grouptypes.NewQueryClient(grpcConn),
ParamsQueryClient: paramsproposaltypes.NewQueryClient(grpcConn),
AuthQueryClient: authtypes.NewQueryClient(grpcConn),
AuthZQueryClient: authz.NewQueryClient(grpcConn),
ConsensusServiceClient: cmtservice.NewServiceClient(grpcConn),
UpgradeQueryClient: upgradetypes.NewQueryClient(grpcConn),
BankQueryClient: banktypes.NewQueryClient(grpcConn),
GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn),
GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn),
GroupsQueryClient: grouptypes.NewQueryClient(grpcConn),
ParamsQueryClient: paramsproposaltypes.NewQueryClient(grpcConn),
AuthQueryClient: authtypes.NewQueryClient(grpcConn),
AuthZQueryClient: authz.NewQueryClient(grpcConn),
ConsensusServiceClient: cmtservice.NewServiceClient(grpcConn),
UpgradeQueryClient: upgradetypes.NewQueryClient(grpcConn),
}
}

Expand Down
3 changes: 2 additions & 1 deletion e2e/testsuite/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path"
"strings"

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

tmjson "github.com/cometbft/cometbft/libs/json"

"github.com/cosmos/ibc-go/e2e/relayer"
"github.com/cosmos/ibc-go/e2e/semverutil"
"github.com/cosmos/ibc-go/e2e/testvalues"
Expand Down
2 changes: 1 addition & 1 deletion e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, ibcrelayer ibc
// StartRelayer starts the given ibcrelayer.
func (s *E2ETestSuite) StartRelayer(ibcrelayer ibc.Relayer) {
if s.startRelayerFn == nil {
panic(errors.New("cannot start relayer before it is created!"))
panic(errors.New("cannot start relayer before it is created"))
}

s.startRelayerFn(ibcrelayer)
Expand Down
30 changes: 15 additions & 15 deletions modules/capability/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ func (k Keeper) GetOwners(ctx sdk.Context, index uint64) (types.CapabilityOwners
func (k Keeper) InitializeCapability(ctx sdk.Context, index uint64, owners types.CapabilityOwners) {
memStore := ctx.KVStore(k.memKey)

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

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

// Set the mapping from index from index to in-memory capability in the go map
k.capMap[index] = cap
k.capMap[index] = capability
}
}

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

// create new capability with the current global index
index := types.IndexFromKey(store.Get(types.KeyIndex))
cap := types.NewCapability(index)
capability := types.NewCapability(index)

// update capability owner set
if err := sk.addOwner(ctx, cap, name); err != nil {
if err := sk.addOwner(ctx, capability, name); err != nil {
return nil, err
}

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

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

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

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

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

return cap, nil
return capability, nil
}

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

cap := sk.capMap[index]
if cap == nil {
capability := sk.capMap[index]
if capability == nil {
panic(errors.New("capability found in memstore is missing from map"))
}

return cap, true
return capability, true
}

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

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

var capOwners types.CapabilityOwners

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

return mods, cap, nil
return mods, capability, nil
}

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