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

chore: address linting issues for more modules. #6121

Merged
merged 8 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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: 2 additions & 1 deletion modules/core/03-connection/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
path := ibctesting.NewPath(suite.chainA, suite.chainB)
path.SetupConnections()

clientHeight := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
clientHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)
expConsensusState, _ = suite.chainA.GetConsensusState(path.EndpointA.ClientID, clientHeight)
suite.Require().NotNil(expConsensusState)
expClientID = path.EndpointA.ClientID
Expand Down
6 changes: 4 additions & 2 deletions modules/core/03-connection/keeper/handshake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
// modify counterparty client without setting in store so it still passes validate but fails proof verification
tmClient, ok := counterpartyClient.(*ibctm.ClientState)
suite.Require().True(ok)
tmClient.LatestHeight = tmClient.LatestHeight.Increment().(clienttypes.Height)
tmClient.LatestHeight, ok = tmClient.LatestHeight.Increment().(clienttypes.Height)
suite.Require().True(ok)
}, false},
{"consensus state verification failed", func() {
// retrieve client state of chainA to pass as counterpartyClient
Expand Down Expand Up @@ -460,7 +461,8 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
// modify counterparty client without setting in store so it still passes validate but fails proof verification
tmClient, ok := counterpartyClient.(*ibctm.ClientState)
suite.Require().True(ok)
tmClient.LatestHeight = tmClient.LatestHeight.Increment().(clienttypes.Height)
tmClient.LatestHeight, ok = tmClient.LatestHeight.Increment().(clienttypes.Height)
suite.Require().True(ok)

err = path.EndpointB.ConnOpenTry()
suite.Require().NoError(err)
Expand Down
36 changes: 24 additions & 12 deletions modules/core/03-connection/keeper/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ func (suite *KeeperTestSuite) TestVerifyClientState() {
heightDiff = 5
}, false},
{"verification failed", func() {
counterpartyClient := path.EndpointB.GetClientState().(*ibctm.ClientState)
counterpartyClient, ok := path.EndpointB.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
counterpartyClient.ChainId = "wrongChainID"
path.EndpointB.SetClientState(counterpartyClient)
}, false},
{"client status is not active - client is expired", func() {
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointA.SetClientState(clientState)
}, false},
Expand Down Expand Up @@ -112,7 +114,8 @@ func (suite *KeeperTestSuite) TestVerifyClientConsensusState() {
suite.coordinator.CommitBlock(suite.chainB)
}, false},
{"client status is not active - client is expired", func() {
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointA.SetClientState(clientState)
}, false},
Expand Down Expand Up @@ -172,7 +175,8 @@ func (suite *KeeperTestSuite) TestVerifyConnectionState() {
path.EndpointA.UpdateConnection(func(c *types.ConnectionEnd) { c.State = types.TRYOPEN })
}, false},
{"client status is not active - client is expired", func() {
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointA.SetClientState(clientState)
}, false},
Expand Down Expand Up @@ -233,7 +237,8 @@ func (suite *KeeperTestSuite) TestVerifyChannelState() {
path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { channel.State = channeltypes.TRYOPEN })
}, false},
{"client status is not active - client is expired", func() {
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointA.SetClientState(clientState)
}, false},
Expand Down Expand Up @@ -309,7 +314,8 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() {
packet.Data = []byte(ibctesting.InvalidID)
}, false},
{"client status is not active - client is expired", func() {
clientState := path.EndpointB.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointB.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointB.SetClientState(clientState)
}, false},
Expand Down Expand Up @@ -399,7 +405,8 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() {
ack = ibcmock.MockFailAcknowledgement
}, false},
{"client status is not active - client is expired", func() {
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointA.SetClientState(clientState)
}, false},
Expand Down Expand Up @@ -503,7 +510,8 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() {
suite.Require().NoError(err)
}, false},
{"client status is not active - client is expired", func() {
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointA.SetClientState(clientState)
}, false},
Expand Down Expand Up @@ -532,7 +540,8 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() {
connection := path.EndpointA.GetConnection()
connection.DelayPeriod = delayTimePeriod

clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
if clientState.FrozenHeight.IsZero() {
// need to update height to prove absence or receipt
suite.coordinator.CommitBlock(suite.chainA, suite.chainB)
Expand Down Expand Up @@ -602,7 +611,8 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() {
offsetSeq = 1
}, false},
{"client status is not active - client is expired", func() {
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointA.SetClientState(clientState)
}, false},
Expand Down Expand Up @@ -678,7 +688,8 @@ func (suite *KeeperTestSuite) TestVerifyUpgradeErrorReceipt() {
{
name: "fails when client state is frozen",
malleate: func() {
clientState := path.EndpointB.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointB.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointB.SetClientState(clientState)
},
Expand Down Expand Up @@ -759,7 +770,8 @@ func (suite *KeeperTestSuite) TestVerifyUpgrade() {
{
name: "fails when client state is frozen",
malleate: func() {
clientState := path.EndpointB.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointB.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointB.SetClientState(clientState)
},
Expand Down
5 changes: 3 additions & 2 deletions modules/core/03-connection/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
testifysuite "github.com/stretchr/testify/suite"

log "cosmossdk.io/log"
"cosmossdk.io/log"
"cosmossdk.io/store/iavl"
"cosmossdk.io/store/metrics"
"cosmossdk.io/store/rootmulti"
Expand Down Expand Up @@ -60,7 +60,8 @@ func (suite *MsgTestSuite) SetupTest() {
store.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, nil)
err := store.LoadVersion(0)
suite.Require().NoError(err)
iavlStore := store.GetCommitStore(storeKey).(*iavl.Store)
iavlStore, ok := store.GetCommitStore(storeKey).(*iavl.Store)
suite.Require().True(ok)

iavlStore.Set([]byte("KEY"), []byte("VALUE"))
_ = store.Commit()
Expand Down
2 changes: 1 addition & 1 deletion modules/core/03-connection/types/params_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ for migration purposes and will be removed in a future release.
package types

import (
fmt "fmt"
"fmt"

paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
Expand Down
4 changes: 3 additions & 1 deletion modules/core/04-channel/keeper/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ func (suite *KeeperTestSuite) TestSendPacket() {
path.Setup()
sourceChannel = path.EndpointA.ChannelID

timeoutHeight = path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
var ok bool
timeoutHeight, ok = path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)
DimitrisJim marked this conversation as resolved.
Show resolved Hide resolved
channelCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
}, false},
{"timeout timestamp passed", func() {
Expand Down
5 changes: 3 additions & 2 deletions modules/core/04-channel/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
testifysuite "github.com/stretchr/testify/suite"

errorsmod "cosmossdk.io/errors"
log "cosmossdk.io/log"
"cosmossdk.io/log"
"cosmossdk.io/store/iavl"
"cosmossdk.io/store/metrics"
"cosmossdk.io/store/rootmulti"
Expand Down Expand Up @@ -94,7 +94,8 @@ func (suite *TypesTestSuite) SetupTest() {
store.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, nil)
err := store.LoadVersion(0)
suite.Require().NoError(err)
iavlStore := store.GetCommitStore(storeKey).(*iavl.Store)
iavlStore, ok := store.GetCommitStore(storeKey).(*iavl.Store)
suite.Require().True(ok)

iavlStore.Set([]byte("KEY"), []byte("VALUE"))
_ = store.Commit()
Expand Down
4 changes: 3 additions & 1 deletion modules/core/23-commitment/types/commitment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ func (suite *MerkleTestSuite) SetupTest() {
err := suite.store.LoadVersion(0)
suite.Require().NoError(err)

suite.iavlStore = suite.store.GetCommitStore(suite.storeKey).(*iavl.Store)
var ok bool
suite.iavlStore, ok = suite.store.GetCommitStore(suite.storeKey).(*iavl.Store)
suite.Require().True(ok)
}

func TestMerkleTestSuite(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion modules/core/23-commitment/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

errorsmod "cosmossdk.io/errors"

crypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
"github.com/cometbft/cometbft/proto/tendermint/crypto"
)

// ConvertProofs converts crypto.ProofOps into MerkleProof
Expand Down
2 changes: 1 addition & 1 deletion modules/core/23-commitment/types/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

storetypes "cosmossdk.io/store/types"

crypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
"github.com/cometbft/cometbft/proto/tendermint/crypto"

"github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
)
Expand Down
2 changes: 1 addition & 1 deletion modules/core/exported/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package exported

import (
proto "github.com/cosmos/gogoproto/proto"
"github.com/cosmos/gogoproto/proto"

storetypes "cosmossdk.io/store/types"

Expand Down
9 changes: 6 additions & 3 deletions modules/core/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ func (suite *KeeperTestSuite) TestRecoverClient() {

// Assert that client status is now Active
clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), subjectPath.EndpointA.ClientID)
tmClientState := subjectPath.EndpointA.GetClientState().(*ibctm.ClientState)
tmClientState, ok := subjectPath.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
suite.Require().Equal(tmClientState.Status(suite.chainA.GetContext(), clientStore, suite.chainA.App.AppCodec()), exported.Active)
} else {
suite.Require().Error(err)
Expand Down Expand Up @@ -870,7 +871,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
path.SetupClients()

var err error
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
revisionNumber := clienttypes.ParseChainID(clientState.ChainId)

newChainID, err = clienttypes.SetRevisionNumber(clientState.ChainId, revisionNumber+1)
Expand Down Expand Up @@ -2574,7 +2576,8 @@ func (suite *KeeperTestSuite) TestIBCSoftwareUpgrade() {
Height: 1000,
}
// update trusting period
clientState := path.EndpointB.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointB.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
DimitrisJim marked this conversation as resolved.
Show resolved Hide resolved
clientState.TrustingPeriod += 100

var err error
Expand Down
Loading