From 64e4690e84f98e4cb3a61537bd59dc14580e3b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 15 Aug 2022 13:49:15 +0200 Subject: [PATCH] add 02-client query client --- e2e/testsuite/grpc_query.go | 20 ++++++++++++++++++++ e2e/testsuite/testsuite.go | 2 ++ 2 files changed, 22 insertions(+) diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/grpc_query.go index 302403c3fbe..e3cd50a8979 100644 --- a/e2e/testsuite/grpc_query.go +++ b/e2e/testsuite/grpc_query.go @@ -5,9 +5,29 @@ import ( "github.com/strangelove-ventures/ibctest/ibc" + clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v5/modules/core/exported" ) +// QueryClientState queries the client state on the given chain for the provided clientID. +func (s *E2ETestSuite) QueryClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexported.ClientState, error) { + queryClient := s.GetChainGRCPClients(chain).ClientQueryClient + res, err := queryClient.ClientState(ctx, &clienttypes.QueryClientStateRequest{ + ClientId: clientID, + }) + if err != nil { + return nil, err + } + + clientState, err := clienttypes.UnpackClientState(res.ClientState) + if err != nil { + return nil, err + } + + return clientState, nil +} + // 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 diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 16132793578..12257330fec 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -48,6 +48,7 @@ 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 { + ClientQueryClient clienttypes.QueryClient ChannelQueryClient channeltypes.QueryClient FeeQueryClient feetypes.QueryClient } @@ -277,6 +278,7 @@ func (s *E2ETestSuite) initGRPCClients(chain *cosmos.CosmosChain) { } s.grpcClients[chain.Config().ChainID] = GRPCClients{ + ClientQueryClient: clienttypes.NewQueryClient(grpcConn), ChannelQueryClient: channeltypes.NewQueryClient(grpcConn), FeeQueryClient: feetypes.NewQueryClient(grpcConn), }