Skip to content

Commit

Permalink
chore: Address linter findings in testing/ (#6150)
Browse files Browse the repository at this point in the history
* Address lint findings in testing/

* Remove nolint directive

---------

Co-authored-by: DimitrisJim <[email protected]>
  • Loading branch information
bznein and DimitrisJim authored Apr 15, 2024
1 parent ebabc1c commit ca33574
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 9 additions & 4 deletions testing/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down
10 changes: 7 additions & 3 deletions testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion testing/simapp/upgrades/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ca33574

Please sign in to comment.