Skip to content

Commit

Permalink
updating grpc query tests, removing queryClient on KeeperTestSuite (#379
Browse files Browse the repository at this point in the history
)
  • Loading branch information
damiannolan authored Sep 6, 2021
1 parent 74fb34e commit d37f2ec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion modules/apps/27-interchain-accounts/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand All @@ -20,7 +21,7 @@ func (k Keeper) InterchainAccountAddress(ctx context.Context, req *types.QueryIn
return nil, status.Error(codes.InvalidArgument, "empty request")
}

if req.CounterpartyPortId == "" {
if strings.TrimSpace(req.CounterpartyPortId) == "" {
return nil, status.Error(codes.InvalidArgument, "counterparty portID cannot be empty")
}

Expand Down
6 changes: 3 additions & 3 deletions modules/apps/27-interchain-accounts/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ func (suite *KeeperTestSuite) TestQueryInterchainAccountAddress() {
{
"empty request",
func() {
req = &types.QueryInterchainAccountAddressRequest{}
req = nil
},
false,
},
{
"invalid counterparty portID",
func() {
req = &types.QueryInterchainAccountAddressRequest{
CounterpartyPortId: "",
CounterpartyPortId: " ",
}
},
false,
Expand Down Expand Up @@ -66,7 +66,7 @@ func (suite *KeeperTestSuite) TestQueryInterchainAccountAddress() {
tc.malleate()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())

res, err := suite.queryClient.InterchainAccountAddress(ctx, req)
res, err := suite.chainA.GetSimApp().ICAKeeper.InterchainAccountAddress(ctx, req)

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

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

Expand All @@ -21,19 +20,13 @@ type KeeperTestSuite struct {
chainA *ibctesting.TestChain
chainB *ibctesting.TestChain
chainC *ibctesting.TestChain

queryClient types.QueryClient
}

func (suite *KeeperTestSuite) SetupTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3)
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0))
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1))
suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(2))

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

func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {
Expand Down

0 comments on commit d37f2ec

Please sign in to comment.