Skip to content

Commit

Permalink
feat: add channel query client to e2e test suite (#1985)
Browse files Browse the repository at this point in the history
## 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/<module>/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
  • Loading branch information
colin-axner authored Aug 11, 2022
1 parent 5a9aeb1 commit fe6f9a8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
23 changes: 23 additions & 0 deletions e2e/testsuite/grpc_query.go
Original file line number Diff line number Diff line change
@@ -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
}
8 changes: 5 additions & 3 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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.
Expand Down Expand Up @@ -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),
}
}

Expand Down

0 comments on commit fe6f9a8

Please sign in to comment.