From ca335744da85607869c0438b47f04d21b11af7ed Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 15 Apr 2024 23:24:21 +0100 Subject: [PATCH] chore: Address linter findings in testing/ (#6150) * Address lint findings in testing/ * Remove nolint directive --------- Co-authored-by: DimitrisJim --- testing/chain.go | 3 ++- testing/endpoint.go | 13 +++++++++---- testing/simapp/app.go | 10 +++++++--- testing/simapp/upgrades/upgrades.go | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/testing/chain.go b/testing/chain.go index 5b59e78fe40..01a7d27dea8 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -276,7 +276,8 @@ func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, cl // QueryConsensusStateProof performs an abci query for a consensus state // stored on the given clientID. The proof and consensusHeight are returned. func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clienttypes.Height) { - consensusHeight := chain.GetClientLatestHeight(clientID).(clienttypes.Height) + consensusHeight, ok := chain.GetClientLatestHeight(clientID).(clienttypes.Height) + require.True(chain.TB, ok) consensusKey := host.FullConsensusStateKey(clientID, consensusHeight) consensusProof, _ := chain.QueryProof(consensusKey) diff --git a/testing/endpoint.go b/testing/endpoint.go index bde2146432f..e1adacafe0d 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -95,7 +95,8 @@ func (endpoint *Endpoint) CreateClient() (err error) { tmConfig, ok := endpoint.ClientConfig.(*TendermintConfig) require.True(endpoint.Chain.TB, ok) - height := endpoint.Counterparty.Chain.LatestCommittedHeader.GetHeight().(clienttypes.Height) + height, ok := endpoint.Counterparty.Chain.LatestCommittedHeader.GetHeight().(clienttypes.Height) + require.True(endpoint.Chain.TB, ok) clientState = ibctm.NewClientState( endpoint.Counterparty.Chain.ChainID, tmConfig.TrustLevel, tmConfig.TrustingPeriod, tmConfig.UnbondingPeriod, tmConfig.MaxClockDrift, height, commitmenttypes.GetSDKSpecs(), UpgradePath) @@ -138,7 +139,8 @@ func (endpoint *Endpoint) UpdateClient() (err error) { switch endpoint.ClientConfig.GetClientType() { case exported.Tendermint: - trustedHeight := endpoint.GetClientLatestHeight().(clienttypes.Height) + trustedHeight, ok := endpoint.GetClientLatestHeight().(clienttypes.Height) + require.True(endpoint.Chain.TB, ok) header, err = endpoint.Counterparty.Chain.IBCClientHeader(endpoint.Counterparty.Chain.LatestCommittedHeader, trustedHeight) default: err = fmt.Errorf("client type %s is not supported", endpoint.ClientConfig.GetClientType()) @@ -168,7 +170,8 @@ func (endpoint *Endpoint) UpgradeChain() error { } clientState := endpoint.Counterparty.GetClientState() - tmClientState := clientState.(*ibctm.ClientState) + tmClientState, ok := clientState.(*ibctm.ClientState) + require.True(endpoint.Chain.TB, ok) // increment revision number in chainID oldChainID := tmClientState.ChainId @@ -306,7 +309,9 @@ func (endpoint *Endpoint) QueryConnectionHandshakeProof() ( clientKey := host.FullClientStateKey(endpoint.Counterparty.ClientID) clientProof, proofHeight = endpoint.Counterparty.QueryProof(clientKey) - consensusHeight = endpoint.Counterparty.GetClientLatestHeight().(clienttypes.Height) + var ok bool + consensusHeight, ok = endpoint.Counterparty.GetClientLatestHeight().(clienttypes.Height) + require.True(endpoint.Chain.TB, ok) // query proof for the consensus state on the counterparty consensusKey := host.FullConsensusStateKey(endpoint.Counterparty.ClientID, consensusHeight) consensusProof, _ = endpoint.Counterparty.QueryProofAtHeight(consensusKey, proofHeight.GetRevisionHeight()) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 4a8acb976d0..cbb77eac3db 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -67,7 +67,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - consensus "github.com/cosmos/cosmos-sdk/x/consensus" + "github.com/cosmos/cosmos-sdk/x/consensus" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" "github.com/cosmos/cosmos-sdk/x/crisis" @@ -117,7 +117,7 @@ import ( ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper" ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" - transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + "github.com/cosmos/ibc-go/v8/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ibc "github.com/cosmos/ibc-go/v8/modules/core" @@ -523,7 +523,11 @@ func NewSimApp( // initialize ICA module with mock module as the authentication module on the controller side var icaControllerStack porttypes.IBCModule icaControllerStack = ibcmock.NewIBCModule(&mockModule, ibcmock.NewIBCApp("", scopedICAMockKeeper)) - app.ICAAuthModule = icaControllerStack.(ibcmock.IBCModule) + var ok bool + app.ICAAuthModule, ok = icaControllerStack.(ibcmock.IBCModule) + if !ok { + panic(fmt.Errorf("cannot convert %T into %T", icaControllerStack, app.ICAAuthModule)) + } icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper) icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper) diff --git a/testing/simapp/upgrades/upgrades.go b/testing/simapp/upgrades/upgrades.go index 0509ae15466..afe324e10b6 100644 --- a/testing/simapp/upgrades/upgrades.go +++ b/testing/simapp/upgrades/upgrades.go @@ -15,7 +15,7 @@ import ( paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" - v6 "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/migrations/v6" + "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/migrations/v6" clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" "github.com/cosmos/ibc-go/v8/modules/core/exported" ibctmmigrations "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint/migrations"