From 92a7796ef4ec1f0b81ed07d2ad4044ca8ad0ebb4 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Sun, 13 Aug 2023 21:47:01 +0800 Subject: [PATCH] run golangci-lint --- testutil/crypto/crypto.go | 6 +++--- testutil/ibc_testing/generic_setup.go | 13 +++++++------ testutil/ibc_testing/specific_setup.go | 2 +- testutil/integration/interfaces.go | 4 +++- testutil/keeper/expectations.go | 27 ++++++++++++-------------- testutil/keeper/unit_test_helpers.go | 26 ++++++++++++------------- testutil/simibc/chain_util.go | 6 ++++-- testutil/simibc/relay_util.go | 12 ++++++++---- testutil/simibc/relayed_path.go | 1 + 9 files changed, 52 insertions(+), 45 deletions(-) diff --git a/testutil/crypto/crypto.go b/testutil/crypto/crypto.go index b2d0e464df..53babef942 100644 --- a/testutil/crypto/crypto.go +++ b/testutil/crypto/crypto.go @@ -1,9 +1,8 @@ package crypto import ( - "encoding/binary" - cryptoEd25519 "crypto/ed25519" + "encoding/binary" sdkcryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdkcryptoEd25519 "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -11,11 +10,12 @@ import ( sdkcryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdktypes "github.com/cosmos/cosmos-sdk/types" sdkstakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" tmcrypto "github.com/cometbft/cometbft/crypto" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" tmtypes "github.com/cometbft/cometbft/types" + + providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ) // CryptoIdentity is a test helper for generating keys and addresses of diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go index e784ee23b7..25c483fca5 100644 --- a/testutil/ibc_testing/generic_setup.go +++ b/testutil/ibc_testing/generic_setup.go @@ -4,17 +4,18 @@ import ( "fmt" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" - testutil "github.com/cosmos/interchain-security/v3/testutil/integration" - testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" - consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" - "github.com/stretchr/testify/suite" + sdk "github.com/cosmos/cosmos-sdk/types" + tmencoding "github.com/cometbft/cometbft/crypto/encoding" tmtypes "github.com/cometbft/cometbft/types" + + ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" + testutil "github.com/cosmos/interchain-security/v3/testutil/integration" + testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" + consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" ) // Contains generic setup code for running integration tests against a provider, consumer, diff --git a/testutil/ibc_testing/specific_setup.go b/testutil/ibc_testing/specific_setup.go index 01c8315de8..948007d212 100644 --- a/testutil/ibc_testing/specific_setup.go +++ b/testutil/ibc_testing/specific_setup.go @@ -8,7 +8,6 @@ import ( "encoding/json" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" @@ -16,6 +15,7 @@ import ( appConsumer "github.com/cosmos/interchain-security/v3/app/consumer" appConsumerDemocracy "github.com/cosmos/interchain-security/v3/app/consumer-democracy" appProvider "github.com/cosmos/interchain-security/v3/app/provider" + ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" ) // ProviderAppIniter implements ibctesting.AppIniter for a provider app diff --git a/testutil/integration/interfaces.go b/testutil/integration/interfaces.go index 41e6fd70c3..b677d46789 100644 --- a/testutil/integration/interfaces.go +++ b/testutil/integration/interfaces.go @@ -4,7 +4,7 @@ import ( "time" "cosmossdk.io/math" - abci "github.com/cometbft/cometbft/abci/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -16,6 +16,8 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking/types" + abci "github.com/cometbft/cometbft/abci/types" + ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" providerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/provider/keeper" diff --git a/testutil/keeper/expectations.go b/testutil/keeper/expectations.go index 8a231f4760..07d4d320ba 100644 --- a/testutil/keeper/expectations.go +++ b/testutil/keeper/expectations.go @@ -3,23 +3,20 @@ package keeper import ( time "time" - sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/golang/mock/gomock" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v7/modules/core/24-host" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" - "github.com/cosmos/interchain-security/v3/x/ccv/types" + "github.com/golang/mock/gomock" + extra "github.com/oxyno-zeta/gomock-extra-matcher" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - extra "github.com/oxyno-zeta/gomock-extra-matcher" + providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v3/x/ccv/types" ) // @@ -68,7 +65,7 @@ func GetMocksForSetConsumerChain(ctx sdk.Context, mocks *MockedKeepers, chainIDToInject string, ) []*gomock.Call { return []*gomock.Call{ - mocks.MockChannelKeeper.EXPECT().GetChannel(ctx, ccv.ProviderPortID, gomock.Any()).Return( + mocks.MockChannelKeeper.EXPECT().GetChannel(ctx, types.ProviderPortID, gomock.Any()).Return( channeltypes.Channel{ State: channeltypes.OPEN, ConnectionHops: []string{"connectionID"}, @@ -88,11 +85,11 @@ func GetMocksForSetConsumerChain(ctx sdk.Context, mocks *MockedKeepers, func GetMocksForStopConsumerChain(ctx sdk.Context, mocks *MockedKeepers) []*gomock.Call { dummyCap := &capabilitytypes.Capability{} return []*gomock.Call{ - mocks.MockChannelKeeper.EXPECT().GetChannel(gomock.Any(), ccv.ProviderPortID, "channelID").Return( + mocks.MockChannelKeeper.EXPECT().GetChannel(gomock.Any(), types.ProviderPortID, "channelID").Return( channeltypes.Channel{State: channeltypes.OPEN}, true, ).Times(1), mocks.MockScopedKeeper.EXPECT().GetCapability(gomock.Any(), gomock.Any()).Return(dummyCap, true).Times(1), - mocks.MockChannelKeeper.EXPECT().ChanCloseInit(gomock.Any(), ccv.ProviderPortID, "channelID", dummyCap).Times(1), + mocks.MockChannelKeeper.EXPECT().ChanCloseInit(gomock.Any(), types.ProviderPortID, "channelID", dummyCap).Times(1), } } @@ -137,7 +134,7 @@ func ExpectCreateClientMock(ctx sdk.Context, mocks MockedKeepers, clientID strin func ExpectGetCapabilityMock(ctx sdk.Context, mocks MockedKeepers, times int) *gomock.Call { return mocks.MockScopedKeeper.EXPECT().GetCapability( - ctx, host.PortPath(ccv.ConsumerPortID), + ctx, host.PortPath(types.ConsumerPortID), ).Return(nil, true).Times(times) } diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index b8e69a4045..c5540f4601 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -6,32 +6,32 @@ import ( "testing" "time" - abci "github.com/cometbft/cometbft/abci/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" - tmdb "github.com/cometbft/cometbft-db" - "github.com/cometbft/cometbft/libs/log" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + tmdb "github.com/cometbft/cometbft-db" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" providerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" "github.com/cosmos/interchain-security/v3/x/ccv/types" - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" ) // Parameters needed to instantiate an in-memory keeper diff --git a/testutil/simibc/chain_util.go b/testutil/simibc/chain_util.go index 0e6d14cd38..98622695d3 100644 --- a/testutil/simibc/chain_util.go +++ b/testutil/simibc/chain_util.go @@ -3,10 +3,12 @@ package simibc import ( "time" - abci "github.com/cometbft/cometbft/abci/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + + abci "github.com/cometbft/cometbft/abci/types" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + ibctestingcore "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" ) diff --git a/testutil/simibc/relay_util.go b/testutil/simibc/relay_util.go index c5e4885b24..97bcabf57c 100644 --- a/testutil/simibc/relay_util.go +++ b/testutil/simibc/relay_util.go @@ -1,16 +1,20 @@ package simibc import ( - errorsmod "cosmossdk.io/errors" - tmtypes "github.com/cometbft/cometbft/types" - sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + "github.com/stretchr/testify/require" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + tmtypes "github.com/cometbft/cometbft/types" + simapp "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp" ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" - "github.com/stretchr/testify/require" ) // UpdateReceiverClient DELIVERs a header to the receiving endpoint diff --git a/testutil/simibc/relayed_path.go b/testutil/simibc/relayed_path.go index dfc5febe9c..7ef97c4bee 100644 --- a/testutil/simibc/relayed_path.go +++ b/testutil/simibc/relayed_path.go @@ -5,6 +5,7 @@ import ( "time" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" )