From b6cf3cc5611baf6559a7f0d073fd4f4723a2b24c Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 8 Apr 2024 13:24:06 +0100 Subject: [PATCH 1/3] Address linter issues in e2e/. --- e2e/tests/core/02-client/client_test.go | 3 ++- e2e/tests/transfer/localhost_test.go | 3 ++- e2e/tests/upgrades/genesis_test.go | 2 +- e2e/tests/wasm/grandpa_test.go | 35 ++++++++++++++++++------- e2e/testsuite/testconfig.go | 5 +++- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 06e1f3f3581..fe7ade0ee46 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -101,7 +101,8 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().NoError(err) s.Require().NotEqual(originalChainID, newChainID) - upgradedClientState := clientState.(*ibctm.ClientState) + upgradedClientState, ok := clientState.(*ibctm.ClientState) + s.Require().True(ok) upgradedClientState.ChainId = newChainID scheduleUpgradeMsg, err := clienttypes.NewMsgIBCSoftwareUpgrade( diff --git a/e2e/tests/transfer/localhost_test.go b/e2e/tests/transfer/localhost_test.go index a8909fa9675..e7d5e7299dc 100644 --- a/e2e/tests/transfer/localhost_test.go +++ b/e2e/tests/transfer/localhost_test.go @@ -56,7 +56,8 @@ func (s *LocalhostTransferTestSuite) TestMsgTransfer_Localhost() { cs, err := s.QueryClientState(ctx, chainA, exported.LocalhostClientID) s.Require().NoError(err) - localhostClientState := cs.(*localhost.ClientState) + localhostClientState, ok := cs.(*localhost.ClientState) + s.Require().True(ok) originalHeight := localhostClientState.LatestHeight s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index 2e2d1850e03..08d913d061e 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/gogoproto/proto" "github.com/strangelove-ventures/interchaintest/v8" - cosmos "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" + "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v8/ibc" test "github.com/strangelove-ventures/interchaintest/v8/testutil" "github.com/stretchr/testify/suite" diff --git a/e2e/tests/wasm/grandpa_test.go b/e2e/tests/wasm/grandpa_test.go index b67a4c930e7..4b0824a6103 100644 --- a/e2e/tests/wasm/grandpa_test.go +++ b/e2e/tests/wasm/grandpa_test.go @@ -78,8 +78,11 @@ func (s *GrandpaTestSuite) TestMsgTransfer_Succeeds_GrandpaContract() { chainA, chainB := s.GetGrandpaTestChains() - polkadotChain := chainA.(*polkadot.PolkadotChain) - cosmosChain := chainB.(*cosmos.CosmosChain) + polkadotChain, ok := chainA.(*polkadot.PolkadotChain) + s.Require().True(ok) + + cosmosChain, ok := chainB.(*cosmos.CosmosChain) + s.Require().True(ok) // we explicitly skip path creation as the contract needs to be uploaded before we can create clients. r := s.ConfigureRelayer(ctx, polkadotChain, cosmosChain, nil, func(options *interchaintest.InterchainBuildOptions) { @@ -230,8 +233,11 @@ func (s *GrandpaTestSuite) TestMsgTransfer_TimesOut_GrandpaContract() { chainA, chainB := s.GetGrandpaTestChains() - polkadotChain := chainA.(*polkadot.PolkadotChain) - cosmosChain := chainB.(*cosmos.CosmosChain) + polkadotChain, ok := chainA.(*polkadot.PolkadotChain) + s.Require().True(ok) + + cosmosChain, ok := chainB.(*cosmos.CosmosChain) + s.Require().True(ok) // we explicitly skip path creation as the contract needs to be uploaded before we can create clients. r := s.ConfigureRelayer(ctx, polkadotChain, cosmosChain, nil, func(options *interchaintest.InterchainBuildOptions) { @@ -344,8 +350,11 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_Success_GrandpaContract() { chainA, chainB := s.GetGrandpaTestChains() - polkadotChain := chainA.(*polkadot.PolkadotChain) - cosmosChain := chainB.(*cosmos.CosmosChain) + polkadotChain, ok := chainA.(*polkadot.PolkadotChain) + s.Require().True(ok) + + cosmosChain, ok := chainB.(*cosmos.CosmosChain) + s.Require().True(ok) // we explicitly skip path creation as the contract needs to be uploaded before we can create clients. r := s.ConfigureRelayer(ctx, polkadotChain, cosmosChain, nil, func(options *interchaintest.InterchainBuildOptions) { @@ -431,8 +440,11 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_ContractError_GrandpaContract( chainA, chainB := s.GetGrandpaTestChains() - polkadotChain := chainA.(*polkadot.PolkadotChain) - cosmosChain := chainB.(*cosmos.CosmosChain) + polkadotChain, ok := chainA.(*polkadot.PolkadotChain) + s.Require().True(ok) + + cosmosChain, ok := chainB.(*cosmos.CosmosChain) + s.Require().True(ok) // we explicitly skip path creation as the contract needs to be uploaded before we can create clients. r := s.ConfigureRelayer(ctx, polkadotChain, cosmosChain, nil, func(options *interchaintest.InterchainBuildOptions) { @@ -523,8 +535,11 @@ func (s *GrandpaTestSuite) TestRecoverClient_Succeeds_GrandpaContract() { chainA, chainB := s.GetGrandpaTestChains() - polkadotChain := chainA.(*polkadot.PolkadotChain) - cosmosChain := chainB.(*cosmos.CosmosChain) + polkadotChain, ok := chainA.(*polkadot.PolkadotChain) + s.Require().True(ok) + + cosmosChain, ok := chainB.(*cosmos.CosmosChain) + s.Require().True(ok) // we explicitly skip path creation as the contract needs to be uploaded before we can create clients. r := s.ConfigureRelayer(ctx, polkadotChain, cosmosChain, nil, func(options *interchaintest.InterchainBuildOptions) { diff --git a/e2e/testsuite/testconfig.go b/e2e/testsuite/testconfig.go index 3da52060b06..c5f04e59c89 100644 --- a/e2e/testsuite/testconfig.go +++ b/e2e/testsuite/testconfig.go @@ -741,7 +741,10 @@ func modifyChannelGenesisAppState(ibcAppState []byte) ([]byte, error) { } // be ashamed, be very ashamed - channelGenesis := ibcGenesisMap["channel_genesis"].(map[string]interface{}) + channelGenesis, ok := ibcGenesisMap["channel_genesis"].(map[string]interface{}) + if !ok { + return nil, fmt.Errorf("can't convert ibcGenesisMap entry into map[string]interface{} type") + } delete(channelGenesis, "params") return json.Marshal(ibcGenesisMap) From 7884433fa22f456e6c1e1c3c9682a6cc0fb4c3e7 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 9 Apr 2024 09:07:28 +0100 Subject: [PATCH 2/3] Update e2e/testsuite/testconfig.go Co-authored-by: Carlos Rodriguez --- e2e/testsuite/testconfig.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/testsuite/testconfig.go b/e2e/testsuite/testconfig.go index c5f04e59c89..daa626a0c04 100644 --- a/e2e/testsuite/testconfig.go +++ b/e2e/testsuite/testconfig.go @@ -743,7 +743,7 @@ func modifyChannelGenesisAppState(ibcAppState []byte) ([]byte, error) { // be ashamed, be very ashamed channelGenesis, ok := ibcGenesisMap["channel_genesis"].(map[string]interface{}) if !ok { - return nil, fmt.Errorf("can't convert ibcGenesisMap entry into map[string]interface{} type") + return nil, fmt.Errorf("can't convert IBC genesis map entry into type %T", &map[string]interface{}) } delete(channelGenesis, "params") From aecca122724b032984c37626990218ad2d89bdae Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 9 Apr 2024 09:14:48 +0100 Subject: [PATCH 3/3] Use aux variable to print type --- e2e/testsuite/testconfig.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e/testsuite/testconfig.go b/e2e/testsuite/testconfig.go index daa626a0c04..efe4eef9300 100644 --- a/e2e/testsuite/testconfig.go +++ b/e2e/testsuite/testconfig.go @@ -740,10 +740,11 @@ func modifyChannelGenesisAppState(ibcAppState []byte) ([]byte, error) { return nil, err } + var channelGenesis map[string]interface{} // be ashamed, be very ashamed channelGenesis, ok := ibcGenesisMap["channel_genesis"].(map[string]interface{}) if !ok { - return nil, fmt.Errorf("can't convert IBC genesis map entry into type %T", &map[string]interface{}) + return nil, fmt.Errorf("can't convert IBC genesis map entry into type %T", &channelGenesis) } delete(channelGenesis, "params")