Skip to content

Commit

Permalink
remove query client (#3227)
Browse files Browse the repository at this point in the history
* remove query client

* merge main

* go mod tidy
  • Loading branch information
expertdicer committed Mar 14, 2023
1 parent b2ad0e1 commit 1bdb0e9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 44 deletions.
21 changes: 11 additions & 10 deletions modules/apps/29-fee/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() {
tc.malleate() // malleate mutates test data

ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.queryClient.IncentivizedPackets(ctx, req)

res, err := suite.chainA.GetSimApp().IBCFeeKeeper.IncentivizedPackets(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down Expand Up @@ -125,7 +126,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() {
tc.malleate() // malleate mutates test data

ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.queryClient.IncentivizedPacket(ctx, req)
res, err := suite.chainA.GetSimApp().IBCFeeKeeper.IncentivizedPacket(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down Expand Up @@ -219,7 +220,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() {
tc.malleate()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())

res, err := suite.queryClient.IncentivizedPacketsForChannel(ctx, req)
res, err := suite.chainA.GetSimApp().IBCFeeKeeper.IncentivizedPacketsForChannel(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down Expand Up @@ -275,7 +276,7 @@ func (suite *KeeperTestSuite) TestQueryTotalRecvFees() {
tc.malleate()

ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.queryClient.TotalRecvFees(ctx, req)
res, err := suite.chainA.GetSimApp().IBCFeeKeeper.TotalRecvFees(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down Expand Up @@ -334,7 +335,7 @@ func (suite *KeeperTestSuite) TestQueryTotalAckFees() {
tc.malleate()

ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.queryClient.TotalAckFees(ctx, req)
res, err := suite.chainA.GetSimApp().IBCFeeKeeper.TotalAckFees(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down Expand Up @@ -393,7 +394,7 @@ func (suite *KeeperTestSuite) TestQueryTotalTimeoutFees() {
tc.malleate()

ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.queryClient.TotalTimeoutFees(ctx, req)
res, err := suite.chainA.GetSimApp().IBCFeeKeeper.TotalTimeoutFees(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down Expand Up @@ -460,7 +461,7 @@ func (suite *KeeperTestSuite) TestQueryPayee() {
tc.malleate()

ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.queryClient.Payee(ctx, req)
res, err := suite.chainA.GetSimApp().IBCFeeKeeper.Payee(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down Expand Up @@ -523,7 +524,7 @@ func (suite *KeeperTestSuite) TestQueryCounterpartyPayee() {
tc.malleate()

ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.queryClient.CounterpartyPayee(ctx, req)
res, err := suite.chainA.GetSimApp().IBCFeeKeeper.CounterpartyPayee(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down Expand Up @@ -630,7 +631,7 @@ func (suite *KeeperTestSuite) TestQueryFeeEnabledChannels() {
tc.malleate()

ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.queryClient.FeeEnabledChannels(ctx, req)
res, err := suite.chainA.GetSimApp().IBCFeeKeeper.FeeEnabledChannels(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down Expand Up @@ -679,7 +680,7 @@ func (suite *KeeperTestSuite) TestQueryFeeEnabledChannel() {
tc.malleate()

ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.queryClient.FeeEnabledChannel(ctx, req)
res, err := suite.chainA.GetSimApp().IBCFeeKeeper.FeeEnabledChannel(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down
7 changes: 0 additions & 7 deletions modules/apps/29-fee/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"testing"

"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"

Expand Down Expand Up @@ -33,8 +32,6 @@ type KeeperTestSuite struct {

path *ibctesting.Path
pathAToC *ibctesting.Path

queryClient types.QueryClient
}

func (suite *KeeperTestSuite) SetupTest() {
Expand All @@ -57,10 +54,6 @@ func (suite *KeeperTestSuite) SetupTest() {
path.EndpointA.ChannelConfig.PortID = ibctesting.MockFeePort
path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort
suite.pathAToC = path

queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.GetSimApp().InterfaceRegistry())
types.RegisterQueryServer(queryHelper, suite.chainA.GetSimApp().IBCFeeKeeper)
suite.queryClient = types.NewQueryClient(queryHelper)
}

func TestKeeperTestSuite(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions modules/apps/transfer/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (suite *KeeperTestSuite) TestQueryDenomTrace() {
tc.malleate()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())

res, err := suite.queryClient.DenomTrace(ctx, req)
res, err := suite.chainA.GetSimApp().TransferKeeper.DenomTrace(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand All @@ -92,7 +92,7 @@ func (suite *KeeperTestSuite) TestQueryDenomTrace() {
func (suite *KeeperTestSuite) TestQueryDenomTraces() {
var (
req *types.QueryDenomTracesRequest
expTraces = types.Traces(nil)
expTraces = types.Traces{}
)

testCases := []struct {
Expand Down Expand Up @@ -136,7 +136,7 @@ func (suite *KeeperTestSuite) TestQueryDenomTraces() {
tc.malleate()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())

res, err := suite.queryClient.DenomTraces(ctx, req)
res, err := suite.chainA.GetSimApp().TransferKeeper.DenomTraces(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand All @@ -152,7 +152,7 @@ func (suite *KeeperTestSuite) TestQueryDenomTraces() {
func (suite *KeeperTestSuite) TestQueryParams() {
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
expParams := types.DefaultParams()
res, _ := suite.queryClient.Params(ctx, &types.QueryParamsRequest{})
res, _ := suite.chainA.GetSimApp().TransferKeeper.Params(ctx, &types.QueryParamsRequest{})
suite.Require().Equal(&expParams, res.Params)
}

Expand Down Expand Up @@ -209,7 +209,7 @@ func (suite *KeeperTestSuite) TestQueryDenomHash() {
tc.malleate()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())

res, err := suite.queryClient.DenomHash(ctx, req)
res, err := suite.chainA.GetSimApp().TransferKeeper.DenomHash(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down Expand Up @@ -249,7 +249,7 @@ func (suite *KeeperTestSuite) TestEscrowAddress() {
tc.malleate()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())

res, err := suite.queryClient.EscrowAddress(ctx, req)
res, err := suite.chainA.GetSimApp().TransferKeeper.EscrowAddress(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
Expand Down
3 changes: 0 additions & 3 deletions modules/apps/transfer/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ type KeeperTestSuite struct {
chainA *ibctesting.TestChain
chainB *ibctesting.TestChain
chainC *ibctesting.TestChain

queryClient types.QueryClient
}

func (suite *KeeperTestSuite) SetupTest() {
Expand All @@ -31,7 +29,6 @@ func (suite *KeeperTestSuite) SetupTest() {

queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.GetSimApp().InterfaceRegistry())
types.RegisterQueryServer(queryHelper, suite.chainA.GetSimApp().TransferKeeper)
suite.queryClient = types.NewQueryClient(queryHelper)
}

func NewTransferPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {
Expand Down
7 changes: 1 addition & 6 deletions modules/core/02-client/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import (

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
"github.com/cosmos/cosmos-sdk/types/query"
"google.golang.org/grpc/metadata"

"github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
Expand Down Expand Up @@ -631,10 +629,7 @@ func (suite *KeeperTestSuite) TestQueryUpgradedConsensusStates() {

tc.malleate()

ctx := sdk.WrapSDKContext(suite.ctx)
ctx = metadata.AppendToOutgoingContext(ctx, grpctypes.GRPCBlockHeightHeader, fmt.Sprintf("%d", height))

res, err := suite.queryClient.UpgradedConsensusState(ctx, req)
res, err := suite.keeper.UpgradedConsensusState(suite.ctx, req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().True(expConsensusState.Equal(res.UpgradedConsensusState))
Expand Down
13 changes: 1 addition & 12 deletions modules/core/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ import (
tmbytes "github.com/cometbft/cometbft/libs/bytes"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/suite"

"github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper"
"github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
Expand All @@ -25,6 +22,7 @@ import (
ibctesting "github.com/cosmos/ibc-go/v7/testing"
ibctestingmock "github.com/cosmos/ibc-go/v7/testing/mock"
"github.com/cosmos/ibc-go/v7/testing/simapp"
"github.com/stretchr/testify/suite"
)

const (
Expand Down Expand Up @@ -68,9 +66,6 @@ type KeeperTestSuite struct {
solomachine *ibctesting.Solomachine

signers map[string]tmtypes.PrivValidator

// TODO: deprecate
queryClient types.QueryClient
}

func (suite *KeeperTestSuite) SetupTest() {
Expand All @@ -89,7 +84,6 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: height, ChainID: testClientID, Time: now2})
suite.keeper = &app.IBCKeeper.ClientKeeper
suite.privVal = ibctestingmock.NewPV()

pubKey, err := suite.privVal.GetPubKey()
suite.Require().NoError(err)

Expand Down Expand Up @@ -124,11 +118,6 @@ func (suite *KeeperTestSuite) SetupTest() {
}

suite.solomachine = ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachinesingle", "testing", 1)

// TODO: deprecate
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, app.InterfaceRegistry())
types.RegisterQueryServer(queryHelper, app.IBCKeeper.ClientKeeper)
suite.queryClient = types.NewQueryClient(queryHelper)
}

func TestKeeperTestSuite(t *testing.T) {
Expand Down

0 comments on commit 1bdb0e9

Please sign in to comment.