-
Notifications
You must be signed in to change notification settings - Fork 606
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 linter findings in testing/ #6150
Changes from 2 commits
f33576b
d8e729d
c2b728a
76ec265
aa4fff2
8c9695d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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) | ||||||||||||||
Comment on lines
+142
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure proper error handling for type assertion failures. - require.True(endpoint.Chain.TB, ok)
+ require.True(endpoint.Chain.TB, ok, "failed to assert type as clienttypes.Height") Adding a descriptive error message will help in debugging if the type assertion fails. Committable suggestion
Suggested change
|
||||||||||||||
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) | ||||||||||||||
Comment on lines
+173
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure proper error handling for type assertion failures. - require.True(endpoint.Chain.TB, ok)
+ require.True(endpoint.Chain.TB, ok, "failed to assert type as *ibctm.ClientState") Adding a descriptive error message will help in debugging if the type assertion fails. Committable suggestion
Suggested change
|
||||||||||||||
|
||||||||||||||
// 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) | ||||||||||||||
Comment on lines
+312
to
+314
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure proper error handling for type assertion failures. - require.True(endpoint.Chain.TB, ok)
+ require.True(endpoint.Chain.TB, ok, "failed to assert type as clienttypes.Height") Adding a descriptive error message will help in debugging if the type assertion fails. Committable suggestion
Suggested change
|
||||||||||||||
// query proof for the consensus state on the counterparty | ||||||||||||||
consensusKey := host.FullConsensusStateKey(endpoint.Counterparty.ClientID, consensusHeight) | ||||||||||||||
consensusProof, _ = endpoint.Counterparty.QueryProofAtHeight(consensusKey, proofHeight.GetRevisionHeight()) | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,8 +117,8 @@ 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" | ||
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" | ||
"github.com/cosmos/ibc-go/v8/modules/apps/transfer" | ||
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" //nolint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an interesting one that left me stumped! If I remove the type alias, So I would be very happy if anyone would like to help me understand what is going on :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, with these imports it works fine locally: "github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" you mean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, this is weird. I tried to repro the issue (which happened at line 121) but... it's not happening anymore. No idea what was happening, but thank you! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code gods works in mysterious ways 🕯️ |
||
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" | ||
ibc "github.com/cosmos/ibc-go/v8/modules/core" | ||
ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client" | ||
|
@@ -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)) | ||
} | ||
Comment on lines
+526
to
+530
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type assertion for Would you like me to help with writing the unit test for this type assertion? |
||
icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper) | ||
icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification The verification process has revealed that the old import path Given this finding, it is recommended to update all references to the old import path across the entire codebase to ensure consistency and prevent potential issues related to outdated imports. Analysis chainThe import path for the migration module related to interchain accounts has been updated to remove the specific version reference Scripts ExecutedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for any files that might still be using the old import path.
rg --type go 'github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/migrations/v6'
Length of output: 403 |
||
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" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure proper error handling for type assertion failures.
Adding a descriptive error message will help in debugging if the type assertion fails.
Committable suggestion