From 96d58e794c9c47867b410ebf29bcf43b539e60a2 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 17 Jan 2023 00:16:32 +0800 Subject: [PATCH] lint tests (#2926) * lint tests * don't use prealloc for golangci * fix unnecessary conversions * var-declaration lints * fix ineffectual assignments * fix composite literal lints * address copylocks lints from govet * error checks in tests * handshake_test.go error checks * packet_test.go error checks * error checks * msg_server_test.go * errcheck in upgrade_test.go * goconsts & linting complete * Update CHANGELOG.md * golangci-lint run ./... --fix * last lint * fix lints * tidy * ignore legacy ica api * ignore icacontrollersendtx * golangci lint fixes * fix test Co-authored-by: Carlos Rodriguez Co-authored-by: Carlos Rodriguez --- .golangci.yml | 8 +-- CHANGELOG.md | 1 + cmd/build_test_matrix/main_test.go | 4 +- go.mod | 2 +- .../controller/ibc_middleware_test.go | 9 ++- .../controller/keeper/handshake_test.go | 4 +- .../controller/keeper/keeper_test.go | 12 ++-- .../host/ibc_module_test.go | 9 ++- .../host/keeper/handshake_test.go | 2 +- .../host/keeper/keeper_test.go | 12 ++-- .../types/codec_test.go | 7 -- modules/apps/29-fee/ibc_middleware_test.go | 10 +-- modules/apps/29-fee/keeper/events_test.go | 16 ++--- 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 | 18 +++-- modules/apps/29-fee/types/fee_test.go | 4 +- modules/apps/29-fee/types/msgs_test.go | 12 ++-- modules/apps/transfer/ibc_module_test.go | 2 +- .../apps/transfer/keeper/grpc_query_test.go | 4 +- .../apps/transfer/keeper/mbt_relay_test.go | 20 +++--- .../apps/transfer/keeper/migrations_test.go | 2 +- .../apps/transfer/keeper/msg_server_test.go | 10 +-- modules/apps/transfer/keeper/relay_test.go | 4 +- modules/core/02-client/keeper/client_test.go | 52 +++++++------- .../core/02-client/keeper/grpc_query_test.go | 3 +- modules/core/02-client/keeper/keeper_test.go | 16 ++--- modules/core/02-client/keeper/params_test.go | 2 +- .../core/02-client/keeper/proposal_test.go | 10 +-- .../core/02-client/proposal_handler_test.go | 2 +- modules/core/02-client/types/genesis_test.go | 2 +- modules/core/02-client/types/msgs_test.go | 2 +- .../03-connection/keeper/handshake_test.go | 3 +- .../core/03-connection/keeper/keeper_test.go | 4 +- .../core/03-connection/keeper/params_test.go | 2 +- .../core/03-connection/keeper/verify_test.go | 3 +- modules/core/03-connection/types/msgs_test.go | 3 +- .../core/04-channel/keeper/grpc_query_test.go | 6 +- .../core/04-channel/keeper/handshake_test.go | 26 ++++--- modules/core/04-channel/keeper/keeper_test.go | 6 +- modules/core/04-channel/keeper/packet_test.go | 14 ++-- .../core/04-channel/keeper/timeout_test.go | 70 +++++++++++++------ .../04-channel/types/acknowledgement_test.go | 9 ++- modules/core/04-channel/types/msgs_test.go | 3 +- .../23-commitment/types/commitment_test.go | 3 +- .../core/23-commitment/types/merkle_test.go | 8 +-- modules/core/24-host/validate_test.go | 4 +- modules/core/keeper/msg_server_test.go | 57 ++++++++++----- .../06-solomachine/client_state_test.go | 2 +- .../06-solomachine/update_test.go | 2 +- .../07-tendermint/client_state_test.go | 2 +- .../07-tendermint/proposal_handle_test.go | 6 +- .../07-tendermint/update_test.go | 9 ++- .../07-tendermint/upgrade_test.go | 50 ++++++------- proto/buf.yaml | 2 +- testing/chain_test.go | 10 +-- testing/mock/privval_test.go | 6 +- 57 files changed, 330 insertions(+), 251 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 19c59963c96..14f775ad072 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,14 +13,12 @@ linters: - goconst - gocritic - gofumpt - - goimports - gosec - gosimple - govet - ineffassign - misspell - nakedret - - prealloc - staticcheck - stylecheck - revive @@ -33,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/CHANGELOG.md b/CHANGELOG.md index 215f699ff6b..35bdb13851c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,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. 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 847ffe13d45..4203fee443e 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ go 1.19 module github.com/cosmos/ibc-go/v6 require ( + cosmossdk.io/errors v1.0.0-beta.7 cosmossdk.io/math v1.0.0-beta.4 cosmossdk.io/simapp v0.0.0-20221216140705-ee8890cf30e7 cosmossdk.io/tools/rosetta v0.2.0 @@ -36,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/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..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, }, @@ -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/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/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index 7615e5a617f..fc47e70ada0 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/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/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) diff --git a/modules/apps/27-interchain-accounts/types/codec_test.go b/modules/apps/27-interchain-accounts/types/codec_test.go index 2f9deb58ac3..1440951706d 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/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/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/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 d767b3f4361..4037dc8b93e 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -29,7 +29,7 @@ func (suite *KeeperTestSuite) TestRegisterPayee() { "channel does not exist", false, func() { - msg.ChannelId = "channel-100" + msg.ChannelId = "channel-100" //nolint:goconst }, }, { @@ -201,18 +201,19 @@ 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, }, { "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} @@ -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, }, @@ -410,7 +413,7 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { { "packet not sent", func() { - msg.PacketId.Sequence = msg.PacketId.Sequence + 1 + msg.PacketId.Sequence++ }, false, }, @@ -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/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 05dcc84ec46..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, }, @@ -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) { @@ -117,7 +117,7 @@ func TestMsgRegisterCountepartyPayeeValidation(t *testing.T) { { "validate with incorrect destination relayer address", func() { - msg.Relayer = "invalid-address" + msg.Relayer = invalidAddress }, false, }, @@ -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) { @@ -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 ff44c9a679b..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,16 +281,16 @@ 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)) } - 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)) } @@ -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/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/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index e457d3894cb..b184abf5c0d 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 @@ -26,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, }, @@ -62,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/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index 67576695bc3..7797c839f23 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, }, { @@ -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/client_test.go b/modules/core/02-client/keeper/client_test.go index f20ba1dcdc1..bdb1d0f3369 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" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" @@ -24,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 { @@ -70,7 +69,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() @@ -80,10 +79,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 @@ -103,7 +102,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{ @@ -112,7 +111,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), @@ -120,7 +119,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) @@ -130,7 +129,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, @@ -138,7 +137,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), @@ -146,7 +145,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) @@ -158,11 +157,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(), @@ -178,7 +177,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}, @@ -186,20 +185,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}, } @@ -352,7 +351,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, @@ -401,13 +400,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() @@ -433,6 +432,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) @@ -443,13 +443,13 @@ 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 := 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/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/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 539c14a3899..3785e77258e 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", @@ -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/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/02-client/keeper/proposal_test.go b/modules/core/02-client/keeper/proposal_test.go index 485174e8ec5..61fae3bc52a 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) @@ -218,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/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/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, 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/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/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/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) } 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/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/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 b607017f213..687f6917a68 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() @@ -340,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() { @@ -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}, @@ -496,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() { @@ -627,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() { @@ -712,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/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/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 754d1c80e74..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" @@ -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 diff --git a/modules/core/04-channel/keeper/timeout_test.go b/modules/core/04-channel/keeper/timeout_test.go index 200ad68199b..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" @@ -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/04-channel/types/acknowledgement_test.go b/modules/core/04-channel/types/acknowledgement_test.go index 2392ed5675b..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" @@ -18,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 @@ -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/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/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/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) } }) 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/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 9908abaabe3..f6549db9269 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()) @@ -386,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()) @@ -407,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() { @@ -426,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() { @@ -507,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) @@ -522,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 @@ -543,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() @@ -563,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 @@ -581,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() @@ -592,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}, @@ -669,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) @@ -709,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/06-solomachine/client_state_test.go b/modules/light-clients/06-solomachine/client_state_test.go index dbb958ae7ba..2300197418b 100644 --- a/modules/light-clients/06-solomachine/client_state_test.go +++ b/modules/light-clients/06-solomachine/client_state_test.go @@ -96,7 +96,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 8a251dc22cf..cb4389395f0 100644 --- a/modules/light-clients/06-solomachine/update_test.go +++ b/modules/light-clients/06-solomachine/update_test.go @@ -191,7 +191,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/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" diff --git a/modules/light-clients/07-tendermint/proposal_handle_test.go b/modules/light-clients/07-tendermint/proposal_handle_test.go index 6a8a8102bee..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" }, }, } @@ -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, }, { diff --git a/modules/light-clients/07-tendermint/update_test.go b/modules/light-clients/07-tendermint/update_test.go index 09d5fc6afe9..77fe7090dcf 100644 --- a/modules/light-clients/07-tendermint/update_test.go +++ b/modules/light-clients/07-tendermint/update_test.go @@ -533,7 +533,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 @@ -552,12 +553,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) 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 diff --git a/proto/buf.yaml b/proto/buf.yaml index 58df57893cc..f0e0a79a4d5 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: # TODO: update sdk buf dependency when v0.47.0 is tagged and pushed to BSR # see: (https://github.com/cosmos/cosmos-sdk/tree/main/proto#sdk-x-buf) 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)