From fe6f9a85ad54d7934a1778ae04a3f9da54d9f908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 11 Aug 2022 14:04:56 +0200 Subject: [PATCH] feat: add channel query client to e2e test suite (#1985) ## Description closes: #1983 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x//spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes --- e2e/testsuite/grpc_query.go | 23 +++++++++++++++++++++++ e2e/testsuite/testsuite.go | 8 +++++--- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 e2e/testsuite/grpc_query.go diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/grpc_query.go new file mode 100644 index 00000000000..302403c3fbe --- /dev/null +++ b/e2e/testsuite/grpc_query.go @@ -0,0 +1,23 @@ +package testsuite + +import ( + "context" + + "github.com/strangelove-ventures/ibctest/ibc" + + channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" +) + +// QueryPacketCommitment queries the packet commitment on the given chain for the provided channel and sequence. +func (s *E2ETestSuite) QueryPacketCommitment(ctx context.Context, chain ibc.Chain, portID, channelID string, sequence uint64) ([]byte, error) { + queryClient := s.GetChainGRCPClients(chain).ChannelQueryClient + res, err := queryClient.PacketCommitment(ctx, &channeltypes.QueryPacketCommitmentRequest{ + PortId: portID, + ChannelId: channelID, + Sequence: sequence, + }) + if err != nil { + return nil, err + } + return res.Commitment, nil +} diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 10d58ef735a..502dac842df 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -21,7 +21,7 @@ import ( "github.com/cosmos/ibc-go/e2e/testconfig" feetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types" - clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" ) const ( @@ -47,7 +47,8 @@ type E2ETestSuite struct { // These should typically be used for query clients only. If we need to make changes, we should // use E2ETestSuite.BroadcastMessages to broadcast transactions instead. type GRPCClients struct { - FeeQueryClient feetypes.QueryClient + ChannelQueryClient channeltypes.QueryClient + FeeQueryClient feetypes.QueryClient } // path is a pairing of two chains which will be used in a test. @@ -275,7 +276,8 @@ func (s *E2ETestSuite) initGRPCClients(chain *cosmos.CosmosChain) { } s.grpcClients[chain.Config().ChainID] = GRPCClients{ - FeeQueryClient: feetypes.NewQueryClient(grpcConn), + ChannelQueryClient: channeltypes.NewQueryClient(grpcConn), + FeeQueryClient: feetypes.NewQueryClient(grpcConn), } }