From f74eac501804791f6e4e994bd15443d17e9ba2ff Mon Sep 17 00:00:00 2001 From: Charly Date: Fri, 13 Jan 2023 12:51:01 -0600 Subject: [PATCH 01/15] update paginate to use filter paginate --- modules/core/02-client/keeper/grpc_query.go | 12 +++++++----- modules/core/04-channel/keeper/grpc_query.go | 11 ++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index 1f08604dd64..c2decf672b0 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -63,26 +63,28 @@ func (q Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequ clientStates := types.IdentifiedClientStates{} store := prefix.NewStore(ctx.KVStore(q.storeKey), host.KeyClientStorePrefix) - pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { + // filter any metadata stored under client state key keySplit := strings.Split(string(key), "/") if keySplit[len(keySplit)-1] != "clientState" { - return nil + return false, nil } clientState, err := q.UnmarshalClientState(value) if err != nil { - return err + return false, err } clientID := keySplit[1] if err := host.ClientIdentifierValidator(clientID); err != nil { - return err + return false, err } identifiedClient := types.NewIdentifiedClientState(clientID, clientState) clientStates = append(clientStates, identifiedClient) - return nil + return true, nil }) + if err != nil { return nil, err } diff --git a/modules/core/04-channel/keeper/grpc_query.go b/modules/core/04-channel/keeper/grpc_query.go index e6bc4ea2ecf..351c63c7e38 100644 --- a/modules/core/04-channel/keeper/grpc_query.go +++ b/modules/core/04-channel/keeper/grpc_query.go @@ -96,26 +96,27 @@ func (q Keeper) ConnectionChannels(c context.Context, req *types.QueryConnection channels := []*types.IdentifiedChannel{} store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelEndPrefix)) - pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { + // filter any metadata stored under channel key var result types.Channel if err := q.cdc.Unmarshal(value, &result); err != nil { - return err + return false, err } // ignore channel and continue to the next item if the connection is // different than the requested one if result.ConnectionHops[0] != req.Connection { - return nil + return false, nil } portID, channelID, err := host.ParseChannelPath(string(key)) if err != nil { - return err + return false, err } identifiedChannel := types.NewIdentifiedChannel(portID, channelID, result) channels = append(channels, &identifiedChannel) - return nil + return true, nil }) if err != nil { return nil, err From 126a848b58a904bcac578881ca54e9aee49fc44b Mon Sep 17 00:00:00 2001 From: Charly Date: Fri, 13 Jan 2023 18:41:05 -0600 Subject: [PATCH 02/15] gofumpt --- modules/core/02-client/keeper/grpc_query.go | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index c2decf672b0..4fba0cdd782 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -84,7 +84,6 @@ func (q Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequ clientStates = append(clientStates, identifiedClient) return true, nil }) - if err != nil { return nil, err } From a5f92f41e9ea74256cb24195922e64e0130f615a Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 17 Jan 2023 11:47:39 -0600 Subject: [PATCH 03/15] update tests to check for correct length of results --- .../core/02-client/keeper/grpc_query_test.go | 26 +++++++++++++------ .../core/04-channel/keeper/grpc_query_test.go | 7 ++++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 02fcbf58163..a961f68b61c 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -97,12 +97,14 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { ) testCases := []struct { - msg string - malleate func() - expPass bool + msg string + expectedClientStates uint64 + malleate func() + expPass bool }{ { "req is nil", + 0, func() { req = nil }, @@ -110,6 +112,7 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { }, { "empty pagination", + 0, func() { req = &types.QueryClientStatesRequest{} }, @@ -117,6 +120,7 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { }, { "success, no results", + 0, func() { req = &types.QueryClientStatesRequest{ Pagination: &query.PageRequest{ @@ -129,6 +133,7 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { }, { "success", + 2, func() { path1 := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path1) @@ -163,10 +168,10 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) res, err := suite.chainA.QueryServer.ClientStates(ctx, req) - if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) + suite.Require().Equal(tc.expectedClientStates, res.Pagination.Total) suite.Require().Equal(expClientStates.Sort(), res.ClientStates) } else { suite.Require().Error(err) @@ -296,12 +301,14 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { ) testCases := []struct { - msg string - malleate func() - expPass bool + msg string + expectedConsensusStates uint64 + malleate func() + expPass bool }{ { "success: without pagination", + 0, func() { req = &types.QueryConsensusStatesRequest{ ClientId: testClientID, @@ -311,6 +318,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { }, { "success, no results", + 0, func() { req = &types.QueryConsensusStatesRequest{ ClientId: testClientID, @@ -324,6 +332,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { }, { "success", + 2, func() { path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path) @@ -359,6 +368,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { }, { "invalid client identifier", + 0, func() { req = &types.QueryConsensusStatesRequest{} }, @@ -377,11 +387,11 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) + suite.Require().Equal(tc.expectedConsensusStates, res.Pagination.Total) suite.Require().Equal(len(expConsensusStates), len(res.ConsensusStates)) for i := range expConsensusStates { suite.Require().NotNil(res.ConsensusStates[i]) suite.Require().Equal(expConsensusStates[i], res.ConsensusStates[i]) - // ensure UnpackInterfaces is defined cachedValue := res.ConsensusStates[i].ConsensusState.GetCachedValue() suite.Require().NotNil(cachedValue) diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index 2bdc2607c57..1bda1340f7c 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -112,12 +112,14 @@ func (suite *KeeperTestSuite) TestQueryChannels() { ) testCases := []struct { - msg string + msg string + expectedChannels uint64 malleate func() expPass bool }{ { "empty request", + 0, func() { req = nil }, @@ -125,6 +127,7 @@ func (suite *KeeperTestSuite) TestQueryChannels() { }, { "empty pagination", + 0, func() { req = &types.QueryChannelsRequest{} }, @@ -132,6 +135,7 @@ func (suite *KeeperTestSuite) TestQueryChannels() { }, { "success", + 2, func() { path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) @@ -193,6 +197,7 @@ func (suite *KeeperTestSuite) TestQueryChannels() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) + suite.Require().Equal(tc.expectedChannels, res.Pagination.Total) suite.Require().Equal(expChannels, res.Channels) suite.Require().Equal(len(expChannels), int(res.Pagination.Total)) } else { From aff6563fce92d94b5fedd90bce5f5e3d2e6fab67 Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 17 Jan 2023 11:55:05 -0600 Subject: [PATCH 04/15] format --- modules/core/04-channel/keeper/grpc_query_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index 1bda1340f7c..b71f71be344 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -112,10 +112,10 @@ func (suite *KeeperTestSuite) TestQueryChannels() { ) testCases := []struct { - msg string + msg string expectedChannels uint64 - malleate func() - expPass bool + malleate func() + expPass bool }{ { "empty request", From 629b24cb4e16a7e91c2160573beeaae6b0c1ed00 Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 17 Jan 2023 13:19:29 -0600 Subject: [PATCH 05/15] format test --- e2e/testsuite/testsuite.go | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 9f8ffecd234..ad0510ab8eb 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -243,7 +243,6 @@ func (b *broadcastUser) FormattedAddressWithPrefix(prefix string) string { // BroadcastMessages broadcasts the provided messages to the given chain and signs them on behalf of the provided user. // Once the broadcast response is returned, we wait for a few blocks to be created on both chain A and chain B. func (s *E2ETestSuite) BroadcastMessages(ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, msgs ...sdk.Msg) (sdk.TxResponse, error) { - // wrap the user so it is a valid implementation of broadcast user. b := broadcastUser{Wallet: user} From 31ea49c849f5dda12c040b6daa9d1220e61bdd95 Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 17 Jan 2023 13:34:17 -0600 Subject: [PATCH 06/15] rm linter for SendTx --- .golangci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 14f775ad072..f8b41a60efe 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -30,9 +30,6 @@ 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 From 1ce931f3db18ee9037aa45767cd7248668f54eaf Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 17 Jan 2023 13:50:01 -0600 Subject: [PATCH 07/15] update .golangci.yml --- .golangci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index f8b41a60efe..14f775ad072 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -30,6 +30,9 @@ linters: issues: exclude-rules: + - text: "SA1019: suite.chainA.GetSimApp().ICAControllerKeeper.SendTx is deprecated: this is a legacy API that is only intended to function correctly in workflows where an underlying application has been set. Prior to to v6.x.x of ibc-go, the controller module was only functional as middleware, with authentication performed by the underlying application. For a full summary of the changes in v6.x.x, please see ADR009. This API will be removed in later releases." + linters: + - staticcheck - text: "Use of weak random number generator" linters: - gosec From 7b0498cf86cffe9ca5dd44634d1a951ca5f5f223 Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 17 Jan 2023 14:08:34 -0600 Subject: [PATCH 08/15] nolint on test --- .../apps/27-interchain-accounts/controller/keeper/relay_test.go | 1 + modules/apps/27-interchain-accounts/host/ibc_module_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go index c012c2cb4be..3034b23b6b2 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go @@ -151,6 +151,7 @@ func (suite *KeeperTestSuite) TestSendTx() { tc.malleate() // malleate mutates test data + //nolint _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, packetData, timeoutTimestamp) if tc.expPass { 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 fc47e70ada0..90755301638 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -667,6 +667,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() params := types.NewParams(true, []string{sdk.MsgTypeURL(msg)}) suite.chainB.GetSimApp().ICAHostKeeper.SetParams(suite.chainB.GetContext(), params) + //nolint _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) err = path.EndpointB.UpdateClient() @@ -694,6 +695,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() path.EndpointB.ChannelID = "" suite.coordinator.CreateChannels(path) + //nolint _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) err = path.EndpointB.UpdateClient() From 16351a998ce0c843984e18d88c14a43e8fdf56d6 Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 17 Jan 2023 14:23:42 -0600 Subject: [PATCH 09/15] add directive to nolint --- .../27-interchain-accounts/controller/keeper/relay_test.go | 2 +- modules/apps/27-interchain-accounts/host/ibc_module_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go index 3034b23b6b2..c4f6dc32dbc 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go @@ -151,7 +151,7 @@ func (suite *KeeperTestSuite) TestSendTx() { tc.malleate() // malleate mutates test data - //nolint + //nolint: staticcheck // SA1019: ibctesting.FirstConnectionID is deprecated: use path.EndpointA.ConnectionID instead. (staticcheck) _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, packetData, timeoutTimestamp) if tc.expPass { 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 90755301638..0dd668ad566 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -667,7 +667,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() params := types.NewParams(true, []string{sdk.MsgTypeURL(msg)}) suite.chainB.GetSimApp().ICAHostKeeper.SetParams(suite.chainB.GetContext(), params) - //nolint + //nolint: staticcheck // SA1019: ibctesting.FirstConnectionID is deprecated: use path.EndpointA.ConnectionID instead. (staticcheck) _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) err = path.EndpointB.UpdateClient() @@ -695,7 +695,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() path.EndpointB.ChannelID = "" suite.coordinator.CreateChannels(path) - //nolint + //nolint: staticcheck // SA1019: ibctesting.FirstConnectionID is deprecated: use path.EndpointA.ConnectionID instead. (staticcheck)/nolint _, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), nil, ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0)) suite.Require().NoError(err) err = path.EndpointB.UpdateClient() From e6987b521c10b0dd3332dd8a89fdef197f03199a Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 17 Jan 2023 14:27:31 -0600 Subject: [PATCH 10/15] rm nolintlint --- .golangci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 14f775ad072..15f140f2025 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,7 +26,6 @@ linters: - unconvert - unused - misspell - - nolintlint issues: exclude-rules: From cce9ad98824c0061b82d0d412dda35055a76540e Mon Sep 17 00:00:00 2001 From: Charly Date: Wed, 18 Jan 2023 14:37:19 -0600 Subject: [PATCH 11/15] add a clientState update to verify that query returns consensusstates only --- modules/core/02-client/keeper/grpc_query_test.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index a961f68b61c..3550b607fc1 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -302,13 +302,11 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { testCases := []struct { msg string - expectedConsensusStates uint64 malleate func() expPass bool }{ { "success: without pagination", - 0, func() { req = &types.QueryConsensusStatesRequest{ ClientId: testClientID, @@ -318,7 +316,6 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { }, { "success, no results", - 0, func() { req = &types.QueryConsensusStatesRequest{ ClientId: testClientID, @@ -332,11 +329,13 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { }, { "success", - 2, func() { path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path) + path1 := ibctesting.NewPath(suite.chainA, suite.chainB) + suite.coordinator.SetupClients(path1) + height1 := path.EndpointA.GetClientState().GetLatestHeight().(types.Height) expConsensusStates = append( expConsensusStates, @@ -368,7 +367,6 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { }, { "invalid client identifier", - 0, func() { req = &types.QueryConsensusStatesRequest{} }, @@ -387,7 +385,6 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(tc.expectedConsensusStates, res.Pagination.Total) suite.Require().Equal(len(expConsensusStates), len(res.ConsensusStates)) for i := range expConsensusStates { suite.Require().NotNil(res.ConsensusStates[i]) From a41069c37e007a128b798b54d3162a41ace003ea Mon Sep 17 00:00:00 2001 From: Charly Date: Wed, 18 Jan 2023 14:48:58 -0600 Subject: [PATCH 12/15] format --- modules/core/02-client/keeper/grpc_query_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 3550b607fc1..e3030758615 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -301,9 +301,9 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { ) testCases := []struct { - msg string - malleate func() - expPass bool + msg string + malleate func() + expPass bool }{ { "success: without pagination", From c176b18978dc125dd8291aa3e8674e772e8163f3 Mon Sep 17 00:00:00 2001 From: Charly Date: Mon, 23 Jan 2023 07:37:14 -0600 Subject: [PATCH 13/15] update test rm unnecessary value --- modules/core/02-client/keeper/grpc_query_test.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index e3030758615..892ec511bf6 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -97,14 +97,12 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { ) testCases := []struct { - msg string - expectedClientStates uint64 - malleate func() - expPass bool + msg string + malleate func() + expPass bool }{ { "req is nil", - 0, func() { req = nil }, @@ -112,7 +110,6 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { }, { "empty pagination", - 0, func() { req = &types.QueryClientStatesRequest{} }, @@ -120,7 +117,6 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { }, { "success, no results", - 0, func() { req = &types.QueryClientStatesRequest{ Pagination: &query.PageRequest{ @@ -133,7 +129,6 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { }, { "success", - 2, func() { path1 := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path1) @@ -171,7 +166,7 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(tc.expectedClientStates, res.Pagination.Total) + suite.Require().Equal(len(expClientStates), res.Pagination.Total) suite.Require().Equal(expClientStates.Sort(), res.ClientStates) } else { suite.Require().Error(err) From b14bdfdf78c1b9bd8effb301b84fc309c7d96ab0 Mon Sep 17 00:00:00 2001 From: Charly Date: Mon, 23 Jan 2023 11:32:03 -0600 Subject: [PATCH 14/15] uint64 --- modules/core/02-client/keeper/grpc_query_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 892ec511bf6..6a5308f7999 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -166,7 +166,7 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(len(expClientStates), res.Pagination.Total) + suite.Require().Equal(uint64(len(expClientStates)), res.Pagination.Total) suite.Require().Equal(expClientStates.Sort(), res.ClientStates) } else { suite.Require().Error(err) From d57b50e67071354a9987d553c97ad954ee63eb1e Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 24 Jan 2023 16:35:12 -0600 Subject: [PATCH 15/15] fix pr review --- modules/core/02-client/keeper/grpc_query_test.go | 5 +---- modules/core/04-channel/keeper/grpc_query_test.go | 11 +++-------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 6a5308f7999..9ff637a6065 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -166,8 +166,8 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(uint64(len(expClientStates)), res.Pagination.Total) suite.Require().Equal(expClientStates.Sort(), res.ClientStates) + suite.Require().Equal(len(expClientStates), int(res.Pagination.Total)) } else { suite.Require().Error(err) } @@ -328,9 +328,6 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path) - path1 := ibctesting.NewPath(suite.chainA, suite.chainB) - suite.coordinator.SetupClients(path1) - height1 := path.EndpointA.GetClientState().GetLatestHeight().(types.Height) expConsensusStates = append( expConsensusStates, diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index b71f71be344..2bdc2607c57 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -112,14 +112,12 @@ func (suite *KeeperTestSuite) TestQueryChannels() { ) testCases := []struct { - msg string - expectedChannels uint64 - malleate func() - expPass bool + msg string + malleate func() + expPass bool }{ { "empty request", - 0, func() { req = nil }, @@ -127,7 +125,6 @@ func (suite *KeeperTestSuite) TestQueryChannels() { }, { "empty pagination", - 0, func() { req = &types.QueryChannelsRequest{} }, @@ -135,7 +132,6 @@ func (suite *KeeperTestSuite) TestQueryChannels() { }, { "success", - 2, func() { path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) @@ -197,7 +193,6 @@ func (suite *KeeperTestSuite) TestQueryChannels() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(tc.expectedChannels, res.Pagination.Total) suite.Require().Equal(expChannels, res.Channels) suite.Require().Equal(len(expChannels), int(res.Pagination.Total)) } else {