Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add channel query client to e2e test suite #1985

Merged
merged 2 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought it might be nice to have a separate file for core queries we support

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense 👍


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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add a AssertPacketIsRelayed function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a useful assertion to have, we can always add it as we need it though if you don't want to include it in this PR.

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
}
7 changes: 5 additions & 2 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/cosmos/ibc-go/e2e/testconfig"
feetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types"
channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
)

const (
Expand All @@ -46,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 @@ -274,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