From c403bb272311558753ac578af26e37b923358d72 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 20:17:05 +0700 Subject: [PATCH 01/23] lint tests --- .golangci.yml | 4 +--- modules/apps/27-interchain-accounts/types/codec_test.go | 7 ------- modules/core/04-channel/types/msgs_test.go | 3 ++- modules/core/23-commitment/types/merkle_test.go | 8 ++++---- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 19c59963c96..1b451e6cbe3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,12 +1,11 @@ run: - tests: false + tests: true # # timeout for analysis, e.g. 30s, 5m, default is 1m timeout: 5m linters: disable-all: true enable: - - deadcode - depguard - dogsled - exportloopref @@ -14,7 +13,6 @@ linters: - goconst - gocritic - gofumpt - - goimports - gosec - gosimple - govet diff --git a/modules/apps/27-interchain-accounts/types/codec_test.go b/modules/apps/27-interchain-accounts/types/codec_test.go index 301488b9ec7..c0cb9927f03 100644 --- a/modules/apps/27-interchain-accounts/types/codec_test.go +++ b/modules/apps/27-interchain-accounts/types/codec_test.go @@ -11,13 +11,6 @@ import ( "github.com/cosmos/ibc-go/v6/testing/simapp" ) -// caseRawBytes defines a helper struct, used for testing codec operations -type caseRawBytes struct { - name string - bz []byte - expPass bool -} - // mockSdkMsg defines a mock struct, used for testing codec error scenarios type mockSdkMsg struct{} diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index 661e17eefa7..f4c3d25c2d5 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -80,7 +80,8 @@ func (suite *TypesTestSuite) SetupTest() { storeKey := storetypes.NewKVStoreKey("iavlStoreKey") store.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, nil) - store.LoadVersion(0) + err := store.LoadVersion(0) + suite.Require().NoError(err) iavlStore := store.GetCommitStore(storeKey).(*iavl.Store) iavlStore.Set([]byte("KEY"), []byte("VALUE")) diff --git a/modules/core/23-commitment/types/merkle_test.go b/modules/core/23-commitment/types/merkle_test.go index 4c8a83b5834..721d535c923 100644 --- a/modules/core/23-commitment/types/merkle_test.go +++ b/modules/core/23-commitment/types/merkle_test.go @@ -64,10 +64,10 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { err := proof.VerifyMembership(types.GetSDKSpecs(), &root, path, tc.value) if tc.shouldPass { - // nolint: scopelint + //nolint: scopelint suite.Require().NoError(err, "test case %d should have passed", i) } else { - // nolint: scopelint + //nolint: scopelint suite.Require().Error(err, "test case %d should have failed", i) } }) @@ -127,10 +127,10 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { err := proof.VerifyNonMembership(types.GetSDKSpecs(), &root, path) if tc.shouldPass { - // nolint: scopelint + //nolint: scopelint suite.Require().NoError(err, "test case %d should have passed", i) } else { - // nolint: scopelint + //nolint: scopelint suite.Require().Error(err, "test case %d should have failed", i) } }) From 07c1d2b0833638a1eee0e23ea51b2ad4bdae54b1 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 20:19:49 +0700 Subject: [PATCH 02/23] don't use prealloc for golangci --- .golangci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 1b451e6cbe3..f8b41a60efe 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -19,7 +19,6 @@ linters: - ineffassign - misspell - nakedret - - prealloc - staticcheck - stylecheck - revive From 7b0c5b3a85f2c8d5ebb9483cebb4c7c5e58852e5 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 20:22:24 +0700 Subject: [PATCH 03/23] fix unnecessary conversions --- modules/apps/29-fee/types/msgs_test.go | 4 ++-- modules/apps/transfer/keeper/mbt_relay_test.go | 2 +- modules/light-clients/07-tendermint/proposal_handle_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 05dcc84ec46..d11202e57ca 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -84,7 +84,7 @@ func TestMsgRegisterPayeeValidation(t *testing.T) { func TestRegisterPayeeGetSigners(t *testing.T) { accAddress := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) msg := types.NewMsgRegisterPayee(ibctesting.MockPort, ibctesting.FirstChannelID, accAddress.String(), defaultAccAddress) - require.Equal(t, []sdk.AccAddress{sdk.AccAddress(accAddress)}, msg.GetSigners()) + require.Equal(t, []sdk.AccAddress{accAddress}, msg.GetSigners()) } func TestMsgRegisterCountepartyPayeeValidation(t *testing.T) { @@ -155,7 +155,7 @@ func TestMsgRegisterCountepartyPayeeValidation(t *testing.T) { func TestRegisterCountepartyAddressGetSigners(t *testing.T) { accAddress := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) msg := types.NewMsgRegisterCounterpartyPayee(ibctesting.MockPort, ibctesting.FirstChannelID, accAddress.String(), defaultAccAddress) - require.Equal(t, []sdk.AccAddress{sdk.AccAddress(accAddress)}, msg.GetSigners()) + require.Equal(t, []sdk.AccAddress{accAddress}, msg.GetSigners()) } func TestMsgPayPacketFeeValidation(t *testing.T) { diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index ff44c9a679b..e2d326677d7 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -290,7 +290,7 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { if err != nil { panic(fmt.Errorf("Failed to read JSON test fixture: %w", err)) } - err = json.Unmarshal([]byte(jsonBlob), &tlaTestCases) + err = json.Unmarshal(jsonBlob, &tlaTestCases) if err != nil { panic(fmt.Errorf("Failed to parse JSON test fixture: %w", err)) } diff --git a/modules/light-clients/07-tendermint/proposal_handle_test.go b/modules/light-clients/07-tendermint/proposal_handle_test.go index 6a8a8102bee..98b5134cddd 100644 --- a/modules/light-clients/07-tendermint/proposal_handle_test.go +++ b/modules/light-clients/07-tendermint/proposal_handle_test.go @@ -202,8 +202,8 @@ func (suite *TendermintTestSuite) TestIsMatchingClientState() { }, { "matching, trusting period is different", func() { - subjectClientState.TrustingPeriod = time.Duration(time.Hour * 10) - substituteClientState.TrustingPeriod = time.Duration(time.Hour * 1) + subjectClientState.TrustingPeriod = time.Hour * 10 + substituteClientState.TrustingPeriod = time.Hour * 1 }, true, }, { From 7e477b245c90c951b2f18720da97cd638edd279f Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 20:24:42 +0700 Subject: [PATCH 04/23] var-declaration lints --- .../controller/keeper/keeper_test.go | 12 ++++++------ .../host/keeper/keeper_test.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go index fc4428ce68a..02f9bfd5da8 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go @@ -157,8 +157,8 @@ func (suite *KeeperTestSuite) TestGetInterchainAccountAddress() { func (suite *KeeperTestSuite) TestGetAllActiveChannels() { var ( - expectedChannelID string = "test-channel" - expectedPortID string = "test-port" + expectedChannelID = "test-channel" + expectedPortID = "test-port" ) suite.SetupTest() @@ -193,8 +193,8 @@ func (suite *KeeperTestSuite) TestGetAllActiveChannels() { func (suite *KeeperTestSuite) TestGetAllInterchainAccounts() { var ( - expectedAccAddr string = "test-acc-addr" - expectedPortID string = "test-port" + expectedAccAddr = "test-acc-addr" + expectedPortID = "test-port" ) suite.SetupTest() @@ -245,8 +245,8 @@ func (suite *KeeperTestSuite) TestIsActiveChannel() { func (suite *KeeperTestSuite) TestSetInterchainAccountAddress() { var ( - expectedAccAddr string = "test-acc-addr" - expectedPortID string = "test-port" + expectedAccAddr = "test-acc-addr" + expectedPortID = "test-port" ) suite.chainA.GetSimApp().ICAControllerKeeper.SetInterchainAccountAddress(suite.chainA.GetContext(), ibctesting.FirstConnectionID, expectedPortID, expectedAccAddr) diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go index 7007a1bb6f7..e72af25d842 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -141,8 +141,8 @@ func (suite *KeeperTestSuite) TestGetInterchainAccountAddress() { func (suite *KeeperTestSuite) TestGetAllActiveChannels() { var ( - expectedChannelID string = "test-channel" - expectedPortID string = "test-port" + expectedChannelID = "test-channel" + expectedPortID = "test-port" ) suite.SetupTest() @@ -175,8 +175,8 @@ func (suite *KeeperTestSuite) TestGetAllActiveChannels() { func (suite *KeeperTestSuite) TestGetAllInterchainAccounts() { var ( - expectedAccAddr string = "test-acc-addr" - expectedPortID string = "test-port" + expectedAccAddr = "test-acc-addr" + expectedPortID = "test-port" ) suite.SetupTest() @@ -225,8 +225,8 @@ func (suite *KeeperTestSuite) TestIsActiveChannel() { func (suite *KeeperTestSuite) TestSetInterchainAccountAddress() { var ( - expectedAccAddr string = "test-acc-addr" - expectedPortID string = "test-port" + expectedAccAddr = "test-acc-addr" + expectedPortID = "test-port" ) suite.chainB.GetSimApp().ICAHostKeeper.SetInterchainAccountAddress(suite.chainB.GetContext(), ibctesting.FirstConnectionID, expectedPortID, expectedAccAddr) From 3c5432dd8c8d80c29be6217e256f14ac26ba3faf Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 20:26:16 +0700 Subject: [PATCH 05/23] fix ineffectual assignments --- modules/core/02-client/keeper/client_test.go | 1 + modules/core/02-client/keeper/params_test.go | 2 +- modules/core/03-connection/keeper/params_test.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/core/02-client/keeper/client_test.go b/modules/core/02-client/keeper/client_test.go index 12acddb4ff1..837083b1a93 100644 --- a/modules/core/02-client/keeper/client_test.go +++ b/modules/core/02-client/keeper/client_test.go @@ -430,6 +430,7 @@ func (suite *KeeperTestSuite) TestUpdateClientEventEmission() { path.EndpointA.ClientID, header, suite.chainA.SenderAccount.GetAddress().String(), ) + suite.Require().NoError(err) result, err := suite.chainA.SendMsgs(msg) suite.Require().NoError(err) diff --git a/modules/core/02-client/keeper/params_test.go b/modules/core/02-client/keeper/params_test.go index 180757050f5..a153413b622 100644 --- a/modules/core/02-client/keeper/params_test.go +++ b/modules/core/02-client/keeper/params_test.go @@ -12,6 +12,6 @@ func (suite *KeeperTestSuite) TestParams() { expParams.AllowedClients = []string{} suite.chainA.App.GetIBCKeeper().ClientKeeper.SetParams(suite.chainA.GetContext(), expParams) - params = suite.chainA.App.GetIBCKeeper().ClientKeeper.GetParams(suite.chainA.GetContext()) + _ = suite.chainA.App.GetIBCKeeper().ClientKeeper.GetParams(suite.chainA.GetContext()) suite.Require().Empty(expParams.AllowedClients) } diff --git a/modules/core/03-connection/keeper/params_test.go b/modules/core/03-connection/keeper/params_test.go index 9371305d4b9..690d499a701 100644 --- a/modules/core/03-connection/keeper/params_test.go +++ b/modules/core/03-connection/keeper/params_test.go @@ -12,6 +12,6 @@ func (suite *KeeperTestSuite) TestParams() { expParams.MaxExpectedTimePerBlock = 10 suite.chainA.App.GetIBCKeeper().ConnectionKeeper.SetParams(suite.chainA.GetContext(), expParams) - params = suite.chainA.App.GetIBCKeeper().ConnectionKeeper.GetParams(suite.chainA.GetContext()) + _ = suite.chainA.App.GetIBCKeeper().ConnectionKeeper.GetParams(suite.chainA.GetContext()) suite.Require().Equal(uint64(10), expParams.MaxExpectedTimePerBlock) } From 7666a6bbbdfe816182eab3bdcba333b8c53ad610 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 20:29:55 +0700 Subject: [PATCH 06/23] fix composite literal lints --- modules/core/02-client/keeper/client_test.go | 2 +- modules/core/02-client/keeper/keeper_test.go | 4 ++-- modules/core/02-client/types/genesis_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/core/02-client/keeper/client_test.go b/modules/core/02-client/keeper/client_test.go index 837083b1a93..528fc5ab9f8 100644 --- a/modules/core/02-client/keeper/client_test.go +++ b/modules/core/02-client/keeper/client_test.go @@ -23,7 +23,7 @@ func (suite *KeeperTestSuite) TestCreateClient() { expPass bool }{ {"success", ibctm.NewClientState(testChainID, ibctm.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath), true}, - {"client type not supported", solomachine.NewClientState(0, &solomachine.ConsensusState{suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, suite.solomachine.Time}), false}, + {"client type not supported", solomachine.NewClientState(0, &solomachine.ConsensusState{PublicKey: suite.solomachine.ConsensusState().PublicKey, Diversifier: suite.solomachine.Diversifier, Timestamp: suite.solomachine.Time}), false}, } for i, tc := range cases { diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 539c14a3899..1a680f2e434 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -190,7 +190,7 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() { }, { "invalid client type", - solomachine.NewClientState(0, &solomachine.ConsensusState{suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, suite.solomachine.Time}), + solomachine.NewClientState(0, &solomachine.ConsensusState{PublicKey: suite.solomachine.ConsensusState().PublicKey, Diversifier: suite.solomachine.Diversifier, Timestamp: suite.solomachine.Time}), false, }, { @@ -205,7 +205,7 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() { }, { "invalid trust level", - ibctm.NewClientState(suite.chainA.ChainID, ibctm.Fraction{0, 1}, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath), false, + ibctm.NewClientState(suite.chainA.ChainID, ibctm.Fraction{Numerator: 0, Denominator: 1}, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath), false, }, { "invalid unbonding period", diff --git a/modules/core/02-client/types/genesis_test.go b/modules/core/02-client/types/genesis_test.go index 4ab4fd90b98..5f7c0b2600c 100644 --- a/modules/core/02-client/types/genesis_test.go +++ b/modules/core/02-client/types/genesis_test.go @@ -114,7 +114,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { types.NewIdentifiedClientState( soloMachineClientID, ibctm.NewClientState(suite.chainA.ChainID, ibctm.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath), ), - types.NewIdentifiedClientState(tmClientID0, solomachine.NewClientState(0, &solomachine.ConsensusState{suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, suite.solomachine.Time})), + types.NewIdentifiedClientState(tmClientID0, solomachine.NewClientState(0, &solomachine.ConsensusState{PublicKey: suite.solomachine.ConsensusState().PublicKey, Diversifier: suite.solomachine.Diversifier, Timestamp: suite.solomachine.Time})), }, nil, nil, From 54598dcdd971397715c0331bf6ed354f7f911ab5 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 20:33:14 +0700 Subject: [PATCH 07/23] address copylocks lints from govet --- modules/core/02-client/keeper/keeper_test.go | 12 ++++++------ modules/core/03-connection/keeper/keeper_test.go | 4 ++-- modules/core/04-channel/keeper/keeper_test.go | 6 +++--- .../core/04-channel/types/acknowledgement_test.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 1a680f2e434..3785e77258e 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -234,7 +234,7 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() { } } -func (suite KeeperTestSuite) TestGetAllGenesisClients() { +func (suite KeeperTestSuite) TestGetAllGenesisClients() { //nolint:govet // this is a test, we are okay with copying locks clientIDs := []string{ testClientID2, testClientID3, testClientID, } @@ -256,7 +256,7 @@ func (suite KeeperTestSuite) TestGetAllGenesisClients() { suite.Require().Equal(expGenClients.Sort(), genClients) } -func (suite KeeperTestSuite) TestGetAllGenesisMetadata() { +func (suite KeeperTestSuite) TestGetAllGenesisMetadata() { //nolint:govet // this is a test, we are okay with copying locks expectedGenMetadata := []types.IdentifiedGenesisMetadata{ types.NewIdentifiedGenesisMetadata( "07-tendermint-1", @@ -286,7 +286,7 @@ func (suite KeeperTestSuite) TestGetAllGenesisMetadata() { suite.Require().Equal(expectedGenMetadata, actualGenMetadata, "retrieved metadata is unexpected") } -func (suite KeeperTestSuite) TestGetConsensusState() { +func (suite KeeperTestSuite) TestGetConsensusState() { //nolint:govet // this is a test, we are okay with copying locks suite.ctx = suite.ctx.WithBlockHeight(10) cases := []struct { name string @@ -312,7 +312,7 @@ func (suite KeeperTestSuite) TestGetConsensusState() { } } -func (suite KeeperTestSuite) TestConsensusStateHelpers() { +func (suite KeeperTestSuite) TestConsensusStateHelpers() { //nolint:govet // this is a test, we are okay with copying locks // initial setup clientState := ibctm.NewClientState(testChainID, ibctm.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath) @@ -338,7 +338,7 @@ func (suite KeeperTestSuite) TestConsensusStateHelpers() { // 2 clients in total are created on chainA. The first client is updated so it contains an initial consensus state // and a consensus state at the update height. -func (suite KeeperTestSuite) TestGetAllConsensusStates() { +func (suite KeeperTestSuite) TestGetAllConsensusStates() { //nolint:govet // this is a test, we are okay with copying locks path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path) @@ -387,7 +387,7 @@ func (suite KeeperTestSuite) TestGetAllConsensusStates() { suite.Require().Equal(expConsensusStates, consStates, "%s \n\n%s", expConsensusStates, consStates) } -func (suite KeeperTestSuite) TestIterateClientStates() { +func (suite KeeperTestSuite) TestIterateClientStates() { //nolint:govet // this is a test, we are okay with copying locks paths := []*ibctesting.Path{ ibctesting.NewPath(suite.chainA, suite.chainB), ibctesting.NewPath(suite.chainA, suite.chainB), diff --git a/modules/core/03-connection/keeper/keeper_test.go b/modules/core/03-connection/keeper/keeper_test.go index bbe264ec5e3..d30362200a1 100644 --- a/modules/core/03-connection/keeper/keeper_test.go +++ b/modules/core/03-connection/keeper/keeper_test.go @@ -60,7 +60,7 @@ func (suite *KeeperTestSuite) TestSetAndGetClientConnectionPaths() { } // create 2 connections: A0 - B0, A1 - B1 -func (suite KeeperTestSuite) TestGetAllConnections() { +func (suite KeeperTestSuite) TestGetAllConnections() { //nolint:govet // this is a test, we are okay with copying locks path1 := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupConnections(path1) @@ -88,7 +88,7 @@ func (suite KeeperTestSuite) TestGetAllConnections() { // the test creates 2 clients path.EndpointA.ClientID0 and path.EndpointA.ClientID1. path.EndpointA.ClientID0 has a single // connection and path.EndpointA.ClientID1 has 2 connections. -func (suite KeeperTestSuite) TestGetAllClientConnectionPaths() { +func (suite KeeperTestSuite) TestGetAllClientConnectionPaths() { //nolint:govet // this is a test, we are okay with copying locks path1 := ibctesting.NewPath(suite.chainA, suite.chainB) path2 := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupConnections(path1) diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index 422eb28bd36..d40d8bb4687 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -165,7 +165,7 @@ func containsAll(expected, actual []types.IdentifiedChannel) bool { // TestGetAllChannels creates multiple channels on chain A through various connections // and tests their retrieval. 2 channels are on connA0 and 1 channel is on connA1 -func (suite KeeperTestSuite) TestGetAllChannels() { +func (suite KeeperTestSuite) TestGetAllChannels() { //nolint:govet // this is a test, we are okay with copying locks path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) // channel0 on first connection on chainA @@ -229,7 +229,7 @@ func (suite KeeperTestSuite) TestGetAllChannels() { // TestGetAllSequences sets all packet sequences for two different channels on chain A and // tests their retrieval. -func (suite KeeperTestSuite) TestGetAllSequences() { +func (suite KeeperTestSuite) TestGetAllSequences() { //nolint:govet // this is a test, we are okay with copying locks path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) @@ -271,7 +271,7 @@ func (suite KeeperTestSuite) TestGetAllSequences() { // TestGetAllPacketState creates a set of acks, packet commitments, and receipts on two different // channels on chain A and tests their retrieval. -func (suite KeeperTestSuite) TestGetAllPacketState() { +func (suite KeeperTestSuite) TestGetAllPacketState() { //nolint:govet // this is a test, we are okay with copying locks path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) diff --git a/modules/core/04-channel/types/acknowledgement_test.go b/modules/core/04-channel/types/acknowledgement_test.go index 97fa8f9a34d..7b93f2ed404 100644 --- a/modules/core/04-channel/types/acknowledgement_test.go +++ b/modules/core/04-channel/types/acknowledgement_test.go @@ -17,7 +17,7 @@ const ( ) // tests acknowledgement.ValidateBasic and acknowledgement.GetBytes -func (suite TypesTestSuite) TestAcknowledgement() { +func (suite TypesTestSuite) TestAcknowledgement() { //nolint:govet // this is a test, we are okay with copying locks testCases := []struct { name string ack types.Acknowledgement From 79bf5fac5c3ee7e4d188a2c61fa1411e1008f149 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 20:50:03 +0700 Subject: [PATCH 08/23] error checks in tests --- .../controller/ibc_middleware_test.go | 9 ++++++--- .../controller/keeper/handshake_test.go | 2 +- .../27-interchain-accounts/host/ibc_module_test.go | 9 ++++++--- modules/apps/29-fee/ibc_middleware_test.go | 10 ++++++---- modules/apps/29-fee/keeper/msg_server_test.go | 2 +- modules/apps/transfer/keeper/migrations_test.go | 2 +- modules/apps/transfer/keeper/relay_test.go | 2 +- modules/core/02-client/keeper/grpc_query_test.go | 3 ++- modules/core/02-client/keeper/proposal_test.go | 7 ++++--- modules/core/03-connection/keeper/handshake_test.go | 3 ++- modules/core/03-connection/types/msgs_test.go | 3 ++- modules/core/23-commitment/types/commitment_test.go | 3 ++- testing/chain_test.go | 10 ++++++---- testing/mock/privval_test.go | 6 ++++-- 14 files changed, 44 insertions(+), 27 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index 7f727a3a594..5f951e72168 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -209,7 +209,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { suite.Require().NoError(err) portCap := suite.chainA.GetSimApp().IBCKeeper.PortKeeper.BindPort(suite.chainA.GetContext(), portID) - suite.chainA.GetSimApp().ICAControllerKeeper.ClaimCapability(suite.chainA.GetContext(), portCap, host.PortPath(portID)) + suite.chainA.GetSimApp().ICAControllerKeeper.ClaimCapability(suite.chainA.GetContext(), portCap, host.PortPath(portID)) //nolint:errcheck // checking this error isn't needed for the test path.EndpointA.ChannelConfig.PortID = portID path.EndpointA.ChannelID = ibctesting.FirstChannelID @@ -276,7 +276,9 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenTry() { err = RegisterInterchainAccount(path.EndpointB, TestOwnerAddress) suite.Require().NoError(err) - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) + channelKey := host.ChannelKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) proofInit, proofHeight := path.EndpointB.Chain.QueryProof(channelKey) @@ -420,7 +422,8 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenConfirm() { // commit state changes so proof can be created suite.chainB.NextBlock() - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) // query proof from ChainB channelKey := host.ChannelKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 8bf395f2405..c808bc7e738 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -237,7 +237,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { suite.Require().NoError(err) portCap := suite.chainA.GetSimApp().IBCKeeper.PortKeeper.BindPort(suite.chainA.GetContext(), portID) - suite.chainA.GetSimApp().ICAControllerKeeper.ClaimCapability(suite.chainA.GetContext(), portCap, host.PortPath(portID)) + suite.chainA.GetSimApp().ICAControllerKeeper.ClaimCapability(suite.chainA.GetContext(), portCap, host.PortPath(portID)) //nolint:errcheck // this error check isn't needed for tests path.EndpointA.ChannelConfig.PortID = portID // default values diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index 02c085b4106..535420ccfad 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -251,7 +251,8 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenAck() { // commit state changes so proof can be created suite.chainA.NextBlock() - path.EndpointB.UpdateClient() + err = path.EndpointB.UpdateClient() + suite.Require().NoError(err) // query proof from ChainA channelKey := host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) @@ -668,7 +669,8 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) - path.EndpointB.UpdateClient() + err = path.EndpointB.UpdateClient() + suite.Require().NoError(err) // relay the packet packetRelay := channeltypes.NewPacket(icaPacketData.GetBytes(), 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.ZeroHeight(), ^uint64(0)) @@ -694,7 +696,8 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) - path.EndpointB.UpdateClient() + err = path.EndpointB.UpdateClient() + suite.Require().NoError(err) // relay the packet packetRelay = channeltypes.NewPacket(icaPacketData.GetBytes(), 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.ZeroHeight(), ^uint64(0)) diff --git a/modules/apps/29-fee/ibc_middleware_test.go b/modules/apps/29-fee/ibc_middleware_test.go index ea416379e47..88ccca8a414 100644 --- a/modules/apps/29-fee/ibc_middleware_test.go +++ b/modules/apps/29-fee/ibc_middleware_test.go @@ -172,7 +172,8 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { // reset suite suite.SetupTest() suite.coordinator.SetupConnections(suite.path) - suite.path.EndpointB.ChanOpenInit() + err := suite.path.EndpointB.ChanOpenInit() + suite.Require().NoError(err) // setup mock callback suite.chainA.GetSimApp().FeeMockModule.IBCApp.OnChanOpenTry = func(ctx sdk.Context, order channeltypes.Order, connectionHops []string, @@ -188,7 +189,6 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { var ( chanCap *capabilitytypes.Capability ok bool - err error ) chanCap, err = suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)) @@ -286,8 +286,10 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { // malleate test case tc.malleate(suite) - suite.path.EndpointA.ChanOpenInit() - suite.path.EndpointB.ChanOpenTry() + err := suite.path.EndpointA.ChanOpenInit() + suite.Require().NoError(err) + err = suite.path.EndpointB.ChanOpenTry() + suite.Require().NoError(err) module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index 7f8f08744d8..a213e925063 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -200,7 +200,7 @@ func (suite *KeeperTestSuite) TestPayPacketFee() { { "refund account is module account", func() { - suite.chainA.GetSimApp().BankKeeper.SendCoinsFromAccountToModule(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibcmock.ModuleName, fee.Total()) + suite.chainA.GetSimApp().BankKeeper.SendCoinsFromAccountToModule(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibcmock.ModuleName, fee.Total()) //nolint:errcheck // ignore error for testing msg.Signer = suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(ibcmock.ModuleName).String() expPacketFee := types.NewPacketFee(fee, msg.Signer, nil) expFeesInEscrow = []types.PacketFee{expPacketFee} diff --git a/modules/apps/transfer/keeper/migrations_test.go b/modules/apps/transfer/keeper/migrations_test.go index 3c43743b023..48e7b0aa7ae 100644 --- a/modules/apps/transfer/keeper/migrations_test.go +++ b/modules/apps/transfer/keeper/migrations_test.go @@ -116,6 +116,6 @@ func (suite *KeeperTestSuite) TestMigratorMigrateTracesCorruptionDetection() { migrator := transferkeeper.NewMigrator(suite.chainA.GetSimApp().TransferKeeper) suite.Panics(func() { - migrator.MigrateTraces(suite.chainA.GetContext()) + migrator.MigrateTraces(suite.chainA.GetContext()) //nolint:errcheck // we shouldn't check the error here because we want to ensure that a panic occurs. }) } diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index 14d033b7873..303cd34a665 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -92,7 +92,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { cap := suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) // Release channel capability - suite.chainA.GetSimApp().ScopedTransferKeeper.ReleaseCapability(suite.chainA.GetContext(), cap) + suite.chainA.GetSimApp().ScopedTransferKeeper.ReleaseCapability(suite.chainA.GetContext(), cap) //nolint:errcheck // ignore error for testing }, false, }, { diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 10dc859bbe9..02fcbf58163 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -253,7 +253,8 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() { suite.Require().NoError(err) // update client to new height - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) req = &types.QueryConsensusStateRequest{ ClientId: path.EndpointA.ClientID, diff --git a/modules/core/02-client/keeper/proposal_test.go b/modules/core/02-client/keeper/proposal_test.go index 485174e8ec5..59ed99cfa22 100644 --- a/modules/core/02-client/keeper/proposal_test.go +++ b/modules/core/02-client/keeper/proposal_test.go @@ -15,7 +15,6 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() { subject, substitute string subjectClientState, substituteClientState exported.ClientState content govtypes.Content - err error ) testCases := []struct { @@ -114,8 +113,10 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() { substitute = substitutePath.EndpointA.ClientID // update substitute twice - substitutePath.EndpointA.UpdateClient() - substitutePath.EndpointA.UpdateClient() + err := substitutePath.EndpointA.UpdateClient() + suite.Require().NoError(err) + err = substitutePath.EndpointA.UpdateClient() + suite.Require().NoError(err) substituteClientState = suite.chainA.GetClientState(substitute) tmClientState, ok := subjectClientState.(*ibctm.ClientState) diff --git a/modules/core/03-connection/keeper/handshake_test.go b/modules/core/03-connection/keeper/handshake_test.go index 1d51a4e6932..692eb7e2acd 100644 --- a/modules/core/03-connection/keeper/handshake_test.go +++ b/modules/core/03-connection/keeper/handshake_test.go @@ -112,7 +112,8 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { // commit in order for proof to return correct value suite.coordinator.CommitBlock(suite.chainA) - path.EndpointB.UpdateClient() + err = path.EndpointB.UpdateClient() + suite.Require().NoError(err) // retrieve client state of chainA to pass as counterpartyClient counterpartyClient = suite.chainA.GetClientState(path.EndpointA.ClientID) diff --git a/modules/core/03-connection/types/msgs_test.go b/modules/core/03-connection/types/msgs_test.go index 690a8bb721d..08ed2f3f657 100644 --- a/modules/core/03-connection/types/msgs_test.go +++ b/modules/core/03-connection/types/msgs_test.go @@ -52,7 +52,8 @@ func (suite *MsgTestSuite) SetupTest() { storeKey := storetypes.NewKVStoreKey("iavlStoreKey") store.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, nil) - store.LoadVersion(0) + err := store.LoadVersion(0) + suite.Require().NoError(err) iavlStore := store.GetCommitStore(storeKey).(*iavl.Store) iavlStore.Set([]byte("KEY"), []byte("VALUE")) diff --git a/modules/core/23-commitment/types/commitment_test.go b/modules/core/23-commitment/types/commitment_test.go index b46553cab47..ccc794579f8 100644 --- a/modules/core/23-commitment/types/commitment_test.go +++ b/modules/core/23-commitment/types/commitment_test.go @@ -27,7 +27,8 @@ func (suite *MerkleTestSuite) SetupTest() { suite.storeKey = storetypes.NewKVStoreKey("iavlStoreKey") suite.store.MountStoreWithDB(suite.storeKey, storetypes.StoreTypeIAVL, nil) - suite.store.LoadVersion(0) + err := suite.store.LoadVersion(0) + suite.Require().NoError(err) suite.iavlStore = suite.store.GetCommitStore(suite.storeKey).(*iavl.Store) } diff --git a/testing/chain_test.go b/testing/chain_test.go index 363964a7396..f97fe4d43a4 100644 --- a/testing/chain_test.go +++ b/testing/chain_test.go @@ -25,14 +25,16 @@ func TestChangeValSet(t *testing.T) { val := chainA.GetSimApp().StakingKeeper.GetValidators(chainA.GetContext(), 4) - chainA.GetSimApp().StakingKeeper.Delegate(chainA.GetContext(), chainA.SenderAccounts[1].SenderAccount.GetAddress(), + chainA.GetSimApp().StakingKeeper.Delegate(chainA.GetContext(), chainA.SenderAccounts[1].SenderAccount.GetAddress(), //nolint:errcheck // ignore error for test amount, types.Unbonded, val[1], true) - chainA.GetSimApp().StakingKeeper.Delegate(chainA.GetContext(), chainA.SenderAccounts[3].SenderAccount.GetAddress(), + chainA.GetSimApp().StakingKeeper.Delegate(chainA.GetContext(), chainA.SenderAccounts[3].SenderAccount.GetAddress(), //nolint:errcheck // ignore error for test amount2, types.Unbonded, val[3], true) coord.CommitBlock(chainA) // verify that update clients works even after validator update goes into effect - path.EndpointB.UpdateClient() - path.EndpointB.UpdateClient() + err := path.EndpointB.UpdateClient() + require.NoError(t, err) + err = path.EndpointB.UpdateClient() + require.NoError(t, err) } diff --git a/testing/mock/privval_test.go b/testing/mock/privval_test.go index 0a41acb843e..512dd5d9ead 100644 --- a/testing/mock/privval_test.go +++ b/testing/mock/privval_test.go @@ -24,7 +24,8 @@ func TestSignVote(t *testing.T) { pk, _ := pv.GetPubKey() vote := &tmproto.Vote{Height: 2} - pv.SignVote(chainID, vote) + err := pv.SignVote(chainID, vote) + require.NoError(t, err) msg := tmtypes.VoteSignBytes(chainID, vote) ok := pk.VerifySignature(msg, vote.Signature) @@ -36,7 +37,8 @@ func TestSignProposal(t *testing.T) { pk, _ := pv.GetPubKey() proposal := &tmproto.Proposal{Round: 2} - pv.SignProposal(chainID, proposal) + err := pv.SignProposal(chainID, proposal) + require.NoError(t, err) msg := tmtypes.ProposalSignBytes(chainID, proposal) ok := pk.VerifySignature(msg, proposal.Signature) From d6cd1993e8f4db0f2299bcd32653cc6401cddc2d Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 20:55:49 +0700 Subject: [PATCH 09/23] handshake_test.go error checks --- modules/core/02-client/keeper/proposal_test.go | 3 ++- .../core/03-connection/keeper/verify_test.go | 3 ++- .../core/04-channel/keeper/handshake_test.go | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/core/02-client/keeper/proposal_test.go b/modules/core/02-client/keeper/proposal_test.go index 59ed99cfa22..61fae3bc52a 100644 --- a/modules/core/02-client/keeper/proposal_test.go +++ b/modules/core/02-client/keeper/proposal_test.go @@ -219,7 +219,8 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() { bz, err := types.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClientState) suite.Require().NoError(err) - suite.chainA.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainA.GetContext(), oldPlan.Height, bz) + + suite.chainA.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainA.GetContext(), oldPlan.Height, bz) //nolint:errcheck } upgradeProp, ok := content.(*types.UpgradeProposal) diff --git a/modules/core/03-connection/keeper/verify_test.go b/modules/core/03-connection/keeper/verify_test.go index ce6fcf8e1e2..b6147793bb1 100644 --- a/modules/core/03-connection/keeper/verify_test.go +++ b/modules/core/03-connection/keeper/verify_test.go @@ -557,7 +557,8 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() { if clientState.FrozenHeight.IsZero() { // need to update height to prove absence or receipt suite.coordinator.CommitBlock(suite.chainA, suite.chainB) - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) } packetReceiptKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) diff --git a/modules/core/04-channel/keeper/handshake_test.go b/modules/core/04-channel/keeper/handshake_test.go index b607017f213..6a9a7973e11 100644 --- a/modules/core/04-channel/keeper/handshake_test.go +++ b/modules/core/04-channel/keeper/handshake_test.go @@ -152,7 +152,8 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { {"success", func() { suite.coordinator.SetupConnections(path) path.SetChannelOrdered() - path.EndpointA.ChanOpenInit() + err := path.EndpointA.ChanOpenInit() + suite.Require().NoError(err) suite.chainB.CreatePortCapability(suite.chainB.GetSimApp().ScopedIBCMockKeeper, ibctesting.MockPort) portCap = suite.chainB.GetPortCapability(ibctesting.MockPort) @@ -177,7 +178,8 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { {"consensus state not found", func() { suite.coordinator.SetupConnections(path) path.SetChannelOrdered() - path.EndpointA.ChanOpenInit() + err := path.EndpointA.ChanOpenInit() + suite.Require().NoError(err) suite.chainB.CreatePortCapability(suite.chainB.GetSimApp().ScopedIBCMockKeeper, ibctesting.MockPort) portCap = suite.chainB.GetPortCapability(ibctesting.MockPort) @@ -192,14 +194,16 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { {"port capability not found", func() { suite.coordinator.SetupConnections(path) path.SetChannelOrdered() - path.EndpointA.ChanOpenInit() + err := path.EndpointA.ChanOpenInit() + suite.Require().NoError(err) portCap = capabilitytypes.NewCapability(3) }, false}, {"connection version not negotiated", func() { suite.coordinator.SetupConnections(path) path.SetChannelOrdered() - path.EndpointA.ChanOpenInit() + err := path.EndpointA.ChanOpenInit() + suite.Require().NoError(err) // modify connB versions conn := path.EndpointB.GetConnection() @@ -217,7 +221,8 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { {"connection does not support ORDERED channels", func() { suite.coordinator.SetupConnections(path) path.SetChannelOrdered() - path.EndpointA.ChanOpenInit() + err := path.EndpointA.ChanOpenInit() + suite.Require().NoError(err) // modify connA versions to only support UNORDERED channels conn := path.EndpointA.GetConnection() @@ -405,7 +410,8 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { err := path.EndpointA.ChanOpenInit() suite.Require().NoError(err) - path.EndpointB.ChanOpenTry() + err = path.EndpointB.ChanOpenTry() + suite.Require().NoError(err) channelCap = capabilitytypes.NewCapability(6) }, false}, From e2b5a27e5e17356451b702b9ab75ab535ca57be2 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 20:57:23 +0700 Subject: [PATCH 10/23] packet_test.go error checks --- modules/core/04-channel/keeper/packet_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 754d1c80e74..6ffc8b25f85 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -436,8 +436,10 @@ func (suite *KeeperTestSuite) TestRecvPacket() { channelCap = suite.chainB.GetChannelCapability(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - path.EndpointA.UpdateClient() - path.EndpointB.UpdateClient() + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) + err = path.EndpointB.UpdateClient() + suite.Require().NoError(err) }, false}, {"receipt already stored", func() { expError = types.ErrNoOpMsg @@ -826,8 +828,10 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { suite.coordinator.CommitBlock(path.EndpointA.Chain, path.EndpointB.Chain) - path.EndpointA.UpdateClient() - path.EndpointB.UpdateClient() + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) + err = path.EndpointB.UpdateClient() + suite.Require().NoError(err) }, false}, {"next ack sequence mismatch ORDERED", func() { expError = types.ErrPacketSequenceOutOfOrder From 4cf6f9d08292f11fa73abb4a674187a50403a1f6 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 21:02:22 +0700 Subject: [PATCH 11/23] error checks --- .../core/04-channel/keeper/timeout_test.go | 68 +++++++++++++------ modules/core/keeper/msg_server_test.go | 3 +- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/modules/core/04-channel/keeper/timeout_test.go b/modules/core/04-channel/keeper/timeout_test.go index 200ad68199b..37995af55f4 100644 --- a/modules/core/04-channel/keeper/timeout_test.go +++ b/modules/core/04-channel/keeper/timeout_test.go @@ -40,7 +40,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) // need to update chainA's client representing chainB to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) }, true}, {"success: UNORDERED", func() { ordered = false @@ -52,7 +53,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) // need to update chainA's client representing chainB to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) }, true}, {"packet already timed out: ORDERED", func() { expError = types.ErrNoOpMsg @@ -66,7 +68,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) // need to update chainA's client representing chainB to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) err = path.EndpointA.TimeoutPacket(packet) @@ -82,7 +85,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) // need to update chainA's client representing chainB to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) err = path.EndpointA.TimeoutPacket(packet) @@ -104,7 +108,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) // need to update chainA's client representing chainB to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) err = path.EndpointA.SetChannelClosed() suite.Require().NoError(err) @@ -137,7 +142,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) }, false}, {"packet already received ", func() { expError = types.ErrPacketReceived @@ -151,7 +157,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, timeoutTimestamp) - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) }, false}, {"packet hasn't been sent", func() { expError = types.ErrNoOpMsg @@ -160,7 +167,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { suite.coordinator.Setup(path) packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, uint64(suite.chainB.GetContext().BlockTime().UnixNano())) - path.EndpointA.UpdateClient() + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) }, false}, {"next seq receive verification failed", func() { // skip error check, error occurs in light-clients @@ -176,7 +184,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) }, false}, {"packet ack verification failed", func() { // skip error check, error occurs in light-clients @@ -191,7 +200,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) }, false}, } @@ -322,9 +332,11 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) - path.EndpointB.SetChannelClosed() + err = path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) // need to update chainA's client representing chainB to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) chanCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) @@ -337,9 +349,11 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) - path.EndpointB.SetChannelClosed() + err = path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) // need to update chainA's client representing chainB to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) chanCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) @@ -392,9 +406,11 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) - path.EndpointB.SetChannelClosed() + err = path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) // need to update chainA's client representing chainB to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) chanCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) @@ -423,8 +439,11 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) - path.EndpointB.SetChannelClosed() - path.EndpointA.UpdateClient() + err = path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) + packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) chanCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) }, false}, @@ -437,8 +456,11 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) - path.EndpointB.SetChannelClosed() - path.EndpointA.UpdateClient() + err = path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) + packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) chanCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) }, false}, @@ -452,9 +474,11 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) - path.EndpointB.SetChannelClosed() + err = path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) // need to update chainA's client representing chainB to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) chanCap = capabilitytypes.NewCapability(100) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 9908abaabe3..a0784afb8da 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -370,7 +370,8 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { suite.Require().NoError(err) // need to update chainA client to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) From 0a247d8fd3a1f13cadf4a271e86b9715bb14789b Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 21:06:55 +0700 Subject: [PATCH 12/23] msg_server_test.go --- modules/core/keeper/msg_server_test.go | 54 +++++++++++++------ .../07-tendermint/update_test.go | 9 ++-- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index a0784afb8da..f6549db9269 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -387,7 +387,8 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { suite.Require().NoError(err) // need to update chainA client to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) @@ -408,7 +409,9 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0) } - path.EndpointA.UpdateClient() + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, true}, {"success: ORDERED timeout out of order packet", func() { @@ -427,7 +430,9 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0) } - path.EndpointA.UpdateClient() + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) + packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) }, true}, {"channel does not exist", func() { @@ -508,12 +513,15 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { suite.Require().NoError(err) // need to update chainA client to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) + packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0) packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) // close counterparty channel - path.EndpointB.SetChannelClosed() + err = path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) }, true}, {"success: UNORDERED", func() { suite.coordinator.Setup(path) @@ -523,12 +531,15 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { suite.Require().NoError(err) // need to update chainA client to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) + packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0) packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) // close counterparty channel - path.EndpointB.SetChannelClosed() + err = path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) }, true}, {"success: UNORDERED timeout out of order packet", func() { // setup uses an UNORDERED channel @@ -544,11 +555,14 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0) } - path.EndpointA.UpdateClient() + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) // close counterparty channel - path.EndpointB.SetChannelClosed() + err = path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) }, true}, {"success: ORDERED timeout out of order packet", func() { path.SetChannelOrdered() @@ -564,11 +578,14 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0) } - path.EndpointA.UpdateClient() + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) + packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) // close counterparty channel - path.EndpointB.SetChannelClosed() + err = path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) }, true}, {"channel does not exist", func() { // any non-nil value of packet is valid @@ -582,7 +599,8 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { packetKey = host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) // close counterparty channel - path.EndpointB.SetChannelClosed() + err := path.EndpointB.SetChannelClosed() + suite.Require().NoError(err) }, true}, {"ORDERED: channel not closed", func() { path.SetChannelOrdered() @@ -593,7 +611,9 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { suite.Require().NoError(err) // need to update chainA client to prove missing ack - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) + packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0) packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) }, false}, @@ -670,8 +690,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { suite.Require().NoError(err) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for testing + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for testing // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) @@ -710,8 +730,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { suite.Require().NoError(err) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for testing + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for testing // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) diff --git a/modules/light-clients/07-tendermint/update_test.go b/modules/light-clients/07-tendermint/update_test.go index 7da6ba3cf2c..e516112a061 100644 --- a/modules/light-clients/07-tendermint/update_test.go +++ b/modules/light-clients/07-tendermint/update_test.go @@ -491,7 +491,8 @@ func (suite *TendermintTestSuite) TestPruneConsensusState() { ibctm.IterateConsensusStateAscending(clientStore, getFirstHeightCb) // this height will be expired but not pruned - path.EndpointA.UpdateClient() + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) expiredHeight := path.EndpointA.GetClientState().GetLatestHeight() // expected values that must still remain in store after pruning @@ -510,12 +511,14 @@ func (suite *TendermintTestSuite) TestPruneConsensusState() { suite.coordinator.IncrementTimeBy(7 * 24 * time.Hour) // create the consensus state that can be used as trusted height for next update - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) // Increment the time by another week, then update the client. // This will cause the first two consensus states to become expired. suite.coordinator.IncrementTimeBy(7 * 24 * time.Hour) - path.EndpointA.UpdateClient() + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) ctx = path.EndpointA.Chain.GetContext() clientStore = path.EndpointA.Chain.App.GetIBCKeeper().ClientKeeper.ClientStore(ctx, path.EndpointA.ClientID) From d0ff51e447691fd089f82f6df42e7ee771795e29 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 21:11:13 +0700 Subject: [PATCH 13/23] errcheck in upgrade_test.go --- .../07-tendermint/upgrade_test.go | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/modules/light-clients/07-tendermint/upgrade_test.go b/modules/light-clients/07-tendermint/upgrade_test.go index f055e528802..dc1cc556b6f 100644 --- a/modules/light-clients/07-tendermint/upgrade_test.go +++ b/modules/light-clients/07-tendermint/upgrade_test.go @@ -34,8 +34,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for test // commit upgrade store changes and update clients @@ -63,8 +63,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for test // commit upgrade store changes and update clients @@ -88,8 +88,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+10)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for test // commit upgrade store changes and update clients @@ -117,8 +117,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for test // commit upgrade store changes and update clients @@ -141,8 +141,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for test // change upgradedClient client-specified parameters upgradedClient = ibctm.NewClientState("wrongchainID", ibctm.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath) @@ -163,8 +163,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: client-specified parameters do not match previous client", setup: func() { // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for test // change upgradedClient client-specified parameters upgradedClient = ibctm.NewClientState(newChainID, ibctm.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, lastHeight, commitmenttypes.GetSDKSpecs(), upgradePath) @@ -188,8 +188,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for test // change submitted upgradedConsensusState upgradedConsState = &ibctm.ConsensusState{ @@ -213,7 +213,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { { name: "unsuccessful upgrade: client proof unmarshal failed", setup: func() { - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for test cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().True(found) @@ -227,7 +227,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { { name: "unsuccessful upgrade: consensus state proof unmarshal failed", setup: func() { - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().True(found) @@ -246,7 +246,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { // upgrade Height is at next block lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for test cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().True(found) @@ -264,7 +264,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { // upgrade Height is at next block lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().True(found) @@ -281,7 +281,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test // commit upgrade store changes and update clients @@ -309,7 +309,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test // commit upgrade store changes and update clients @@ -332,7 +332,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+100)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for // commit upgrade store changes and update clients @@ -352,7 +352,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: client is expired", setup: func() { // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test // commit upgrade store changes and update clients @@ -378,7 +378,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for test // commit upgrade store changes and update clients @@ -406,8 +406,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) // zero custom fields and store in upgrade store - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) - suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz) //nolint:errcheck // ignore error for testing + suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) //nolint:errcheck // ignore error for testing // commit upgrade store changes and update clients From 856722643ef0803c13d445f52ebefd8982095c77 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 21:31:57 +0700 Subject: [PATCH 14/23] goconsts & linting complete --- cmd/build_test_matrix/main_test.go | 4 +- go.mod | 2 +- .../controller/keeper/handshake_test.go | 2 +- .../host/keeper/handshake_test.go | 2 +- modules/apps/29-fee/keeper/grpc_query_test.go | 4 +- modules/apps/29-fee/keeper/keeper_test.go | 6 +-- modules/apps/29-fee/keeper/msg_server_test.go | 4 +- modules/apps/29-fee/types/fee_test.go | 4 +- modules/apps/29-fee/types/msgs_test.go | 8 ++-- modules/apps/transfer/ibc_module_test.go | 2 +- .../apps/transfer/keeper/grpc_query_test.go | 4 +- .../apps/transfer/keeper/mbt_relay_test.go | 18 ++++---- modules/apps/transfer/keeper/relay_test.go | 2 +- modules/core/02-client/keeper/client_test.go | 45 +++++++++---------- modules/core/02-client/types/msgs_test.go | 2 +- .../core/04-channel/keeper/grpc_query_test.go | 6 ++- .../core/04-channel/keeper/handshake_test.go | 8 ++-- modules/core/04-channel/keeper/packet_test.go | 2 +- .../core/04-channel/keeper/timeout_test.go | 2 +- modules/core/24-host/validate_test.go | 4 +- .../06-solomachine/client_state_test.go | 2 +- .../06-solomachine/update_test.go | 2 +- .../07-tendermint/proposal_handle_test.go | 2 +- 23 files changed, 70 insertions(+), 67 deletions(-) diff --git a/cmd/build_test_matrix/main_test.go b/cmd/build_test_matrix/main_test.go index 9f765cfdc53..e680ac808c8 100644 --- a/cmd/build_test_matrix/main_test.go +++ b/cmd/build_test_matrix/main_test.go @@ -102,7 +102,7 @@ func SuiteTwo(t *testing.T) { type FeeMiddlewareTestSuite struct {} ` - err := os.WriteFile(path.Join(testingDir, goTestFileNameOne), []byte(fileWithTwoSuites), os.FileMode(777)) + err := os.WriteFile(path.Join(testingDir, goTestFileNameOne), []byte(fileWithTwoSuites), os.FileMode(0o777)) assert.NoError(t, err) _, err = getGithubActionMatrixForTests(testingDir, "", nil) @@ -156,6 +156,6 @@ func helper() {} func createFileWithTestSuiteAndTests(t *testing.T, suiteName, fn1Name, fn2Name, dir, filename string) { goFileContents := goTestFileContents(suiteName, fn1Name, fn2Name) - err := os.WriteFile(path.Join(dir, filename), []byte(goFileContents), os.FileMode(777)) + err := os.WriteFile(path.Join(dir, filename), []byte(goFileContents), os.FileMode(0o777)) assert.NoError(t, err) } diff --git a/go.mod b/go.mod index caf7821c07e..42ce5fb65b7 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ go 1.18 module github.com/cosmos/ibc-go/v6 require ( + cosmossdk.io/errors v1.0.0-beta.7 cosmossdk.io/math v1.0.0-beta.3 github.com/armon/go-metrics v0.4.1 github.com/confio/ics23/go v0.9.0 @@ -31,7 +32,6 @@ require ( cloud.google.com/go/compute/metadata v0.2.1 // indirect cloud.google.com/go/iam v0.4.0 // indirect cloud.google.com/go/storage v1.23.0 // indirect - cosmossdk.io/errors v1.0.0-beta.7 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index c808bc7e738..10c37cdc2b7 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -103,7 +103,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { { "invalid port ID", func() { - path.EndpointA.ChannelConfig.PortID = "invalid-port-id" + path.EndpointA.ChannelConfig.PortID = "invalid-port-id" //nolint:goconst }, false, }, diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 1aa18e20933..b1d5ab846f8 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -167,7 +167,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { { "invalid port ID", func() { - path.EndpointB.ChannelConfig.PortID = "invalid-port-id" + path.EndpointB.ChannelConfig.PortID = "invalid-port-id" //nolint:goconst }, false, }, diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 1a05b7e356e..b67f701b980 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -425,14 +425,14 @@ func (suite *KeeperTestSuite) TestQueryPayee() { { "payee address not found: invalid channel", func() { - req.ChannelId = "invalid-channel-id" + req.ChannelId = "invalid-channel-id" //nolint:goconst }, false, }, { "payee address not found: invalid relayer address", func() { - req.Relayer = "invalid-addr" + req.Relayer = "invalid-addr" //nolint:goconst }, false, }, diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 15b92cf3978..916c5d53efb 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -237,14 +237,14 @@ func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { } func (suite *KeeperTestSuite) TestGetAllFeeEnabledChannels() { - validPortId := "ibcmoduleport" + validPortID := "ibcmoduleport" // set two channels enabled suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), validPortId, ibctesting.FirstChannelID) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), validPortID, ibctesting.FirstChannelID) expectedCh := []types.FeeEnabledChannel{ { - PortId: validPortId, + PortId: validPortID, ChannelId: ibctesting.FirstChannelID, }, { diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index a213e925063..8bc9f5c0417 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -28,7 +28,7 @@ func (suite *KeeperTestSuite) TestRegisterPayee() { "channel does not exist", false, func() { - msg.ChannelId = "channel-100" + msg.ChannelId = "channel-100" //nolint:goconst }, }, { @@ -376,7 +376,7 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { { "packet not sent", func() { - msg.PacketId.Sequence = msg.PacketId.Sequence + 1 + msg.PacketId.Sequence++ }, false, }, diff --git a/modules/apps/29-fee/types/fee_test.go b/modules/apps/29-fee/types/fee_test.go index 0cdb5059ae1..61d3d256e14 100644 --- a/modules/apps/29-fee/types/fee_test.go +++ b/modules/apps/29-fee/types/fee_test.go @@ -27,6 +27,8 @@ var ( defaultAccAddress = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() ) +const invalidAddress = "invalid-address" + func TestFeeTotal(t *testing.T) { fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) @@ -57,7 +59,7 @@ func TestPacketFeeValidation(t *testing.T) { { "should fail when refund address is invalid", func() { - packetFee.RefundAddress = "invalid-address" + packetFee.RefundAddress = invalidAddress }, false, }, diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index d11202e57ca..e2078e9dddf 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -50,14 +50,14 @@ func TestMsgRegisterPayeeValidation(t *testing.T) { { "invalid relayer address", func() { - msg.Relayer = "invalid-address" + msg.Relayer = invalidAddress }, false, }, { "invalid payee address", func() { - msg.Payee = "invalid-address" + msg.Payee = invalidAddress }, false, }, @@ -117,7 +117,7 @@ func TestMsgRegisterCountepartyPayeeValidation(t *testing.T) { { "validate with incorrect destination relayer address", func() { - msg.Relayer = "invalid-address" + msg.Relayer = invalidAddress }, false, }, @@ -202,7 +202,7 @@ func TestMsgPayPacketFeeValidation(t *testing.T) { { "invalid signer address", func() { - msg.Signer = "invalid-address" + msg.Signer = invalidAddress }, false, }, diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index 80285049ec3..ea51fd3f4b1 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -50,7 +50,7 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { }, { "invalid version", func() { - channel.Version = "version" + channel.Version = "version" //nolint:goconst }, false, }, { diff --git a/modules/apps/transfer/keeper/grpc_query_test.go b/modules/apps/transfer/keeper/grpc_query_test.go index fcee1f63214..cc589d9ec4e 100644 --- a/modules/apps/transfer/keeper/grpc_query_test.go +++ b/modules/apps/transfer/keeper/grpc_query_test.go @@ -24,8 +24,8 @@ func (suite *KeeperTestSuite) TestQueryDenomTrace() { { "success: correct ibc denom", func() { - expTrace.Path = "transfer/channelToA/transfer/channelToB" - expTrace.BaseDenom = "uatom" + expTrace.Path = "transfer/channelToA/transfer/channelToB" //nolint:goconst + expTrace.BaseDenom = "uatom" //nolint:goconst suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace) req = &types.QueryDenomTraceRequest{ diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index e2d326677d7..7727877ef98 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -84,7 +84,7 @@ type OwnedCoin struct { } type Balance struct { - Id string + ID string Address string Denom string Amount math.Int @@ -99,7 +99,7 @@ func AddressFromTla(addr []string) string { panic("failed to convert from TLA+ address: wrong number of address components") } s := "" - if len(addr[0]) == 0 && len(addr[1]) == 0 { + if len(addr[0]) == 0 && len(addr[1]) == 0 { //nolint:gocritic // simple address: id s = addr[2] } else if len(addr[2]) == 0 { @@ -121,7 +121,7 @@ func DenomFromTla(denom []string) string { func BalanceFromTla(balance TlaBalance) Balance { return Balance{ - Id: AddressFromTla(balance.Address), + ID: AddressFromTla(balance.Address), Address: AddressFromString(AddressFromTla(balance.Address)), Denom: DenomFromTla(balance.Denom), Amount: sdk.NewInt(balance.Amount), @@ -201,7 +201,7 @@ func (bank *Bank) SetBalance(address string, denom string, amount math.Int) { func (bank *Bank) SetBalances(balances []Balance) { for _, balance := range balances { bank.balances[OwnedCoin{balance.Address, balance.Denom}] = balance.Amount - addressMap[balance.Address] = balance.Id + addressMap[balance.Address] = balance.ID } } @@ -219,7 +219,7 @@ func BankFromBalances(balances []Balance) Bank { coin := OwnedCoin{balance.Address, balance.Denom} if coin != NullCoin() { // ignore null coin bank.balances[coin] = balance.Amount - addressMap[balance.Address] = balance.Id + addressMap[balance.Address] = balance.ID } } return bank @@ -281,12 +281,12 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { if err != nil { panic(fmt.Errorf("Failed to read model-based test files: %w", err)) } - for _, file_info := range files { + for _, fileInfo := range files { tlaTestCases := []TlaOnRecvPacketTestCase{} - if !strings.HasSuffix(file_info.Name(), ".json") { + if !strings.HasSuffix(fileInfo.Name(), ".json") { continue } - jsonBlob, err := os.ReadFile(dirname + file_info.Name()) + jsonBlob, err := os.ReadFile(dirname + fileInfo.Name()) if err != nil { panic(fmt.Errorf("Failed to read JSON test fixture: %w", err)) } @@ -311,7 +311,7 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { } } - description := file_info.Name() + " # " + strconv.Itoa(i+1) + description := fileInfo.Name() + " # " + strconv.Itoa(i+1) suite.Run(fmt.Sprintf("Case %s", description), func() { seq := uint64(1) packet := channeltypes.NewPacket(tc.packet.Data.GetBytes(), seq, tc.packet.SourcePort, tc.packet.SourceChannel, tc.packet.DestPort, tc.packet.DestChannel, clienttypes.NewHeight(1, 100), 0) diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index 303cd34a665..57981d84d2a 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -36,7 +36,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { { "successful transfer from source chain with memo", func() { - memo = "memo" + memo = "memo" //nolint:goconst }, true, }, { diff --git a/modules/core/02-client/keeper/client_test.go b/modules/core/02-client/keeper/client_test.go index 528fc5ab9f8..43c3193af56 100644 --- a/modules/core/02-client/keeper/client_test.go +++ b/modules/core/02-client/keeper/client_test.go @@ -7,7 +7,6 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v6/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v6/modules/core/exported" @@ -67,7 +66,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { }{ {"valid update", func() { clientState := path.EndpointA.GetClientState().(*ibctm.ClientState) - trustHeight := clientState.GetLatestHeight().(types.Height) + trustHeight := clientState.GetLatestHeight().(clienttypes.Height) // store intermediate consensus state to check that trustedHeight does not need to be highest consensus state before header height err := path.EndpointA.UpdateClient() @@ -77,10 +76,10 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { }, true, false}, {"valid past update", func() { clientState := path.EndpointA.GetClientState() - trustedHeight := clientState.GetLatestHeight().(types.Height) + trustedHeight := clientState.GetLatestHeight().(clienttypes.Height) currHeight := suite.chainB.CurrentHeader.Height - fillHeight := types.NewHeight(clientState.GetLatestHeight().GetRevisionNumber(), uint64(currHeight)) + fillHeight := clienttypes.NewHeight(clientState.GetLatestHeight().GetRevisionNumber(), uint64(currHeight)) // commit a couple blocks to allow client to fill in gaps suite.coordinator.CommitBlock(suite.chainB) // this height is not filled in yet @@ -100,7 +99,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { {"valid duplicate update", func() { clientID := path.EndpointA.ClientID - height1 := types.NewHeight(1, 1) + height1 := clienttypes.NewHeight(1, 1) // store previous consensus state prevConsState := &ibctm.ConsensusState{ @@ -109,7 +108,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { } suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, height1, prevConsState) - height5 := types.NewHeight(1, 5) + height5 := clienttypes.NewHeight(1, 5) // store next consensus state to check that trustedHeight does not need to be hightest consensus state before header height nextConsState := &ibctm.ConsensusState{ Timestamp: suite.past.Add(time.Minute), @@ -117,7 +116,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { } suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, height5, nextConsState) - height3 := types.NewHeight(1, 3) + height3 := clienttypes.NewHeight(1, 3) // updateHeader will fill in consensus state between prevConsState and suite.consState // clientState should not be updated updateHeader = createPastUpdateFn(height3, height1) @@ -127,7 +126,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { {"misbehaviour detection: conflicting header", func() { clientID := path.EndpointA.ClientID - height1 := types.NewHeight(1, 1) + height1 := clienttypes.NewHeight(1, 1) // store previous consensus state prevConsState := &ibctm.ConsensusState{ Timestamp: suite.past, @@ -135,7 +134,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { } suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, height1, prevConsState) - height5 := types.NewHeight(1, 5) + height5 := clienttypes.NewHeight(1, 5) // store next consensus state to check that trustedHeight does not need to be hightest consensus state before header height nextConsState := &ibctm.ConsensusState{ Timestamp: suite.past.Add(time.Minute), @@ -143,7 +142,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { } suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, height5, nextConsState) - height3 := types.NewHeight(1, 3) + height3 := clienttypes.NewHeight(1, 3) // updateHeader will fill in consensus state between prevConsState and suite.consState // clientState should not be updated updateHeader = createPastUpdateFn(height3, height1) @@ -155,11 +154,11 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { {"misbehaviour detection: monotonic time violation", func() { clientState := path.EndpointA.GetClientState().(*ibctm.ClientState) clientID := path.EndpointA.ClientID - trustedHeight := clientState.GetLatestHeight().(types.Height) + trustedHeight := clientState.GetLatestHeight().(clienttypes.Height) // store intermediate consensus state at a time greater than updateHeader time // this will break time monotonicity - incrementedClientHeight := clientState.GetLatestHeight().Increment().(types.Height) + incrementedClientHeight := clientState.GetLatestHeight().Increment().(clienttypes.Height) intermediateConsState := &ibctm.ConsensusState{ Timestamp: suite.coordinator.CurrentTime.Add(2 * time.Hour), NextValidatorsHash: suite.chainB.Vals.Hash(), @@ -175,7 +174,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { updateHeader = createFutureUpdateFn(trustedHeight) }, true, true}, {"client state not found", func() { - updateHeader = createFutureUpdateFn(path.EndpointA.GetClientState().GetLatestHeight().(types.Height)) + updateHeader = createFutureUpdateFn(path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height)) path.EndpointA.ClientID = ibctesting.InvalidID }, false, false}, @@ -183,20 +182,20 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { clientState := path.EndpointA.GetClientState() tmClient, ok := clientState.(*ibctm.ClientState) suite.Require().True(ok) - tmClient.LatestHeight = tmClient.LatestHeight.Increment().(types.Height) + tmClient.LatestHeight = tmClient.LatestHeight.Increment().(clienttypes.Height) suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, clientState) - updateHeader = createFutureUpdateFn(clientState.GetLatestHeight().(types.Height)) + updateHeader = createFutureUpdateFn(clientState.GetLatestHeight().(clienttypes.Height)) }, false, false}, {"client is not active", func() { clientState := path.EndpointA.GetClientState().(*ibctm.ClientState) - clientState.FrozenHeight = types.NewHeight(1, 1) + clientState.FrozenHeight = clienttypes.NewHeight(1, 1) suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, clientState) - updateHeader = createFutureUpdateFn(clientState.GetLatestHeight().(types.Height)) + updateHeader = createFutureUpdateFn(clientState.GetLatestHeight().(clienttypes.Height)) }, false, false}, {"invalid header", func() { - updateHeader = createFutureUpdateFn(path.EndpointA.GetClientState().GetLatestHeight().(types.Height)) - updateHeader.TrustedHeight = updateHeader.TrustedHeight.Increment().(types.Height) + updateHeader = createFutureUpdateFn(path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height)) + updateHeader.TrustedHeight = updateHeader.TrustedHeight.Increment().(clienttypes.Height) }, false, false}, } @@ -349,7 +348,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { // set frozen client in store tmClient, ok := cs.(*ibctm.ClientState) suite.Require().True(ok) - tmClient.FrozenHeight = types.NewHeight(1, 1) + tmClient.FrozenHeight = clienttypes.NewHeight(1, 1) suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, tmClient) }, expPass: false, @@ -398,13 +397,13 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { upgradedClient = ibctm.NewClientState(newChainID, ibctm.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, clienttypes.NewHeight(revisionNumber+1, clientState.GetLatestHeight().GetRevisionHeight()+1), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath) upgradedClient = upgradedClient.ZeroCustomFields() - upgradedClientBz, err = types.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient) + upgradedClientBz, err = clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient) suite.Require().NoError(err) upgradedConsState = &ibctm.ConsensusState{ NextValidatorsHash: []byte("nextValsHash"), } - upgradedConsStateBz, err = types.MarshalConsensusState(suite.chainA.App.AppCodec(), upgradedConsState) + upgradedConsStateBz, err = clienttypes.MarshalConsensusState(suite.chainA.App.AppCodec(), upgradedConsState) suite.Require().NoError(err) tc.setup() @@ -447,7 +446,7 @@ func (suite *KeeperTestSuite) TestUpdateClientEventEmission() { bz, err := hex.DecodeString(string(attr.Value)) suite.Require().NoError(err) - emittedHeader, err := types.UnmarshalClientMessage(suite.chainA.App.AppCodec(), bz) + emittedHeader, err := clienttypes.UnmarshalClientMessage(suite.chainA.App.AppCodec(), bz) suite.Require().NoError(err) suite.Require().Equal(header, emittedHeader) } diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 37617434e75..a60eeb30e75 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index 4772854a4da..2bdc2607c57 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -13,6 +13,8 @@ import ( ibctesting "github.com/cosmos/ibc-go/v6/testing" ) +const doesnotexist = "doesnotexist" + func (suite *KeeperTestSuite) TestQueryChannel() { var ( req *types.QueryChannelRequest @@ -372,7 +374,7 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { channel := path.EndpointA.GetChannel() // update channel to reference a connection that does not exist - channel.ConnectionHops[0] = "doesnotexist" + channel.ConnectionHops[0] = doesnotexist // set connection hops to wrong connection ID suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel) @@ -508,7 +510,7 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { channel := path.EndpointA.GetChannel() // update channel to reference a connection that does not exist - channel.ConnectionHops[0] = "doesnotexist" + channel.ConnectionHops[0] = doesnotexist // set connection hops to wrong connection ID suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel) diff --git a/modules/core/04-channel/keeper/handshake_test.go b/modules/core/04-channel/keeper/handshake_test.go index 6a9a7973e11..687f6917a68 100644 --- a/modules/core/04-channel/keeper/handshake_test.go +++ b/modules/core/04-channel/keeper/handshake_test.go @@ -345,7 +345,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { // set the channel's connection hops to wrong connection ID channel := path.EndpointA.GetChannel() - channel.ConnectionHops[0] = "doesnotexist" + channel.ConnectionHops[0] = doesnotexist suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel) }, false}, {"connection is not OPEN", func() { @@ -502,7 +502,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { // set the channel's connection hops to wrong connection ID channel := path.EndpointB.GetChannel() - channel.ConnectionHops[0] = "doesnotexist" + channel.ConnectionHops[0] = doesnotexist suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, channel) }, false}, {"connection is not OPEN", func() { @@ -633,7 +633,7 @@ func (suite *KeeperTestSuite) TestChanCloseInit() { // set the channel's connection hops to wrong connection ID channel := path.EndpointA.GetChannel() - channel.ConnectionHops[0] = "doesnotexist" + channel.ConnectionHops[0] = doesnotexist suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel) }, false}, {"connection is not OPEN", func() { @@ -718,7 +718,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { // set the channel's connection hops to wrong connection ID channel := path.EndpointB.GetChannel() - channel.ConnectionHops[0] = "doesnotexist" + channel.ConnectionHops[0] = doesnotexist suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, channel) }, false}, {"connection is not OPEN", func() { diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 6ffc8b25f85..eeddadd9c39 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "cosmossdk.io/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" diff --git a/modules/core/04-channel/keeper/timeout_test.go b/modules/core/04-channel/keeper/timeout_test.go index 37995af55f4..4f515147bc2 100644 --- a/modules/core/04-channel/keeper/timeout_test.go +++ b/modules/core/04-channel/keeper/timeout_test.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "cosmossdk.io/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" diff --git a/modules/core/24-host/validate_test.go b/modules/core/24-host/validate_test.go index fe5c290ba40..e75ce9334bd 100644 --- a/modules/core/24-host/validate_test.go +++ b/modules/core/24-host/validate_test.go @@ -9,7 +9,7 @@ import ( ) // 195 characters -var longId = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eros neque, ultricies vel ligula ac, convallis porttitor elit. Maecenas tincidunt turpis elit, vel faucibus nisl pellentesque sodales" +var longID = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eros neque, ultricies vel ligula ac, convallis porttitor elit. Maecenas tincidunt turpis elit, vel faucibus nisl pellentesque sodales" type testCase struct { msg string @@ -63,7 +63,7 @@ func TestPortIdentifierValidator(t *testing.T) { {"numeric id", "1234567890", true}, {"blank id", " ", false}, {"id length out of range", "1", false}, - {"id is too long", longId, false}, + {"id is too long", longID, false}, {"path-like id", "lower/case/id", false}, {"invalid id", "(clientid)", false}, {"empty string", "", false}, diff --git a/modules/light-clients/06-solomachine/client_state_test.go b/modules/light-clients/06-solomachine/client_state_test.go index e494a484ec8..5bd93f527e1 100644 --- a/modules/light-clients/06-solomachine/client_state_test.go +++ b/modules/light-clients/06-solomachine/client_state_test.go @@ -95,7 +95,7 @@ func (suite *SoloMachineTestSuite) TestInitialize() { // test singlesig and multisig public keys for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { malleatedConsensus := sm.ClientState().ConsensusState - malleatedConsensus.Timestamp = malleatedConsensus.Timestamp + 10 + malleatedConsensus.Timestamp += 10 testCases := []struct { name string diff --git a/modules/light-clients/06-solomachine/update_test.go b/modules/light-clients/06-solomachine/update_test.go index a8311fbcfbf..16879c223d3 100644 --- a/modules/light-clients/06-solomachine/update_test.go +++ b/modules/light-clients/06-solomachine/update_test.go @@ -201,7 +201,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { "old misbehaviour is successful (timestamp is less than current consensus state)", func() { clientState = sm.ClientState() - sm.Time = sm.Time - 5 + sm.Time -= 5 clientMsg = sm.CreateMisbehaviour() }, true, }, diff --git a/modules/light-clients/07-tendermint/proposal_handle_test.go b/modules/light-clients/07-tendermint/proposal_handle_test.go index 98b5134cddd..5767610c604 100644 --- a/modules/light-clients/07-tendermint/proposal_handle_test.go +++ b/modules/light-clients/07-tendermint/proposal_handle_test.go @@ -34,7 +34,7 @@ func (suite *TendermintTestSuite) TestCheckSubstituteUpdateStateBasic() { substituteClientState.TrustingPeriod = time.Hour * 24 * 7 tmClientState := substituteClientState - tmClientState.ChainId = tmClientState.ChainId + "different chain" + tmClientState.ChainId += "different chain" }, }, } From a1c1923659a9a4eb6f6ec72a184e47cf0abf1a81 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 12 Dec 2022 21:35:11 +0700 Subject: [PATCH 15/23] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9742abb77ed..b9115dbb193 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (tests) [\#2926](https://github.com/cosmos/ibc-go/pull/2926) Lint tests * (apps/transfer) [\#2643](https://github.com/cosmos/ibc-go/pull/2643) Add amount, denom, and memo to transfer event emission. * (core) [\#2746](https://github.com/cosmos/ibc-go/pull/2746) Allow proof height to be zero for all core IBC `sdk.Msg` types that contain proofs. * (light-clients/06-solomachine) [\#2746](https://github.com/cosmos/ibc-go/pull/2746) Discard proofHeight for solo machines and use the solo machine sequence instead. From bc6a14d669d2c9d06fc8a6c8328cfaca2e917a0d Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 13 Dec 2022 03:19:28 +0700 Subject: [PATCH 16/23] golangci-lint run ./... --fix --- modules/apps/transfer/keeper/msg_server_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index e457d3894cb..e11b2b1dfce 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -9,9 +9,7 @@ import ( ) func (suite *KeeperTestSuite) TestMsgTransfer() { - var ( - msg *types.MsgTransfer - ) + var msg *types.MsgTransfer testCases := []struct { name string From 43e58b60b4367fd1d277d4f831709a55c093e082 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 19 Dec 2022 05:12:06 +0700 Subject: [PATCH 17/23] last lint --- modules/apps/27-interchain-accounts/host/ibc_module_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index 535420ccfad..38a01c799fa 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -694,7 +694,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() path.EndpointB.ChannelID = "" suite.coordinator.CreateChannels(path) - _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) + _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) err = path.EndpointB.UpdateClient() suite.Require().NoError(err) From 0cfe15f733e886affb8354268e8c62e7626154b9 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 19 Dec 2022 05:14:04 +0700 Subject: [PATCH 18/23] fix lints --- modules/apps/27-interchain-accounts/host/ibc_module_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index 38a01c799fa..7e85088bc1e 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -694,9 +694,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() path.EndpointB.ChannelID = "" suite.coordinator.CreateChannels(path) - _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) - suite.Require().NoError(err) - err = path.EndpointB.UpdateClient() + _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) // relay the packet From 56094f590376b7dba5b64dc65c14ad4fc6268c4d Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 19 Dec 2022 13:22:18 +0700 Subject: [PATCH 19/23] tidy --- e2e/go.mod | 1 - e2e/go.sum | 3 --- proto/buf.yaml | 4 ++-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/e2e/go.mod b/e2e/go.mod index 20971b2c6cb..f55d4e157ad 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -148,7 +148,6 @@ require ( github.com/prometheus/procfs v0.8.0 // indirect github.com/rakyll/statik v0.1.7 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect - github.com/regen-network/cosmos-proto v0.3.1 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/rs/cors v1.8.2 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect diff --git a/e2e/go.sum b/e2e/go.sum index 8fb9660bc34..8df0841b9a7 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -772,7 +772,6 @@ github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Ung github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg= -github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM= github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= @@ -833,8 +832,6 @@ github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+eg github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= github.com/strangelove-ventures/go-subkey v1.0.7 h1:cOP/Lajg3uxV/tvspu0m6+0Cu+DJgygkEAbx/s+f35I= github.com/strangelove-ventures/go-subkey v1.0.7/go.mod h1:E34izOIEm+sZ1YmYawYRquqBQWeZBjVB4pF7bMuhc1c= -github.com/strangelove-ventures/ibctest/v6 v6.0.0-20221202162429-9359b061fbe5 h1:nzNdAKDDCuhDYT+Rk9SjmLOKUmg6KEMnTHm/xoHXq6Q= -github.com/strangelove-ventures/ibctest/v6 v6.0.0-20221202162429-9359b061fbe5/go.mod h1:l3Q2U/8aRyZrOqXp45nhxSjeXgBB+qROwu+L0vIJmUw= github.com/strangelove-ventures/ibctest/v6 v6.0.0-20221209152048-e8388a0b91fd h1:67pNLuMmq8L8BW8WShjtMoL0KFONLpOVYQxb2HY8IlQ= github.com/strangelove-ventures/ibctest/v6 v6.0.0-20221209152048-e8388a0b91fd/go.mod h1:l3Q2U/8aRyZrOqXp45nhxSjeXgBB+qROwu+L0vIJmUw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/proto/buf.yaml b/proto/buf.yaml index 3e67b96ee6f..7f88423fda8 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -1,5 +1,5 @@ version: v1 -name: buf.build/cosmos/ibc +name: buf.build/faddat/ibc deps: # see: (https://github.com/cosmos/cosmos-sdk/tree/main/proto#sdk-x-buf) - buf.build/cosmos/cosmos-sdk:8cb30a2c4de74dc9bd8d260b1e75e176 @@ -21,4 +21,4 @@ lint: - PACKAGE_VERSION_SUFFIX - RPC_REQUEST_STANDARD_NAME ignore: - - proofs.proto # TODO: remove this when ics23 is linted and can be obtained via buf mod \ No newline at end of file + - proofs.proto # TODO: remove this when ics23 is linted and can be obtained via buf mod From 425edf387ac317616a171a393fabf896ce9b7ca2 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Sat, 24 Dec 2022 15:52:51 +0700 Subject: [PATCH 20/23] ignore legacy ica api --- modules/apps/27-interchain-accounts/host/ibc_module_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index 7e85088bc1e..d7a3577e2a6 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -667,7 +667,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() params := types.NewParams(true, []string{sdk.MsgTypeURL(msg)}) suite.chainB.GetSimApp().ICAHostKeeper.SetParams(suite.chainB.GetContext(), params) - _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) + _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) //nolint:staticcheck suite.Require().NoError(err) err = path.EndpointB.UpdateClient() suite.Require().NoError(err) @@ -694,7 +694,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() path.EndpointB.ChannelID = "" suite.coordinator.CreateChannels(path) - _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) + _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) //nolint:staticcheck suite.Require().NoError(err) // relay the packet From 455b03601be76ad2820de0f61120433c6bf68908 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Sat, 24 Dec 2022 15:56:12 +0700 Subject: [PATCH 21/23] ignore icacontrollersendtx --- .golangci.yml | 3 +++ modules/apps/27-interchain-accounts/host/ibc_module_test.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f8b41a60efe..14f775ad072 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -30,6 +30,9 @@ linters: issues: exclude-rules: + - text: "SA1019: suite.chainA.GetSimApp().ICAControllerKeeper.SendTx is deprecated: this is a legacy API that is only intended to function correctly in workflows where an underlying application has been set. Prior to to v6.x.x of ibc-go, the controller module was only functional as middleware, with authentication performed by the underlying application. For a full summary of the changes in v6.x.x, please see ADR009. This API will be removed in later releases." + linters: + - staticcheck - text: "Use of weak random number generator" linters: - gosec diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index d7a3577e2a6..7e85088bc1e 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -667,7 +667,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() params := types.NewParams(true, []string{sdk.MsgTypeURL(msg)}) suite.chainB.GetSimApp().ICAHostKeeper.SetParams(suite.chainB.GetContext(), params) - _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) //nolint:staticcheck + _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) err = path.EndpointB.UpdateClient() suite.Require().NoError(err) @@ -694,7 +694,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() path.EndpointB.ChannelID = "" suite.coordinator.CreateChannels(path) - _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) //nolint:staticcheck + _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) // relay the packet From 824a7a2df92a6017764c84ae6e89e3b890987edb Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 16 Jan 2023 12:57:00 +0100 Subject: [PATCH 22/23] golangci lint fixes --- go.mod | 1 - modules/apps/29-fee/keeper/events_test.go | 16 ++++++++-------- modules/apps/29-fee/keeper/msg_server_test.go | 12 ++++++++---- modules/apps/transfer/keeper/msg_server_test.go | 6 ++++-- modules/core/02-client/keeper/client_test.go | 4 ++-- modules/core/02-client/proposal_handler_test.go | 2 +- .../04-channel/types/acknowledgement_test.go | 7 +++---- .../07-tendermint/client_state_test.go | 2 +- 8 files changed, 27 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index c5ce6868ec6..4203fee443e 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,6 @@ require ( cosmossdk.io/api v0.2.6 // indirect cosmossdk.io/core v0.3.2 // indirect cosmossdk.io/depinject v1.0.0-alpha.3 // indirect - cosmossdk.io/errors v1.0.0-beta.7 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect diff --git a/modules/apps/29-fee/keeper/events_test.go b/modules/apps/29-fee/keeper/events_test.go index 2f708e614d5..24d67acdeca 100644 --- a/modules/apps/29-fee/keeper/events_test.go +++ b/modules/apps/29-fee/keeper/events_test.go @@ -40,15 +40,15 @@ func (suite *KeeperTestSuite) TestIncentivizePacketEvent() { } for _, attr := range incentivizedPacketEvent.Attributes { - switch string(attr.Key) { + switch attr.Key { case types.AttributeKeyRecvFee: - suite.Require().Equal(expRecvFees.String(), string(attr.Value)) + suite.Require().Equal(expRecvFees.String(), attr.Value) case types.AttributeKeyAckFee: - suite.Require().Equal(expAckFees.String(), string(attr.Value)) + suite.Require().Equal(expAckFees.String(), attr.Value) case types.AttributeKeyTimeoutFee: - suite.Require().Equal(expTimeoutFees.String(), string(attr.Value)) + suite.Require().Equal(expTimeoutFees.String(), attr.Value) } } @@ -69,15 +69,15 @@ func (suite *KeeperTestSuite) TestIncentivizePacketEvent() { } for _, attr := range incentivizedPacketEvent.Attributes { - switch string(attr.Key) { + switch attr.Key { case types.AttributeKeyRecvFee: - suite.Require().Equal(expRecvFees.String(), string(attr.Value)) + suite.Require().Equal(expRecvFees.String(), attr.Value) case types.AttributeKeyAckFee: - suite.Require().Equal(expAckFees.String(), string(attr.Value)) + suite.Require().Equal(expAckFees.String(), attr.Value) case types.AttributeKeyTimeoutFee: - suite.Require().Equal(expTimeoutFees.String(), string(attr.Value)) + suite.Require().Equal(expTimeoutFees.String(), attr.Value) } } } diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index c2270e6614c..4037dc8b93e 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -201,11 +201,12 @@ func (suite *KeeperTestSuite) TestPayPacketFee() { { "bank send enabled for fee denom", func() { - suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), + err := suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), banktypes.Params{ SendEnabled: []*banktypes.SendEnabled{{Denom: sdk.DefaultBondDenom, Enabled: true}}, }, ) + suite.Require().NoError(err) }, true, }, @@ -259,11 +260,12 @@ func (suite *KeeperTestSuite) TestPayPacketFee() { { "bank send disabled for fee denom", func() { - suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), + err := suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), banktypes.Params{ SendEnabled: []*banktypes.SendEnabled{{Denom: sdk.DefaultBondDenom, Enabled: false}}, }, ) + suite.Require().NoError(err) }, false, }, @@ -373,11 +375,12 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { { "bank send enabled for fee denom", func() { - suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), + err := suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), banktypes.Params{ SendEnabled: []*banktypes.SendEnabled{{Denom: sdk.DefaultBondDenom, Enabled: true}}, }, ) + suite.Require().NoError(err) }, true, }, @@ -469,11 +472,12 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { { "bank send disabled for fee denom", func() { - suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), + err := suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), banktypes.Params{ SendEnabled: []*banktypes.SendEnabled{{Denom: sdk.DefaultBondDenom, Enabled: false}}, }, ) + suite.Require().NoError(err) }, false, }, diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index e11b2b1dfce..b184abf5c0d 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -24,11 +24,12 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { { "bank send enabled for denom", func() { - suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), + err := suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), banktypes.Params{ SendEnabled: []*banktypes.SendEnabled{{Denom: sdk.DefaultBondDenom, Enabled: true}}, }, ) + suite.Require().NoError(err) }, true, }, @@ -60,11 +61,12 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { { "bank send disabled for denom", func() { - suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), + err := suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), banktypes.Params{ SendEnabled: []*banktypes.SendEnabled{{Denom: sdk.DefaultBondDenom, Enabled: false}}, }, ) + suite.Require().NoError(err) }, false, }, diff --git a/modules/core/02-client/keeper/client_test.go b/modules/core/02-client/keeper/client_test.go index a0784ae3b0e..bdb1d0f3369 100644 --- a/modules/core/02-client/keeper/client_test.go +++ b/modules/core/02-client/keeper/client_test.go @@ -443,10 +443,10 @@ func (suite *KeeperTestSuite) TestUpdateClientEventEmission() { // use a boolean to ensure the update event contains the header contains := false for _, attr := range updateEvent.Attributes { - if string(attr.Key) == clienttypes.AttributeKeyHeader { + if attr.Key == clienttypes.AttributeKeyHeader { contains = true - bz, err := hex.DecodeString(string(attr.Value)) + bz, err := hex.DecodeString(attr.Value) suite.Require().NoError(err) emittedHeader, err := clienttypes.UnmarshalClientMessage(suite.chainA.App.AppCodec(), bz) diff --git a/modules/core/02-client/proposal_handler_test.go b/modules/core/02-client/proposal_handler_test.go index 080ae069b3a..80cbf9f7824 100644 --- a/modules/core/02-client/proposal_handler_test.go +++ b/modules/core/02-client/proposal_handler_test.go @@ -60,7 +60,7 @@ func (suite *ClientTestSuite) TestNewClientUpdateProposalHandler() { }, { "unsupported proposal type", func() { - content = &distributiontypes.CommunityPoolSpendProposal{ + content = &distributiontypes.CommunityPoolSpendProposal{ //nolint:staticcheck Title: ibctesting.Title, Description: ibctesting.Description, Recipient: suite.chainA.SenderAccount.GetAddress().String(), diff --git a/modules/core/04-channel/types/acknowledgement_test.go b/modules/core/04-channel/types/acknowledgement_test.go index 232564e15e2..11cffdfba4a 100644 --- a/modules/core/04-channel/types/acknowledgement_test.go +++ b/modules/core/04-channel/types/acknowledgement_test.go @@ -4,7 +4,6 @@ import ( "fmt" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - abci "github.com/tendermint/tendermint/abci/types" abcitypes "github.com/tendermint/tendermint/abci/types" tmprotostate "github.com/tendermint/tendermint/proto/tendermint/state" tmstate "github.com/tendermint/tendermint/state" @@ -98,21 +97,21 @@ func (suite *TypesTestSuite) TestABCICodeDeterminism() { // different ABCI error code used errDifferentABCICode := sdkerrors.ErrNotFound - deliverTx := sdkerrors.ResponseDeliverTxWithEvents(err, gasUsed, gasWanted, []abci.Event{}, false) + deliverTx := sdkerrors.ResponseDeliverTxWithEvents(err, gasUsed, gasWanted, []abcitypes.Event{}, false) responses := tmprotostate.ABCIResponses{ DeliverTxs: []*abcitypes.ResponseDeliverTx{ &deliverTx, }, } - deliverTxSameABCICode := sdkerrors.ResponseDeliverTxWithEvents(errSameABCICode, gasUsed, gasWanted, []abci.Event{}, false) + deliverTxSameABCICode := sdkerrors.ResponseDeliverTxWithEvents(errSameABCICode, gasUsed, gasWanted, []abcitypes.Event{}, false) responsesSameABCICode := tmprotostate.ABCIResponses{ DeliverTxs: []*abcitypes.ResponseDeliverTx{ &deliverTxSameABCICode, }, } - deliverTxDifferentABCICode := sdkerrors.ResponseDeliverTxWithEvents(errDifferentABCICode, gasUsed, gasWanted, []abci.Event{}, false) + deliverTxDifferentABCICode := sdkerrors.ResponseDeliverTxWithEvents(errDifferentABCICode, gasUsed, gasWanted, []abcitypes.Event{}, false) responsesDifferentABCICode := tmprotostate.ABCIResponses{ DeliverTxs: []*abcitypes.ResponseDeliverTx{ &deliverTxDifferentABCICode, diff --git a/modules/light-clients/07-tendermint/client_state_test.go b/modules/light-clients/07-tendermint/client_state_test.go index f7535d02a25..21caf5e2e43 100644 --- a/modules/light-clients/07-tendermint/client_state_test.go +++ b/modules/light-clients/07-tendermint/client_state_test.go @@ -3,8 +3,8 @@ package tendermint_test import ( "time" - ics23 "github.com/cosmos/ics23/go" sdk "github.com/cosmos/cosmos-sdk/types" + ics23 "github.com/cosmos/ics23/go" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" From c2eac3150bc434c05a52ebb9799b8f7175d2b406 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 16 Jan 2023 13:34:26 +0100 Subject: [PATCH 23/23] fix test --- modules/apps/27-interchain-accounts/host/ibc_module_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index 44c9271bfd7..fc47e70ada0 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -696,6 +696,8 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) + err = path.EndpointB.UpdateClient() + suite.Require().NoError(err) // relay the packet packetRelay = channeltypes.NewPacket(icaPacketData.GetBytes(), 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.ZeroHeight(), ^uint64(0))