From f23688ec8fbeb7022456d587d36e4fff66145a31 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 12 Mar 2024 15:22:25 +0700 Subject: [PATCH 01/18] e2e: testsuite updated --- e2e/testsuite/grpc_query.go | 445 +++--------------------------------- e2e/testsuite/testsuite.go | 46 ++-- e2e/testsuite/tx.go | 30 ++- 3 files changed, 85 insertions(+), 436 deletions(-) diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/grpc_query.go index 44ba2614d94..1e39188d2ad 100644 --- a/e2e/testsuite/grpc_query.go +++ b/e2e/testsuite/grpc_query.go @@ -3,69 +3,23 @@ package testsuite import ( "context" "fmt" - "sort" + "strings" - "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v8/ibc" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "cosmossdk.io/math" - upgradetypes "cosmossdk.io/x/upgrade/types" - - "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/authz" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - grouptypes "github.com/cosmos/cosmos-sdk/x/group" - paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" - controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" - hosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" - feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + "github.com/cosmos/gogoproto/proto" ) -// GRPCClients holds a reference to any GRPC clients that are needed by the tests. -// 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 - ConnectionQueryClient connectiontypes.QueryClient - ChannelQueryClient channeltypes.QueryClient - TransferQueryClient transfertypes.QueryClient - FeeQueryClient feetypes.QueryClient - ICAControllerQueryClient controllertypes.QueryClient - ICAHostQueryClient hosttypes.QueryClient - WasmQueryClient wasmtypes.QueryClient - - // SDK query clients - BankQueryClient banktypes.QueryClient - GovQueryClient govtypesv1beta1.QueryClient - GovQueryClientV1 govtypesv1.QueryClient - GroupsQueryClient grouptypes.QueryClient - ParamsQueryClient paramsproposaltypes.QueryClient - AuthQueryClient authtypes.QueryClient - AuthZQueryClient authz.QueryClient - UpgradeQueryClient upgradetypes.QueryClient - - ConsensusServiceClient cmtservice.ServiceClient -} - -// InitGRPCClients establishes GRPC clients with the given chain. -// The created GRPCClients can be retrieved with GetChainGRCPClients. -func (s *E2ETestSuite) InitGRPCClients(chain ibc.Chain) { - _, ok := chain.(*cosmos.CosmosChain) - if !ok { - return +// Queries the chain with a query request and deserializes the response to T +func GRPCQuery[T any](ctx context.Context, chain ibc.Chain, req proto.Message, opts ...grpc.CallOption) (*T, error) { + path, err := getProtoPath(req) + if err != nil { + return nil, err } // Create a connection to the gRPC server. @@ -73,392 +27,65 @@ func (s *E2ETestSuite) InitGRPCClients(chain ibc.Chain) { chain.GetHostGRPCAddress(), grpc.WithTransportCredentials(insecure.NewCredentials()), ) - s.Require().NoError(err) - s.T().Cleanup(func() { - if err := grpcConn.Close(); err != nil { - s.T().Logf("failed closing GRPC connection to chain %s: %s", chain.Config().ChainID, err) - } - }) - - if s.grpcClients == nil { - s.grpcClients = make(map[string]GRPCClients) - } - - s.grpcClients[chain.Config().ChainID] = GRPCClients{ - ClientQueryClient: clienttypes.NewQueryClient(grpcConn), - ConnectionQueryClient: connectiontypes.NewQueryClient(grpcConn), - ChannelQueryClient: channeltypes.NewQueryClient(grpcConn), - TransferQueryClient: transfertypes.NewQueryClient(grpcConn), - FeeQueryClient: feetypes.NewQueryClient(grpcConn), - ICAControllerQueryClient: controllertypes.NewQueryClient(grpcConn), - ICAHostQueryClient: hosttypes.NewQueryClient(grpcConn), - WasmQueryClient: wasmtypes.NewQueryClient(grpcConn), - BankQueryClient: banktypes.NewQueryClient(grpcConn), - GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn), - GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn), - GroupsQueryClient: grouptypes.NewQueryClient(grpcConn), - ParamsQueryClient: paramsproposaltypes.NewQueryClient(grpcConn), - AuthQueryClient: authtypes.NewQueryClient(grpcConn), - AuthZQueryClient: authz.NewQueryClient(grpcConn), - ConsensusServiceClient: cmtservice.NewServiceClient(grpcConn), - UpgradeQueryClient: upgradetypes.NewQueryClient(grpcConn), - } -} - -// 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 - } - - cfg := EncodingConfig() - var clientState ibcexported.ClientState - if err := cfg.InterfaceRegistry.UnpackAny(res.ClientState, &clientState); err != nil { - return nil, err - } - - return clientState, nil -} - -// QueryUpgradedClientState queries the upgraded client state on the given chain for the provided clientID. -func (s *E2ETestSuite) QueryUpgradedClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexported.ClientState, error) { - queryClient := s.GetChainGRCPClients(chain).ClientQueryClient - res, err := queryClient.UpgradedClientState(ctx, &clienttypes.QueryUpgradedClientStateRequest{}) - if err != nil { - return nil, err - } - - cfg := EncodingConfig() - var clientState ibcexported.ClientState - if err := cfg.InterfaceRegistry.UnpackAny(res.UpgradedClientState, &clientState); err != nil { - return nil, err - } - - return clientState, nil -} - -// QueryClientStatus queries the status of the client by clientID -func (s *E2ETestSuite) QueryClientStatus(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { - queryClient := s.GetChainGRCPClients(chain).ClientQueryClient - res, err := queryClient.ClientStatus(ctx, &clienttypes.QueryClientStatusRequest{ - ClientId: clientID, - }) - if err != nil { - return "", err - } - - return res.Status, nil -} - -// QueryCurrentUpgradePlan queries the currently scheduled upgrade plans. -func (s *E2ETestSuite) QueryCurrentUpgradePlan(ctx context.Context, chain ibc.Chain) (upgradetypes.Plan, error) { - queryClient := s.GetChainGRCPClients(chain).UpgradeQueryClient - res, err := queryClient.CurrentPlan(ctx, &upgradetypes.QueryCurrentPlanRequest{}) - if err != nil { - return upgradetypes.Plan{}, err - } - - return *res.Plan, nil -} - -// QueryConnection queries the connection end using the given chain and connection id. -func (s *E2ETestSuite) QueryConnection(ctx context.Context, chain ibc.Chain, connectionID string) (connectiontypes.ConnectionEnd, error) { - queryClient := s.GetChainGRCPClients(chain).ConnectionQueryClient - res, err := queryClient.Connection(ctx, &connectiontypes.QueryConnectionRequest{ - ConnectionId: connectionID, - }) - if err != nil { - return connectiontypes.ConnectionEnd{}, err - } - - return *res.Connection, nil -} - -// QueryChannel queries the channel on a given chain for the provided portID and channelID -func (s *E2ETestSuite) QueryChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.Channel, error) { - queryClient := s.GetChainGRCPClients(chain).ChannelQueryClient - res, err := queryClient.Channel(ctx, &channeltypes.QueryChannelRequest{ - PortId: portID, - ChannelId: channelID, - }) - if err != nil { - return channeltypes.Channel{}, err - } - - return *res.Channel, 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 - res, err := queryClient.PacketCommitment(ctx, &channeltypes.QueryPacketCommitmentRequest{ - PortId: portID, - ChannelId: channelID, - Sequence: sequence, - }) - if err != nil { - return nil, err - } - return res.Commitment, nil -} - -// QueryPacketAcknowledgements queries the packet acknowledgements on the given chain for the provided channel (optional) list of packet commitment sequences. -func (s *E2ETestSuite) QueryPacketAcknowledgements(ctx context.Context, chain ibc.Chain, portID, channelID string, packetCommitmentSequences []uint64) ([]*channeltypes.PacketState, error) { - queryClient := s.GetChainGRCPClients(chain).ChannelQueryClient - res, err := queryClient.PacketAcknowledgements(ctx, &channeltypes.QueryPacketAcknowledgementsRequest{ - PortId: portID, - ChannelId: channelID, - PacketCommitmentSequences: packetCommitmentSequences, - }) if err != nil { return nil, err } - return res.Acknowledgements, nil -} - -// QueryUpgradeError queries the upgrade error on the given chain for the provided channel. -func (s *E2ETestSuite) QueryUpgradeError(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.ErrorReceipt, error) { - queryClient := s.GetChainGRCPClients(chain).ChannelQueryClient - res, err := queryClient.UpgradeError(ctx, &channeltypes.QueryUpgradeErrorRequest{ - PortId: portID, - ChannelId: channelID, - }) - if err != nil { - return channeltypes.ErrorReceipt{}, err - } - return res.ErrorReceipt, nil -} - -// QueryTotalEscrowForDenom queries the total amount of tokens in escrow for a denom -func (s *E2ETestSuite) QueryTotalEscrowForDenom(ctx context.Context, chain ibc.Chain, denom string) (sdk.Coin, error) { - queryClient := s.GetChainGRCPClients(chain).TransferQueryClient - res, err := queryClient.TotalEscrowForDenom(ctx, &transfertypes.QueryTotalEscrowForDenomRequest{ - Denom: denom, - }) - if err != nil { - return sdk.Coin{}, err - } - - return res.Amount, nil -} -// QueryInterchainAccount queries the interchain account for the given owner and connectionID. -func (s *E2ETestSuite) QueryInterchainAccount(ctx context.Context, chain ibc.Chain, owner, connectionID string) (string, error) { - queryClient := s.GetChainGRCPClients(chain).ICAControllerQueryClient - res, err := queryClient.InterchainAccount(ctx, &controllertypes.QueryInterchainAccountRequest{ - Owner: owner, - ConnectionId: connectionID, - }) - if err != nil { - return "", err - } - return res.Address, nil -} + defer grpcConn.Close() -// QueryIncentivizedPacketsForChannel queries the incentivized packets on the specified channel. -func (s *E2ETestSuite) QueryIncentivizedPacketsForChannel( - ctx context.Context, - chain ibc.Chain, - portID, - channelID string, -) ([]*feetypes.IdentifiedPacketFees, error) { - queryClient := s.GetChainGRCPClients(chain).FeeQueryClient - res, err := queryClient.IncentivizedPacketsForChannel(ctx, &feetypes.QueryIncentivizedPacketsForChannelRequest{ - PortId: portID, - ChannelId: channelID, - }) + resp := new(T) + err = grpcConn.Invoke(ctx, path, req, resp, opts...) if err != nil { return nil, err } - return res.IncentivizedPackets, err -} - -// QueryFeeEnabledChannel queries the fee-enabled status of a channel. -func (s *E2ETestSuite) QueryFeeEnabledChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (bool, error) { - queryClient := s.GetChainGRCPClients(chain).FeeQueryClient - res, err := queryClient.FeeEnabledChannel(ctx, &feetypes.QueryFeeEnabledChannelRequest{ - PortId: portID, - ChannelId: channelID, - }) - if err != nil { - return false, err - } - return res.FeeEnabled, nil -} - -// QueryCounterPartyPayee queries the counterparty payee of the given chain and relayer address on the specified channel. -func (s *E2ETestSuite) QueryCounterPartyPayee(ctx context.Context, chain ibc.Chain, relayerAddress, channelID string) (string, error) { - queryClient := s.GetChainGRCPClients(chain).FeeQueryClient - res, err := queryClient.CounterpartyPayee(ctx, &feetypes.QueryCounterpartyPayeeRequest{ - ChannelId: channelID, - Relayer: relayerAddress, - }) - if err != nil { - return "", err - } - return res.CounterpartyPayee, nil -} - -// QueryBalance returns the balance of a specific denomination for a given account by address. -func (s *E2ETestSuite) QueryBalance(ctx context.Context, chain ibc.Chain, address string, denom string) (math.Int, error) { - queryClient := s.GetChainGRCPClients(chain).BankQueryClient - res, err := queryClient.Balance(ctx, &banktypes.QueryBalanceRequest{ - Address: address, - Denom: denom, - }) - if err != nil { - return math.Int{}, err - } - - return res.Balance.Amount, nil -} - -// QueryProposalV1Beta1 queries the governance proposal on the given chain with the given proposal ID. -func (s *E2ETestSuite) QueryProposalV1Beta1(ctx context.Context, chain ibc.Chain, proposalID uint64) (govtypesv1beta1.Proposal, error) { - queryClient := s.GetChainGRCPClients(chain).GovQueryClient - res, err := queryClient.Proposal(ctx, &govtypesv1beta1.QueryProposalRequest{ - ProposalId: proposalID, - }) - if err != nil { - return govtypesv1beta1.Proposal{}, err - } - return res.Proposal, nil + return resp, nil } -func (s *E2ETestSuite) QueryProposalV1(ctx context.Context, chain ibc.Chain, proposalID uint64) (govtypesv1.Proposal, error) { - queryClient := s.GetChainGRCPClients(chain).GovQueryClientV1 - res, err := queryClient.Proposal(ctx, &govtypesv1.QueryProposalRequest{ - ProposalId: proposalID, - }) - if err != nil { - return govtypesv1.Proposal{}, err - } - - return *res.Proposal, nil -} +func getProtoPath(req proto.Message) (string, error) { + typeUrl := "/" + proto.MessageName(req) -// GetBlockHeaderByHeight fetches the block header at a given height. -func (s *E2ETestSuite) GetBlockHeaderByHeight(ctx context.Context, chain ibc.Chain, height uint64) (*cmtservice.Header, error) { - consensusService := s.GetChainGRCPClients(chain).ConsensusServiceClient - res, err := consensusService.GetBlockByHeight(ctx, &cmtservice.GetBlockByHeightRequest{ - Height: int64(height), - }) - if err != nil { - return nil, err + queryIndex := strings.Index(typeUrl, "Query") + if queryIndex == -1 { + return "", fmt.Errorf("invalid typeUrl: %s", typeUrl) } - return &res.SdkBlock.Header, nil -} + // Add to the index to account for the length of "Query" + queryIndex += len("Query") -// GetValidatorSetByHeight returns the validators of the given chain at the specified height. The returned validators -// are sorted by address. -func (s *E2ETestSuite) GetValidatorSetByHeight(ctx context.Context, chain ibc.Chain, height uint64) ([]*cmtservice.Validator, error) { - consensusService := s.GetChainGRCPClients(chain).ConsensusServiceClient - res, err := consensusService.GetValidatorSetByHeight(ctx, &cmtservice.GetValidatorSetByHeightRequest{ - Height: int64(height), - }) - if err != nil { - return nil, err + // Add a slash before the query + urlWithSlash := typeUrl[:queryIndex] + "/" + typeUrl[queryIndex:] + if !strings.HasSuffix(urlWithSlash, "Request") { + return "", fmt.Errorf("invalid typeUrl: %s", typeUrl) } - sort.SliceStable(res.Validators, func(i, j int) bool { - return res.Validators[i].Address < res.Validators[j].Address - }) - - return res.Validators, nil + return strings.TrimSuffix(urlWithSlash, "Request"), nil } -// QueryModuleAccountAddress returns the sdk.AccAddress of a given module name. +// QueryModuleAccountAddress returns the address of the given module on the given chain. +// Added because interchaintest's method doesn't work. func (s *E2ETestSuite) QueryModuleAccountAddress(ctx context.Context, moduleName string, chain ibc.Chain) (sdk.AccAddress, error) { - authClient := s.GetChainGRCPClients(chain).AuthQueryClient - resp, err := authClient.ModuleAccountByName(ctx, &authtypes.QueryModuleAccountByNameRequest{ - Name: moduleName, - }) + modAccResp, err := GRPCQuery[authtypes.QueryModuleAccountByNameResponse]( + ctx, chain, &authtypes.QueryModuleAccountByNameRequest{Name: moduleName}, + ) if err != nil { return nil, err } - cfg := EncodingConfig() - + cfg := chain.Config().EncodingConfig var account sdk.AccountI - if err := cfg.InterfaceRegistry.UnpackAny(resp.Account, &account); err != nil { - return nil, err - } - moduleAccount, ok := account.(authtypes.ModuleAccountI) - if !ok { - return nil, fmt.Errorf("failed to cast account: %T as ModuleAccount", moduleAccount) - } - - return moduleAccount.GetAddress(), nil -} - -// QueryGranterGrants returns all GrantAuthorizations for the given granterAddress. -func (s *E2ETestSuite) QueryGranterGrants(ctx context.Context, chain ibc.Chain, granterAddress string) ([]*authz.GrantAuthorization, error) { - authzClient := s.GetChainGRCPClients(chain).AuthZQueryClient - queryRequest := &authz.QueryGranterGrantsRequest{ - Granter: granterAddress, - } - - grants, err := authzClient.GranterGrants(ctx, queryRequest) + err = cfg.InterfaceRegistry.UnpackAny(modAccResp.Account, &account) if err != nil { return nil, err } - return grants.Grants, nil -} - -// QueryAllBalances returns all the balances on the given chain for the provided address. -func (s *E2ETestSuite) QueryAllBalances(ctx context.Context, chain ibc.Chain, address string, resolveDenom bool) (sdk.Coins, error) { - queryClient := s.GetChainGRCPClients(chain).BankQueryClient - res, err := queryClient.AllBalances(ctx, &banktypes.QueryAllBalancesRequest{ - Address: address, - ResolveDenom: resolveDenom, - }) - if err != nil { - return sdk.Coins{}, err - } - - return res.Balances, nil -} - -// QueryDenomMetadata queries the metadata for the given denom. -func (s *E2ETestSuite) QueryDenomMetadata(ctx context.Context, chain ibc.Chain, denom string) (banktypes.Metadata, error) { - bankClient := s.GetChainGRCPClients(chain).BankQueryClient - queryRequest := &banktypes.QueryDenomMetadataRequest{ - Denom: denom, - } - res, err := bankClient.DenomMetadata(ctx, queryRequest) - if err != nil { - return banktypes.Metadata{}, err - } - return res.Metadata, nil -} - -// QueryWasmCode queries the code for a wasm contract. -func (s *E2ETestSuite) QueryWasmCode(ctx context.Context, chain ibc.Chain, checksum string) ([]byte, error) { - queryClient := s.GetChainGRCPClients(chain).WasmQueryClient - queryRequest := &wasmtypes.QueryCodeRequest{ - Checksum: checksum, - } - res, err := queryClient.Code(ctx, queryRequest) - if err != nil { - return nil, err + govAccount, ok := account.(sdk.ModuleAccountI) + if !ok { + return nil, fmt.Errorf("account is not a module account") } - return res.Data, nil -} - -// QueryWasmChecksums queries the wasm code checksums stored within the 08-wasm module. -func (s *E2ETestSuite) QueryWasmChecksums(ctx context.Context, chain ibc.Chain) ([]string, error) { - queryClient := s.GetChainGRCPClients(chain).WasmQueryClient - res, err := queryClient.Checksums(ctx, &wasmtypes.QueryChecksumsRequest{}) - if err != nil { - return nil, err + if govAccount.GetAddress().String() == "" { + return nil, fmt.Errorf("module account address is empty") } - return res.Checksums, nil + return govAccount.GetAddress(), nil } diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 138632982ba..8622c276711 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -17,6 +17,7 @@ import ( sdkmath "cosmossdk.io/math" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/ibc-go/e2e/relayer" @@ -42,7 +43,6 @@ type E2ETestSuite struct { // proposalIDs keeps track of the active proposal ID for each chain. proposalIDs map[string]uint64 - grpcClients map[string]GRPCClients paths map[string]pathPair relayers relayer.Map logger *zap.Logger @@ -96,8 +96,6 @@ func (s *E2ETestSuite) GetRelayerUsers(ctx context.Context, chainOpts ...ChainOp func (s *E2ETestSuite) SetupChainsRelayerAndChannel(ctx context.Context, channelOpts func(*ibc.CreateChannelOptions), chainSpecOpts ...ChainOptionConfiguration) (ibc.Relayer, ibc.ChannelOutput) { chainA, chainB := s.GetChains(chainSpecOpts...) r := s.ConfigureRelayer(ctx, chainA, chainB, channelOpts) - s.InitGRPCClients(chainA) - s.InitGRPCClients(chainB) chainAChannels, err := r.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID) s.Require().NoError(err) return r, chainAChannels[len(chainAChannels)-1] @@ -165,9 +163,6 @@ func (s *E2ETestSuite) SetupSingleChain(ctx context.Context) ibc.Chain { SkipPathCreation: true, })) - s.InitGRPCClients(chainA) - s.InitGRPCClients(chainB) - return chainA } @@ -314,34 +309,43 @@ func (s *E2ETestSuite) CreateUserOnChainB(ctx context.Context, amount int64) ibc func (s *E2ETestSuite) GetChainANativeBalance(ctx context.Context, user ibc.Wallet) (int64, error) { chainA, _ := s.GetChains() - balance, err := s.QueryBalance(ctx, chainA, user.FormattedAddress(), chainA.Config().Denom) + balanceResp, err := GRPCQuery[banktypes.QueryBalanceResponse](ctx, chainA, &banktypes.QueryBalanceRequest{ + Address: user.FormattedAddress(), + Denom: chainA.Config().Denom, + }) if err != nil { return 0, err } - return balance.Int64(), nil + + return balanceResp.Balance.Amount.Int64(), nil } // GetChainBNativeBalance gets the balance of a given user on chain B. func (s *E2ETestSuite) GetChainBNativeBalance(ctx context.Context, user ibc.Wallet) (int64, error) { _, chainB := s.GetChains() - balance, err := s.QueryBalance(ctx, chainB, user.FormattedAddress(), chainB.Config().Denom) + + balanceResp, err := GRPCQuery[banktypes.QueryBalanceResponse](ctx, chainB, &banktypes.QueryBalanceRequest{ + Address: user.FormattedAddress(), + Denom: chainB.Config().Denom, + }) if err != nil { - return -1, err + return 0, err } - return balance.Int64(), nil -} -// GetChainGRCPClients gets the GRPC clients associated with the given chain. -func (s *E2ETestSuite) GetChainGRCPClients(chain ibc.Chain) GRPCClients { - cs, ok := s.grpcClients[chain.Config().ChainID] - s.Require().True(ok, "chain %s does not have GRPC clients", chain.Config().ChainID) - return cs + return balanceResp.Balance.Amount.Int64(), nil } // AssertPacketRelayed asserts that the packet commitment does not exist on the sending chain. // The packet commitment will be deleted upon a packet acknowledgement or timeout. func (s *E2ETestSuite) AssertPacketRelayed(ctx context.Context, chain ibc.Chain, portID, channelID string, sequence uint64) { - commitment, _ := s.QueryPacketCommitment(ctx, chain, portID, channelID, sequence) + commitmentResp, err := GRPCQuery[channeltypes.QueryPacketCommitmentResponse](ctx, chain, &channeltypes.QueryPacketCommitmentRequest{ + PortId: portID, + ChannelId: channelID, + Sequence: sequence, + }) + s.Require().NoError(err) + + commitment := commitmentResp.Commitment s.Require().Empty(commitment) } @@ -349,9 +353,13 @@ func (s *E2ETestSuite) AssertPacketRelayed(ctx context.Context, chain ibc.Chain, func (s *E2ETestSuite) AssertHumanReadableDenom(ctx context.Context, chain ibc.Chain, counterpartyNativeDenom string, counterpartyChannel ibc.ChannelOutput) { chainIBCDenom := GetIBCToken(counterpartyNativeDenom, counterpartyChannel.Counterparty.PortID, counterpartyChannel.Counterparty.ChannelID) - denomMetadata, err := s.QueryDenomMetadata(ctx, chain, chainIBCDenom.IBCDenom()) + denomMetadataResp, err := GRPCQuery[banktypes.QueryDenomMetadataResponse](ctx, chain, &banktypes.QueryDenomMetadataRequest{ + Denom: chainIBCDenom.IBCDenom(), + }) s.Require().NoError(err) + denomMetadata := denomMetadataResp.Metadata + s.Require().Equal(chainIBCDenom.IBCDenom(), denomMetadata.Base, "denom metadata base does not match expected %s: got %s", chainIBCDenom.IBCDenom(), denomMetadata.Base) expectedName := fmt.Sprintf("%s/%s/%s IBC token", counterpartyChannel.Counterparty.PortID, counterpartyChannel.Counterparty.ChannelID, counterpartyNativeDenom) s.Require().Equal(expectedName, denomMetadata.Name, "denom metadata name does not match expected %s: got %s", expectedName, denomMetadata.Name) diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index c3f39b8685c..dfb38564460 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -179,16 +179,18 @@ func (s *E2ETestSuite) ExecuteGovV1Proposal(ctx context.Context, msg sdk.Msg, ch // waitForGovV1ProposalToPass polls for the entire voting period to see if the proposal has passed. // if the proposal has not passed within the duration of the voting period, an error is returned. -func (s *E2ETestSuite) waitForGovV1ProposalToPass(ctx context.Context, chain ibc.Chain, proposalID uint64) error { - var govProposal govtypesv1.Proposal +func (*E2ETestSuite) waitForGovV1ProposalToPass(ctx context.Context, chain ibc.Chain, proposalID uint64) error { + var govProposal *govtypesv1.Proposal // poll for the query for the entire voting period to see if the proposal has passed. err := test.WaitForCondition(testvalues.VotingPeriod, 10*time.Second, func() (bool, error) { - proposal, err := s.QueryProposalV1(ctx, chain, proposalID) + proposalResp, err := GRPCQuery[govtypesv1.QueryProposalResponse](ctx, chain, &govtypesv1.QueryProposalRequest{ + ProposalId: proposalID, + }) if err != nil { return false, err } - govProposal = proposal + govProposal = proposalResp.Proposal return govProposal.Status == govtypesv1.StatusPassed, nil }) @@ -218,16 +220,24 @@ func (s *E2ETestSuite) ExecuteAndPassGovV1Beta1Proposal(ctx context.Context, cha // TODO: replace with parsed proposal ID from MsgSubmitProposalResponse // https://github.com/cosmos/ibc-go/issues/2122 - proposal, err := s.QueryProposalV1Beta1(ctx, cosmosChain, proposalID) + proposalResp, err := GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, cosmosChain, &govtypesv1beta1.QueryProposalRequest{ + ProposalId: proposalID, + }) s.Require().NoError(err) + + proposal := proposalResp.Proposal s.Require().Equal(govtypesv1beta1.StatusVotingPeriod, proposal.Status) err = cosmosChain.VoteOnProposalAllValidators(ctx, fmt.Sprintf("%d", proposalID), cosmos.ProposalVoteYes) s.Require().NoError(err) // ensure voting period has not passed before validators finished voting - proposal, err = s.QueryProposalV1Beta1(ctx, cosmosChain, proposalID) + proposalResp, err = GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, cosmosChain, &govtypesv1beta1.QueryProposalRequest{ + ProposalId: proposalID, + }) s.Require().NoError(err) + + proposal = proposalResp.Proposal s.Require().Equal(govtypesv1beta1.StatusVotingPeriod, proposal.Status) err = s.waitForGovV1Beta1ProposalToPass(ctx, cosmosChain, proposalID) @@ -236,13 +246,17 @@ func (s *E2ETestSuite) ExecuteAndPassGovV1Beta1Proposal(ctx context.Context, cha // waitForGovV1Beta1ProposalToPass polls for the entire voting period to see if the proposal has passed. // if the proposal has not passed within the duration of the voting period, an error is returned. -func (s *E2ETestSuite) waitForGovV1Beta1ProposalToPass(ctx context.Context, chain ibc.Chain, proposalID uint64) error { +func (*E2ETestSuite) waitForGovV1Beta1ProposalToPass(ctx context.Context, chain ibc.Chain, proposalID uint64) error { // poll for the query for the entire voting period to see if the proposal has passed. return test.WaitForCondition(testvalues.VotingPeriod, 10*time.Second, func() (bool, error) { - proposal, err := s.QueryProposalV1Beta1(ctx, chain, proposalID) + proposalResp, err := GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, chain, &govtypesv1beta1.QueryProposalRequest{ + ProposalId: proposalID, + }) if err != nil { return false, err } + + proposal := proposalResp.Proposal return proposal.Status == govtypesv1beta1.StatusPassed, nil }) } From 1ff12e7e6c84872a80adc5b74ee8a6ac059875a2 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 12 Mar 2024 18:14:29 +0700 Subject: [PATCH 02/18] test: fixed client_test --- e2e/tests/core/02-client/client_test.go | 23 ++++++--- e2e/testsuite/grpc_query.go | 66 ++++++++++++++++++++++--- 2 files changed, 76 insertions(+), 13 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 784ced70e4f..1f03e0e57ee 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -53,8 +53,7 @@ type ClientTestSuite struct { // Status queries the current status of the client func (s *ClientTestSuite) Status(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { - queryClient := s.GetChainGRCPClients(chain).ClientQueryClient - res, err := queryClient.ClientStatus(ctx, &clienttypes.QueryClientStatusRequest{ + res, err := testsuite.GRPCQuery[clienttypes.QueryClientStatusResponse](ctx, chain, &clienttypes.QueryClientStatusRequest{ ClientId: clientID, }) if err != nil { @@ -66,8 +65,7 @@ func (s *ClientTestSuite) Status(ctx context.Context, chain ibc.Chain, clientID // QueryAllowedClients queries the on-chain AllowedClients parameter for 02-client func (s *ClientTestSuite) QueryAllowedClients(ctx context.Context, chain ibc.Chain) []string { - queryClient := s.GetChainGRCPClients(chain).ClientQueryClient - res, err := queryClient.ClientParams(ctx, &clienttypes.QueryClientParamsRequest{}) + res, err := testsuite.GRPCQuery[clienttypes.QueryClientParamsResponse](ctx, chain, &clienttypes.QueryClientParamsRequest{}) s.Require().NoError(err) return res.Params.AllowedClients @@ -118,16 +116,23 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { t.Run("check that IBC software upgrade has been scheduled successfully on chainA", func(t *testing.T) { // checks there is an upgraded client state stored - cs, err := s.QueryUpgradedClientState(ctx, chainA, ibctesting.FirstClientID) + upgradedCsResp, err := testsuite.GRPCQuery[clienttypes.QueryUpgradedClientStateResponse](ctx, chainA, &clienttypes.QueryUpgradedClientStateRequest{}) + + clientStateAny := upgradedCsResp.UpgradedClientState + s.Require().NoError(err) + + cs, err := clienttypes.UnpackClientState(clientStateAny) s.Require().NoError(err) upgradedClientState, ok := cs.(*ibctm.ClientState) s.Require().True(ok) s.Require().Equal(upgradedClientState.ChainId, newChainID) - plan, err := s.QueryCurrentUpgradePlan(ctx, chainA) + planResponse, err := testsuite.GRPCQuery[upgradetypes.QueryCurrentPlanResponse](ctx, chainA, &upgradetypes.QueryCurrentPlanRequest{}) s.Require().NoError(err) + plan := planResponse.Plan + s.Require().Equal("upgrade-client", plan.Name) s.Require().Equal(planHeight, plan.Height) }) @@ -385,8 +390,12 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { var validators []*cmtservice.Validator t.Run("fetch block header at latest client state height", func(t *testing.T) { - header, err = s.GetBlockHeaderByHeight(ctx, chainB, latestHeight.GetRevisionHeight()) + headerResp, err := testsuite.GRPCQuery[cmtservice.GetBlockByHeightResponse](ctx, chainB, &cmtservice.GetBlockByHeightRequest{ + Height: int64(latestHeight.GetRevisionHeight()), + }) s.Require().NoError(err) + + header = &headerResp.SdkBlock.Header }) t.Run("get validators at latest height", func(t *testing.T) { diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/grpc_query.go index 1e39188d2ad..692f8b7688c 100644 --- a/e2e/testsuite/grpc_query.go +++ b/e2e/testsuite/grpc_query.go @@ -3,15 +3,21 @@ package testsuite import ( "context" "fmt" + "sort" "strings" "github.com/strangelove-ventures/interchaintest/v8/ibc" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + "github.com/cosmos/gogoproto/proto" ) @@ -43,20 +49,20 @@ func GRPCQuery[T any](ctx context.Context, chain ibc.Chain, req proto.Message, o } func getProtoPath(req proto.Message) (string, error) { - typeUrl := "/" + proto.MessageName(req) + typeURL := "/" + proto.MessageName(req) - queryIndex := strings.Index(typeUrl, "Query") + queryIndex := strings.Index(typeURL, "Query") if queryIndex == -1 { - return "", fmt.Errorf("invalid typeUrl: %s", typeUrl) + return "", fmt.Errorf("invalid typeURL: %s", typeURL) } // Add to the index to account for the length of "Query" queryIndex += len("Query") // Add a slash before the query - urlWithSlash := typeUrl[:queryIndex] + "/" + typeUrl[queryIndex:] + urlWithSlash := typeURL[:queryIndex] + "/" + typeURL[queryIndex:] if !strings.HasSuffix(urlWithSlash, "Request") { - return "", fmt.Errorf("invalid typeUrl: %s", typeUrl) + return "", fmt.Errorf("invalid typeURL: %s", typeURL) } return strings.TrimSuffix(urlWithSlash, "Request"), nil @@ -64,7 +70,7 @@ func getProtoPath(req proto.Message) (string, error) { // QueryModuleAccountAddress returns the address of the given module on the given chain. // Added because interchaintest's method doesn't work. -func (s *E2ETestSuite) QueryModuleAccountAddress(ctx context.Context, moduleName string, chain ibc.Chain) (sdk.AccAddress, error) { +func (*E2ETestSuite) QueryModuleAccountAddress(ctx context.Context, moduleName string, chain ibc.Chain) (sdk.AccAddress, error) { modAccResp, err := GRPCQuery[authtypes.QueryModuleAccountByNameResponse]( ctx, chain, &authtypes.QueryModuleAccountByNameRequest{Name: moduleName}, ) @@ -89,3 +95,51 @@ func (s *E2ETestSuite) QueryModuleAccountAddress(ctx context.Context, moduleName return govAccount.GetAddress(), nil } + +// QueryClientState queries the client state on the given chain for the provided clientID. +func (*E2ETestSuite) QueryClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexported.ClientState, error) { + clientStateResp, err := GRPCQuery[clienttypes.QueryClientStateResponse](ctx, chain, &clienttypes.QueryClientStateRequest{ + ClientId: ibctesting.FirstClientID, + }) + if err != nil { + return nil, err + } + + clientStateAny := clientStateResp.ClientState + + clientState, err := clienttypes.UnpackClientState(clientStateAny) + if err != nil { + return nil, err + } + + return clientState, nil +} + +// QueryClientStatus queries the status of the client by clientID +func (*E2ETestSuite) QueryClientStatus(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { + clientStatusResp, err := GRPCQuery[clienttypes.QueryClientStatusResponse](ctx, chain, &clienttypes.QueryClientStatusRequest{ + ClientId: clientID, + }) + if err != nil { + return "", err + } + + return clientStatusResp.Status, nil +} + +// GetValidatorSetByHeight returns the validators of the given chain at the specified height. The returned validators +// are sorted by address. +func (*E2ETestSuite) GetValidatorSetByHeight(ctx context.Context, chain ibc.Chain, height uint64) ([]*cmtservice.Validator, error) { + res, err := GRPCQuery[cmtservice.GetValidatorSetByHeightResponse](ctx, chain, &cmtservice.GetValidatorSetByHeightRequest{ + Height: int64(height), + }) + if err != nil { + return nil, err + } + + sort.SliceStable(res.Validators, func(i, j int) bool { + return res.Validators[i].Address < res.Validators[j].Address + }) + + return res.Validators, nil +} From 807271d130b203194d35123343cc6db61de70660 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 12 Mar 2024 18:50:13 +0700 Subject: [PATCH 03/18] test: fixed ica tests --- .../core/03-connection/connection_test.go | 7 +- e2e/tests/interchain_accounts/base_test.go | 19 ++++- e2e/tests/interchain_accounts/groups_test.go | 5 +- e2e/tests/interchain_accounts/params_test.go | 6 +- .../interchain_accounts/upgrades_test.go | 4 +- e2e/testsuite/grpc_query.go | 75 +++++++++++++++++++ 6 files changed, 99 insertions(+), 17 deletions(-) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 6a634986307..f6fdd4c6f12 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -35,18 +35,15 @@ type ConnectionTestSuite struct { // QueryMaxExpectedTimePerBlockParam queries the on-chain max expected time per block param for 03-connection func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Context, chain ibc.Chain) uint64 { if testvalues.SelfParamsFeatureReleases.IsSupported(chain.Config().Images[0].Version) { - queryClient := s.GetChainGRCPClients(chain).ConnectionQueryClient - res, err := queryClient.ConnectionParams(ctx, &connectiontypes.QueryConnectionParamsRequest{}) + res, err := testsuite.GRPCQuery[connectiontypes.QueryConnectionParamsResponse](ctx, chain, &connectiontypes.QueryConnectionParamsRequest{}) s.Require().NoError(err) return res.Params.MaxExpectedTimePerBlock } - queryClient := s.GetChainGRCPClients(chain).ParamsQueryClient - res, err := queryClient.Params(ctx, ¶msproposaltypes.QueryParamsRequest{ + res, err := testsuite.GRPCQuery[paramsproposaltypes.QueryParamsResponse](ctx, chain, ¶msproposaltypes.QueryParamsRequest{ Subspace: ibcexported.ModuleName, Key: string(connectiontypes.KeyMaxExpectedTimePerBlock), }) - s.Require().NoError(err) // removing additional strings that are used for amino delay := strings.ReplaceAll(res.Param.Value, "\"", "") diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 1477f4b511a..c3392f1577a 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -41,6 +41,19 @@ type InterchainAccountsTestSuite struct { testsuite.E2ETestSuite } +// QueryInterchainAccount queries the interchain account for the given owner and connectionID. +func QueryInterchainAccount(ctx context.Context, chain ibc.Chain, address, connectionID string) (string, error) { + res, err := testsuite.GRPCQuery[controllertypes.QueryInterchainAccountResponse](ctx, chain, &controllertypes.QueryInterchainAccountRequest{ + Owner: address, + ConnectionId: connectionID, + }) + if err != nil { + return "", err + } + + return res.Address, nil +} + // RegisterInterchainAccount will attempt to register an interchain account on the counterparty chain. func (s *InterchainAccountsTestSuite) RegisterInterchainAccount(ctx context.Context, chain ibc.Chain, user ibc.Wallet, msgRegisterAccount *controllertypes.MsgRegisterInterchainAccount) { txResp := s.BroadcastMessages(ctx, chain, user, msgRegisterAccount) @@ -86,7 +99,7 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulTransfer(order chan t.Run("verify interchain account", func(t *testing.T) { var err error - hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + hostAccount, err = QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) @@ -185,7 +198,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("verify interchain account", func(t *testing.T) { var err error - hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + hostAccount, err = QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) @@ -283,7 +296,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop t.Run("verify interchain account", func(t *testing.T) { var err error - hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + hostAccount, err = QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index 43faca17a3f..53cb5a207c7 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -67,8 +67,7 @@ type InterchainAccountsGroupsTestSuite struct { } func (s *InterchainAccountsGroupsTestSuite) QueryGroupPolicyAddress(ctx context.Context, chain ibc.Chain) string { - queryClient := s.GetChainGRCPClients(chain).GroupsQueryClient - res, err := queryClient.GroupPoliciesByGroup(ctx, &grouptypes.QueryGroupPoliciesByGroupRequest{ + res, err := testsuite.GRPCQuery[grouptypes.QueryGroupPoliciesByGroupResponse](ctx, chain, &grouptypes.QueryGroupPoliciesByGroupRequest{ GroupId: InitialGroupID, // always use the initial group id }) s.Require().NoError(err) @@ -141,7 +140,7 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat }) t.Run("verify interchain account registration success", func(t *testing.T) { - interchainAccAddr, err = s.QueryInterchainAccount(ctx, chainA, groupPolicyAddr, ibctesting.FirstConnectionID) + interchainAccAddr, err = QueryInterchainAccount(ctx, chainA, groupPolicyAddr, ibctesting.FirstConnectionID) s.Require().NotEmpty(interchainAccAddr) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 4cdc64fa371..d0a2f7ad947 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -31,8 +31,7 @@ type InterchainAccountsParamsTestSuite struct { // QueryControllerParams queries the params for the controller func (s *InterchainAccountsParamsTestSuite) QueryControllerParams(ctx context.Context, chain ibc.Chain) controllertypes.Params { - queryClient := s.GetChainGRCPClients(chain).ICAControllerQueryClient - res, err := queryClient.Params(ctx, &controllertypes.QueryParamsRequest{}) + res, err := testsuite.GRPCQuery[controllertypes.QueryParamsResponse](ctx, chain, &controllertypes.QueryParamsRequest{}) s.Require().NoError(err) return *res.Params @@ -40,8 +39,7 @@ func (s *InterchainAccountsParamsTestSuite) QueryControllerParams(ctx context.Co // QueryHostParams queries the host chain for the params func (s *InterchainAccountsParamsTestSuite) QueryHostParams(ctx context.Context, chain ibc.Chain) hosttypes.Params { - queryClient := s.GetChainGRCPClients(chain).ICAHostQueryClient - res, err := queryClient.Params(ctx, &hosttypes.QueryParamsRequest{}) + res, err := testsuite.GRPCQuery[hosttypes.QueryParamsResponse](ctx, chain, &hosttypes.QueryParamsRequest{}) s.Require().NoError(err) return *res.Params diff --git a/e2e/tests/interchain_accounts/upgrades_test.go b/e2e/tests/interchain_accounts/upgrades_test.go index ddfe321f2ef..db4410c1477 100644 --- a/e2e/tests/interchain_accounts/upgrades_test.go +++ b/e2e/tests/interchain_accounts/upgrades_test.go @@ -78,7 +78,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra t.Run("verify interchain account", func(t *testing.T) { var err error - hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + hostAccount, err = QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) @@ -264,7 +264,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann t.Run("verify interchain account", func(t *testing.T) { var err error - interchainAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + interchainAccount, err = QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccount)) diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/grpc_query.go index 692f8b7688c..1b5c35e8a06 100644 --- a/e2e/testsuite/grpc_query.go +++ b/e2e/testsuite/grpc_query.go @@ -6,14 +6,18 @@ import ( "sort" "strings" + "cosmossdk.io/math" "github.com/strangelove-ventures/interchaintest/v8/ibc" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v8/testing" @@ -143,3 +147,74 @@ func (*E2ETestSuite) GetValidatorSetByHeight(ctx context.Context, chain ibc.Chai return res.Validators, nil } + +// QueryBalance returns the balance of a specific denomination for a given account by address. +func (*E2ETestSuite) QueryBalance(ctx context.Context, chain ibc.Chain, address string, denom string) (math.Int, error) { + res, err := GRPCQuery[banktypes.QueryBalanceResponse](ctx, chain, &banktypes.QueryBalanceRequest{ + Address: address, + Denom: denom, + }) + if err != nil { + return math.Int{}, err + } + + return res.Balance.Amount, nil +} + +// QueryChannel queries the channel on a given chain for the provided portID and channelID +func (s *E2ETestSuite) QueryChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.Channel, error) { + res, err := GRPCQuery[channeltypes.QueryChannelResponse](ctx, chain, &channeltypes.QueryChannelRequest{ + PortId: portID, + ChannelId: channelID, + }) + + if err != nil { + return channeltypes.Channel{}, err + } + + return *res.Channel, nil +} + +// QueryCounterPartyPayee queries the counterparty payee of the given chain and relayer address on the specified channel. +func (s *E2ETestSuite) QueryCounterPartyPayee(ctx context.Context, chain ibc.Chain, relayerAddress, channelID string) (string, error) { + res, err := GRPCQuery[feetypes.QueryCounterpartyPayeeResponse](ctx, chain, &feetypes.QueryCounterpartyPayeeRequest{ + ChannelId: channelID, + Relayer: relayerAddress, + }) + if err != nil { + return "", err + } + + return res.CounterpartyPayee, nil +} + +// QueryIncentivizedPacketsForChannel queries the incentivized packets on the specified channel. +func (s *E2ETestSuite) QueryIncentivizedPacketsForChannel( + ctx context.Context, + chain ibc.Chain, + portID, + channelID string, +) ([]*feetypes.IdentifiedPacketFees, error) { + res, err := GRPCQuery[feetypes.QueryIncentivizedPacketsForChannelResponse](ctx, chain, &feetypes.QueryIncentivizedPacketsForChannelRequest{ + PortId: portID, + ChannelId: channelID, + }) + + if err != nil { + return nil, err + } + return res.IncentivizedPackets, err +} + +// QueryFeeEnabledChannel queries the fee-enabled status of a channel. +func (s *E2ETestSuite) QueryFeeEnabledChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (bool, error) { + res, err := GRPCQuery[feetypes.QueryFeeEnabledChannelResponse](ctx, chain, &feetypes.QueryFeeEnabledChannelRequest{ + PortId: portID, + ChannelId: channelID, + }) + + if err != nil { + return false, err + } + return res.FeeEnabled, nil +} From a23f860f1889c6e4415a7e78d0feab3d93057e13 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 12 Mar 2024 20:05:18 +0700 Subject: [PATCH 04/18] e2e: query refactor and fix more tests --- e2e/tests/core/02-client/client_test.go | 33 ++--- .../core/03-connection/connection_test.go | 9 +- e2e/tests/interchain_accounts/base_test.go | 23 ++-- e2e/tests/interchain_accounts/gov_test.go | 9 +- e2e/tests/interchain_accounts/groups_test.go | 7 +- .../interchain_accounts/incentivized_test.go | 29 ++--- .../interchain_accounts/localhost_test.go | 35 +++--- e2e/tests/interchain_accounts/params_test.go | 9 +- .../interchain_accounts/upgrades_test.go | 29 ++--- e2e/tests/transfer/authz_test.go | 18 ++- e2e/tests/transfer/base_test.go | 23 ++-- e2e/tests/transfer/incentivized_test.go | 47 +++---- e2e/tests/transfer/localhost_test.go | 11 +- e2e/tests/transfer/upgrades_test.go | 49 ++++---- e2e/testsuite/query/grpc_query.go | 60 +++++++++ .../{grpc_query.go => query/queries.go} | 117 ++++++++---------- e2e/testsuite/testsuite.go | 13 +- e2e/testsuite/tx.go | 9 +- 18 files changed, 302 insertions(+), 228 deletions(-) create mode 100644 e2e/testsuite/query/grpc_query.go rename e2e/testsuite/{grpc_query.go => query/queries.go} (64%) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 1f03e0e57ee..d3b6c52c997 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -31,6 +31,7 @@ import ( "github.com/cosmos/ibc-go/e2e/dockerutil" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" @@ -53,7 +54,7 @@ type ClientTestSuite struct { // Status queries the current status of the client func (s *ClientTestSuite) Status(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { - res, err := testsuite.GRPCQuery[clienttypes.QueryClientStatusResponse](ctx, chain, &clienttypes.QueryClientStatusRequest{ + res, err := query.GRPCQuery[clienttypes.QueryClientStatusResponse](ctx, chain, &clienttypes.QueryClientStatusRequest{ ClientId: clientID, }) if err != nil { @@ -65,7 +66,7 @@ func (s *ClientTestSuite) Status(ctx context.Context, chain ibc.Chain, clientID // QueryAllowedClients queries the on-chain AllowedClients parameter for 02-client func (s *ClientTestSuite) QueryAllowedClients(ctx context.Context, chain ibc.Chain) []string { - res, err := testsuite.GRPCQuery[clienttypes.QueryClientParamsResponse](ctx, chain, &clienttypes.QueryClientParamsRequest{}) + res, err := query.GRPCQuery[clienttypes.QueryClientParamsResponse](ctx, chain, &clienttypes.QueryClientParamsRequest{}) s.Require().NoError(err) return res.Params.AllowedClients @@ -85,11 +86,11 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { var newChainID string t.Run("execute proposal for MsgIBCSoftwareUpgrade", func(t *testing.T) { - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) - clientState, err := s.QueryClientState(ctx, chainB, ibctesting.FirstClientID) + clientState, err := query.QueryClientState(ctx, chainB, ibctesting.FirstClientID) s.Require().NoError(err) originalChainID := clientState.(*ibctm.ClientState).ChainId @@ -116,7 +117,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { t.Run("check that IBC software upgrade has been scheduled successfully on chainA", func(t *testing.T) { // checks there is an upgraded client state stored - upgradedCsResp, err := testsuite.GRPCQuery[clienttypes.QueryUpgradedClientStateResponse](ctx, chainA, &clienttypes.QueryUpgradedClientStateRequest{}) + upgradedCsResp, err := query.GRPCQuery[clienttypes.QueryUpgradedClientStateResponse](ctx, chainA, &clienttypes.QueryUpgradedClientStateRequest{}) clientStateAny := upgradedCsResp.UpgradedClientState s.Require().NoError(err) @@ -128,7 +129,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().True(ok) s.Require().Equal(upgradedClientState.ChainId, newChainID) - planResponse, err := testsuite.GRPCQuery[upgradetypes.QueryCurrentPlanResponse](ctx, chainA, &upgradetypes.QueryCurrentPlanRequest{}) + planResponse, err := query.GRPCQuery[upgradetypes.QueryCurrentPlanResponse](ctx, chainA, &upgradetypes.QueryCurrentPlanRequest{}) s.Require().NoError(err) plan := planResponse.Plan @@ -138,11 +139,11 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { }) t.Run("ensure legacy proposal does not succeed", func(t *testing.T) { - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) - clientState, err := s.QueryClientState(ctx, chainB, ibctesting.FirstClientID) + clientState, err := query.QueryClientState(ctx, chainB, ibctesting.FirstClientID) s.Require().NoError(err) originalChainID := clientState.(*ibctm.ClientState).ChainId @@ -312,7 +313,7 @@ func (s *ClientTestSuite) TestRecoverClient_Succeeds() { }) t.Run("execute proposal for MsgRecoverClient", func(t *testing.T) { - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) recoverClientMsg := clienttypes.NewMsgRecoverClient(authority.String(), subjectClientID, substituteClientID) s.Require().NotNil(recoverClientMsg) @@ -358,7 +359,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { err := relayer.UpdateClients(ctx, s.GetRelayerExecReporter(), s.GetPathName(0)) s.Require().NoError(err) - clientState, err = s.QueryClientState(ctx, chainA, ibctesting.FirstClientID) + clientState, err = query.QueryClientState(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) }) @@ -374,7 +375,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { err := relayer.UpdateClients(ctx, s.GetRelayerExecReporter(), s.GetPathName(0)) s.Require().NoError(err) - clientState, err = s.QueryClientState(ctx, chainA, ibctesting.FirstClientID) + clientState, err = query.QueryClientState(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) }) @@ -390,7 +391,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { var validators []*cmtservice.Validator t.Run("fetch block header at latest client state height", func(t *testing.T) { - headerResp, err := testsuite.GRPCQuery[cmtservice.GetBlockByHeightResponse](ctx, chainB, &cmtservice.GetBlockByHeightRequest{ + headerResp, err := query.GRPCQuery[cmtservice.GetBlockByHeightResponse](ctx, chainB, &cmtservice.GetBlockByHeightRequest{ Height: int64(latestHeight.GetRevisionHeight()), }) s.Require().NoError(err) @@ -399,7 +400,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { }) t.Run("get validators at latest height", func(t *testing.T) { - validators, err = s.GetValidatorSetByHeight(ctx, chainB, latestHeight.GetRevisionHeight()) + validators, err = query.GetValidatorSetByHeight(ctx, chainB, latestHeight.GetRevisionHeight()) s.Require().NoError(err) }) @@ -434,7 +435,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { }) t.Run("ensure client status is frozen", func(t *testing.T) { - status, err := s.QueryClientStatus(ctx, chainA, ibctesting.FirstClientID) + status, err := query.QueryClientStatus(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Frozen.String(), status) }) @@ -469,7 +470,7 @@ func (s *ClientTestSuite) TestAllowedClientsParam() { allowedClient := ibcexported.Solomachine t.Run("change the allowed client to only allow solomachine clients", func(t *testing.T) { if testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) { - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) @@ -493,7 +494,7 @@ func (s *ClientTestSuite) TestAllowedClientsParam() { }) t.Run("ensure querying non-allowed client's status returns Unauthorized Status", func(t *testing.T) { - status, err := s.QueryClientStatus(ctx, chainA, ibctesting.FirstClientID) + status, err := query.QueryClientStatus(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Unauthorized.String(), status) }) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index f6fdd4c6f12..803a0c7c098 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -18,6 +18,7 @@ import ( paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" @@ -35,12 +36,12 @@ type ConnectionTestSuite struct { // QueryMaxExpectedTimePerBlockParam queries the on-chain max expected time per block param for 03-connection func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Context, chain ibc.Chain) uint64 { if testvalues.SelfParamsFeatureReleases.IsSupported(chain.Config().Images[0].Version) { - res, err := testsuite.GRPCQuery[connectiontypes.QueryConnectionParamsResponse](ctx, chain, &connectiontypes.QueryConnectionParamsRequest{}) + res, err := query.GRPCQuery[connectiontypes.QueryConnectionParamsResponse](ctx, chain, &connectiontypes.QueryConnectionParamsRequest{}) s.Require().NoError(err) return res.Params.MaxExpectedTimePerBlock } - res, err := testsuite.GRPCQuery[paramsproposaltypes.QueryParamsResponse](ctx, chain, ¶msproposaltypes.QueryParamsRequest{ + res, err := query.GRPCQuery[paramsproposaltypes.QueryParamsResponse](ctx, chain, ¶msproposaltypes.QueryParamsRequest{ Subspace: ibcexported.ModuleName, Key: string(connectiontypes.KeyMaxExpectedTimePerBlock), }) @@ -82,7 +83,7 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() { t.Run("change the delay to 60 seconds", func(t *testing.T) { delay := uint64(1 * time.Minute) if testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) { - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) @@ -125,7 +126,7 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index c3392f1577a..a91323c5369 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -19,6 +19,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" @@ -43,7 +44,7 @@ type InterchainAccountsTestSuite struct { // QueryInterchainAccount queries the interchain account for the given owner and connectionID. func QueryInterchainAccount(ctx context.Context, chain ibc.Chain, address, connectionID string) (string, error) { - res, err := testsuite.GRPCQuery[controllertypes.QueryInterchainAccountResponse](ctx, chain, &controllertypes.QueryInterchainAccountRequest{ + res, err := query.GRPCQuery[controllertypes.QueryInterchainAccountResponse](ctx, chain, &controllertypes.QueryInterchainAccountRequest{ Owner: address, ConnectionId: connectionID, }) @@ -155,10 +156,10 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulTransfer(order chan }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = s.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) + _, err = query.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount @@ -209,7 +210,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("fail to execute bank transfer over ICA", func(t *testing.T) { t.Run("verify empty host wallet", func(t *testing.T) { - hostAccountBalance, err := s.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) + hostAccountBalance, err := query.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) s.Require().NoError(err) s.Require().Zero(hostAccountBalance.Int64()) @@ -248,7 +249,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF }) t.Run("verify balance is the same", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount @@ -300,7 +301,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) - _, err = s.QueryChannel(ctx, chainA, portID, initialChannelID) + _, err = query.QueryChannel(ctx, chainA, portID, initialChannelID) s.Require().NoError(err) }) @@ -360,17 +361,17 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop }) t.Run("verify channel is closed due to timeout on ordered channel", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainA, portID, initialChannelID) + channel, err := query.QueryChannel(ctx, chainA, portID, initialChannelID) s.Require().NoError(err) s.Require().Equal(channeltypes.CLOSED, channel.State, "the channel was not in an expected state") }) t.Run("verify tokens not transferred", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = s.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) + _, err = query.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount @@ -389,7 +390,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop }) t.Run("verify new channel is now open and interchain account has been reregistered with the same portID", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainA, portID, channelIDAfterReopening) + channel, err := query.QueryChannel(ctx, chainA, portID, channelIDAfterReopening) s.Require().NoError(err) s.Require().Equal(channeltypes.OPEN, channel.State, "the channel was not in an expected state") @@ -430,7 +431,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index 212b5d173f4..1774f1c15f7 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -20,6 +20,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" @@ -48,7 +49,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) chainBAddress := chainBAccount.FormattedAddress() - govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -67,7 +68,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() var interchainAccAddr string t.Run("verify interchain account registration success", func(t *testing.T) { var err error - interchainAccAddr, err = s.QueryInterchainAccount(ctx, chainA, govModuleAddress.String(), ibctesting.FirstConnectionID) + interchainAccAddr, err = QueryInterchainAccount(ctx, chainA, govModuleAddress.String(), ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddr)) @@ -109,10 +110,10 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = s.QueryBalance(ctx, chainB, interchainAccAddr, chainB.Config().Denom) + _, err = query.QueryBalance(ctx, chainB, interchainAccAddr, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index 53cb5a207c7..45e9c941b9e 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -20,6 +20,7 @@ import ( grouptypes "github.com/cosmos/cosmos-sdk/x/group" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" @@ -67,7 +68,7 @@ type InterchainAccountsGroupsTestSuite struct { } func (s *InterchainAccountsGroupsTestSuite) QueryGroupPolicyAddress(ctx context.Context, chain ibc.Chain) string { - res, err := testsuite.GRPCQuery[grouptypes.QueryGroupPoliciesByGroupResponse](ctx, chain, &grouptypes.QueryGroupPoliciesByGroupRequest{ + res, err := query.GRPCQuery[grouptypes.QueryGroupPoliciesByGroupResponse](ctx, chain, &grouptypes.QueryGroupPoliciesByGroupRequest{ GroupId: InitialGroupID, // always use the initial group id }) s.Require().NoError(err) @@ -198,14 +199,14 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat t.Run("verify tokens transferred", func(t *testing.T) { s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks") - balance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainB.Config().Denom) + balance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount s.Require().Equal(expected, balance.Int64()) - balance, err = s.QueryBalance(ctx, chainB, interchainAccAddr, chainB.Config().Denom) + balance, err = query.QueryBalance(ctx, chainB, interchainAccAddr, chainB.Config().Denom) s.Require().NoError(err) expected = testvalues.StartingTokenAmount - testvalues.IBCTransferAmount diff --git a/e2e/tests/interchain_accounts/incentivized_test.go b/e2e/tests/interchain_accounts/incentivized_test.go index 309a8e92b8f..b70779868fa 100644 --- a/e2e/tests/interchain_accounts/incentivized_test.go +++ b/e2e/tests/interchain_accounts/incentivized_test.go @@ -19,6 +19,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" @@ -85,7 +86,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe var channelOutput ibc.ChannelOutput t.Run("verify interchain account", func(t *testing.T) { var err error - interchainAcc, err = s.QueryInterchainAccount(ctx, chainA, controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID) + interchainAcc, err = QueryInterchainAccount(ctx, chainA, controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAcc)) @@ -116,13 +117,13 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := s.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelOutput.Counterparty.ChannelID) + address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelOutput.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) t.Run("no incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -164,7 +165,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -179,16 +180,16 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) t.Run("verify interchain account sent tokens", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = s.QueryBalance(ctx, chainB, interchainAcc, chainB.Config().Denom) + _, err = query.QueryBalance(ctx, chainB, interchainAcc, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount @@ -263,7 +264,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I var channelOutput ibc.ChannelOutput t.Run("verify interchain account", func(t *testing.T) { var err error - interchainAcc, err = s.QueryInterchainAccount(ctx, chainA, controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID) + interchainAcc, err = QueryInterchainAccount(ctx, chainA, controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAcc)) @@ -284,13 +285,13 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := s.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelOutput.Counterparty.ChannelID) + address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelOutput.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) t.Run("no incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -333,7 +334,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -348,16 +349,16 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) t.Run("verify interchain account did not send tokens", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = s.QueryBalance(ctx, chainB, interchainAcc, chainB.Config().Denom) + _, err = query.QueryBalance(ctx, chainB, interchainAcc, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index fdd875686e4..325463b20a3 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -19,6 +19,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" @@ -108,11 +109,11 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( }) t.Run("query localhost interchain accounts channel ends", func(t *testing.T) { - channelEndA, err := s.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + channelEndA, err := query.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndA) - channelEndB, err := s.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + channelEndB, err := query.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndB) @@ -120,7 +121,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( }) t.Run("verify interchain account registration and deposit funds", func(t *testing.T) { - interchainAccAddress, err := s.QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) @@ -134,7 +135,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( }) t.Run("send packet localhost interchain accounts", func(t *testing.T) { - interchainAccAddress, err := s.QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) @@ -183,7 +184,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom) + balance, err := query.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount @@ -263,11 +264,11 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("query localhost interchain accounts channel ends", func(t *testing.T) { - channelEndA, err := s.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + channelEndA, err := query.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndA) - channelEndB, err := s.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + channelEndB, err := query.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndB) @@ -275,7 +276,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("verify interchain account registration and deposit funds", func(t *testing.T) { - interchainAccAddress, err := s.QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) @@ -289,7 +290,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("send localhost interchain accounts packet with timeout", func(t *testing.T) { - interchainAccAddress, err := s.QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) @@ -335,12 +336,12 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("verify localhost interchain accounts channel is closed", func(t *testing.T) { - channelEndA, err := s.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + channelEndA, err := query.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) s.Require().NoError(err) s.Require().Equal(channeltypes.CLOSED, channelEndA.State, "the channel was not in an expected state") - channelEndB, err := s.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + channelEndB, err := query.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().Equal(channeltypes.CLOSED, channelEndB.State, "the channel was not in an expected state") @@ -393,11 +394,11 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("query localhost interchain accounts channel ends", func(t *testing.T) { - channelEndA, err := s.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + channelEndA, err := query.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndA) - channelEndB, err := s.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + channelEndB, err := query.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndB) @@ -405,11 +406,11 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("verify interchain account and existing balance", func(t *testing.T) { - interchainAccAddress, err := s.QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) - balance, err := s.QueryBalance(ctx, chainA, interchainAccAddress, chainADenom) + balance, err := query.QueryBalance(ctx, chainA, interchainAccAddress, chainADenom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount @@ -417,7 +418,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("send packet localhost interchain accounts", func(t *testing.T) { - interchainAccAddress, err := s.QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) @@ -468,7 +469,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan t.Run("verify tokens transferred", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId, 1) - balance, err := s.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom) + balance, err := query.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index d0a2f7ad947..08bfc3ec4f2 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -13,6 +13,7 @@ import ( paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" hosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" @@ -31,7 +32,7 @@ type InterchainAccountsParamsTestSuite struct { // QueryControllerParams queries the params for the controller func (s *InterchainAccountsParamsTestSuite) QueryControllerParams(ctx context.Context, chain ibc.Chain) controllertypes.Params { - res, err := testsuite.GRPCQuery[controllertypes.QueryParamsResponse](ctx, chain, &controllertypes.QueryParamsRequest{}) + res, err := query.GRPCQuery[controllertypes.QueryParamsResponse](ctx, chain, &controllertypes.QueryParamsRequest{}) s.Require().NoError(err) return *res.Params @@ -39,7 +40,7 @@ func (s *InterchainAccountsParamsTestSuite) QueryControllerParams(ctx context.Co // QueryHostParams queries the host chain for the params func (s *InterchainAccountsParamsTestSuite) QueryHostParams(ctx context.Context, chain ibc.Chain) hosttypes.Params { - res, err := testsuite.GRPCQuery[hosttypes.QueryParamsResponse](ctx, chain, &hosttypes.QueryParamsRequest{}) + res, err := query.GRPCQuery[hosttypes.QueryParamsResponse](ctx, chain, &hosttypes.QueryParamsRequest{}) s.Require().NoError(err) return *res.Params @@ -67,7 +68,7 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t.Run("disable the controller", func(t *testing.T) { if testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) { - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) @@ -124,7 +125,7 @@ func (s *InterchainAccountsParamsTestSuite) TestHostEnabledParam() { t.Run("disable the host", func(t *testing.T) { if testvalues.SelfParamsFeatureReleases.IsSupported(chainBVersion) { - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainB) + authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainB) s.Require().NoError(err) s.Require().NotNil(authority) diff --git a/e2e/tests/interchain_accounts/upgrades_test.go b/e2e/tests/interchain_accounts/upgrades_test.go index db4410c1477..dc0e7cc61cb 100644 --- a/e2e/tests/interchain_accounts/upgrades_test.go +++ b/e2e/tests/interchain_accounts/upgrades_test.go @@ -20,6 +20,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" @@ -82,7 +83,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) - _, err = s.QueryChannel(ctx, chainA, portID, initialChannelID) + _, err = query.QueryChannel(ctx, chainA, portID, initialChannelID) s.Require().NoError(err) }) @@ -129,21 +130,21 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount s.Require().Equal(expected, balance.Int64()) }) - channel, err := s.QueryChannel(ctx, chainA, portID, initialChannelID) + channel, err := query.QueryChannel(ctx, chainA, portID, initialChannelID) s.Require().NoError(err) // upgrade the channel ordering to UNORDERED upgradeFields := channeltypes.NewUpgradeFields(channeltypes.UNORDERED, channel.ConnectionHops, channel.Version) t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) { - govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -154,7 +155,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra t.Run("verify channel A upgraded and is now unordered", func(t *testing.T) { var channel channeltypes.Channel waitErr := test.WaitForCondition(time.Minute*2, time.Second*5, func() (bool, error) { - channel, err = s.QueryChannel(ctx, chainA, portID, initialChannelID) + channel, err = query.QueryChannel(ctx, chainA, portID, initialChannelID) if err != nil { return false, err } @@ -166,7 +167,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra t.Run("verify channel B upgraded and is now unordered", func(t *testing.T) { var channel channeltypes.Channel waitErr := test.WaitForCondition(time.Minute*2, time.Second*5, func() (bool, error) { - channel, err = s.QueryChannel(ctx, chainB, icatypes.HostPortID, initialChannelID) + channel, err = query.QueryChannel(ctx, chainB, icatypes.HostPortID, initialChannelID) if err != nil { return false, err } @@ -208,7 +209,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := 2*testvalues.IBCTransferAmount + testvalues.StartingTokenAmount @@ -268,7 +269,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann s.Require().NoError(err) s.Require().NotZero(len(interchainAccount)) - channelA, err = s.QueryChannel(ctx, chainA, controllerPortID, channelID) + channelA, err = query.QueryChannel(ctx, chainA, controllerPortID, channelID) s.Require().NoError(err) }) @@ -279,7 +280,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks") t.Run("verify channel A upgraded and is fee enabled", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainA, controllerPortID, channelID) + channel, err := query.QueryChannel(ctx, chainA, controllerPortID, channelID) s.Require().NoError(err) // check the channel version include the fee version @@ -288,13 +289,13 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := s.QueryFeeEnabledChannel(ctx, chainA, controllerPortID, channelID) + feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainA, controllerPortID, channelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("verify channel B upgraded and is fee enabled", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainB, hostPortID, channelID) + channel, err := query.QueryChannel(ctx, chainB, hostPortID, channelID) s.Require().NoError(err) // check the channel version include the fee version @@ -303,7 +304,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := s.QueryFeeEnabledChannel(ctx, chainB, hostPortID, channelID) + feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainB, hostPortID, channelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) @@ -365,14 +366,14 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann }) t.Run("verify channel A is closed due to timeout on ordered channel", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainA, controllerPortID, channelID) + channel, err := query.QueryChannel(ctx, chainA, controllerPortID, channelID) s.Require().NoError(err) s.Require().Equal(channeltypes.CLOSED, channel.State, "the channel was not in an expected state") }) t.Run("verify channel B is closed due to timeout on ordered channel", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainB, hostPortID, channelID) + channel, err := query.QueryChannel(ctx, chainB, hostPortID, channelID) s.Require().NoError(err) s.Require().Equal(channeltypes.CLOSED, channel.State, "the channel was not in an expected state") diff --git a/e2e/tests/transfer/authz_test.go b/e2e/tests/transfer/authz_test.go index dd390ad3da5..8e06d45901d 100644 --- a/e2e/tests/transfer/authz_test.go +++ b/e2e/tests/transfer/authz_test.go @@ -6,6 +6,7 @@ import ( "context" "testing" + "github.com/strangelove-ventures/interchaintest/v8/ibc" test "github.com/strangelove-ventures/interchaintest/v8/testutil" testifysuite "github.com/stretchr/testify/suite" @@ -17,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" @@ -30,6 +32,18 @@ type AuthzTransferTestSuite struct { testsuite.E2ETestSuite } +// QueryGranterGrants returns all GrantAuthorizations for the given granterAddress. +func (*AuthzTransferTestSuite) QueryGranterGrants(ctx context.Context, chain ibc.Chain, granterAddress string) ([]*authz.GrantAuthorization, error) { + res, err := query.GRPCQuery[authz.QueryGranterGrantsResponse](ctx, chain, &authz.QueryGranterGrantsRequest{ + Granter: granterAddress, + }) + if err != nil { + return nil, err + } + + return res.Grants, nil +} + func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() { t := suite.T() ctx := context.TODO() @@ -137,7 +151,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() { t.Run("verify receiver wallet amount", func(t *testing.T) { chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID) - actualBalance, err := suite.QueryBalance(ctx, chainB, receiverWalletAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, receiverWalletAddress, chainBIBCToken.IBCDenom()) suite.Require().NoError(err) suite.Require().Equal(testvalues.IBCTransferAmount, actualBalance.Int64()) @@ -274,7 +288,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() { t.Run("verify receiver wallet amount", func(t *testing.T) { chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID) - actualBalance, err := suite.QueryBalance(ctx, chainB, receiverWalletAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, receiverWalletAddress, chainBIBCToken.IBCDenom()) suite.Require().NoError(err) suite.Require().Equal(int64(0), actualBalance.Int64()) diff --git a/e2e/tests/transfer/base_test.go b/e2e/tests/transfer/base_test.go index f3272e54a54..b7a18886081 100644 --- a/e2e/tests/transfer/base_test.go +++ b/e2e/tests/transfer/base_test.go @@ -19,6 +19,7 @@ import ( paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" @@ -34,8 +35,7 @@ type TransferTestSuite struct { // QueryTransferSendEnabledParam queries the on-chain send enabled param for the transfer module func (s *TransferTestSuite) QueryTransferParams(ctx context.Context, chain ibc.Chain) transfertypes.Params { - queryClient := s.GetChainGRCPClients(chain).TransferQueryClient - res, err := queryClient.Params(ctx, &transfertypes.QueryParamsRequest{}) + res, err := query.GRPCQuery[transfertypes.QueryParamsResponse](ctx, chain, &transfertypes.QueryParamsRequest{}) s.Require().NoError(err) return *res.Params } @@ -64,7 +64,6 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { s.Require().NoError(chainA.(*cosmos.CosmosChain).StopAllNodes(ctx)) s.Require().NoError(chainA.(*cosmos.CosmosChain).StartAllNodes(ctx)) s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA), "failed to wait for blocks") - s.InitGRPCClients(chainA) }) chainAVersion := chainA.Config().Images[0].Version @@ -83,7 +82,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { s.Require().Equal(expected, actualBalance) if testvalues.TotalEscrowFeatureReleases.IsSupported(chainAVersion) { - actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainA, chainADenom) + actualTotalEscrow, err := query.QueryTotalEscrowForDenom(ctx, chainA, chainADenom) s.Require().NoError(err) expectedTotalEscrow := sdk.NewCoin(chainADenom, sdkmath.NewInt(testvalues.IBCTransferAmount)) @@ -100,7 +99,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount @@ -119,13 +118,13 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { }) t.Run("tokens are escrowed", func(t *testing.T) { - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) s.Require().Equal(sdkmath.ZeroInt(), actualBalance) if testvalues.TotalEscrowFeatureReleases.IsSupported(chainBVersion) { - actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainB, chainBIBCToken.IBCDenom()) + actualTotalEscrow, err := query.QueryTotalEscrowForDenom(ctx, chainB, chainBIBCToken.IBCDenom()) s.Require().NoError(err) s.Require().Equal(sdk.NewCoin(chainBIBCToken.IBCDenom(), sdkmath.NewInt(0)), actualTotalEscrow) // total escrow is zero because sending chain is not source for tokens } @@ -145,7 +144,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { if testvalues.TotalEscrowFeatureReleases.IsSupported(chainAVersion) { t.Run("tokens are un-escrowed", func(t *testing.T) { - actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainA, chainADenom) + actualTotalEscrow, err := query.QueryTotalEscrowForDenom(ctx, chainA, chainADenom) s.Require().NoError(err) s.Require().Equal(sdk.NewCoin(chainADenom, sdkmath.NewInt(0)), actualTotalEscrow) // total escrow is zero because tokens have come back }) @@ -264,7 +263,7 @@ func (s *TransferTestSuite) TestSendEnabledParam() { chainAVersion := chainA.Config().Images[0].Version isSelfManagingParams := testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) - govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -327,7 +326,7 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() { chainAVersion := chainA.Config().Images[0].Version isSelfManagingParams := testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) - govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -358,7 +357,7 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) s.Require().NoError(err) @@ -463,7 +462,7 @@ func (s *TransferTestSuite) TestMsgTransfer_WithMemo() { t.Run("packets relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) s.Require().Equal(testvalues.IBCTransferAmount, actualBalance.Int64()) diff --git a/e2e/tests/transfer/incentivized_test.go b/e2e/tests/transfer/incentivized_test.go index 1902c9e0c66..61d7b28ad71 100644 --- a/e2e/tests/transfer/incentivized_test.go +++ b/e2e/tests/transfer/incentivized_test.go @@ -16,6 +16,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" @@ -72,7 +73,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Su }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := s.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -99,7 +100,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Su t.Run("pay packet fee", func(t *testing.T) { t.Run("no incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -113,7 +114,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Su }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -138,7 +139,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Su }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -189,7 +190,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := s.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -213,7 +214,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou t.Run("pay packet fee", func(t *testing.T) { t.Run("no incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -227,7 +228,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -252,7 +253,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -310,13 +311,13 @@ func (s *IncentivizedTransferTestSuite) TestMultiMsg_MsgPayPacketFeeSingleSender }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := s.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) t.Run("no incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -327,7 +328,7 @@ func (s *IncentivizedTransferTestSuite) TestMultiMsg_MsgPayPacketFeeSingleSender s.AssertTxSuccess(resp) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -351,7 +352,7 @@ func (s *IncentivizedTransferTestSuite) TestMultiMsg_MsgPayPacketFeeSingleSender }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -408,7 +409,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_SingleSender_TimesOu }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := s.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -439,7 +440,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_SingleSender_TimesOu packetFee := feetypes.NewPacketFee(testFee, chainAWallet.FormattedAddress(), nil) t.Run("no incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -450,7 +451,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_SingleSender_TimesOu }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -475,7 +476,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_SingleSender_TimesOu }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -534,7 +535,7 @@ func (s *IncentivizedTransferTestSuite) TestPayPacketFeeAsync_SingleSender_NoCou t.Run("pay packet fee", func(t *testing.T) { t.Run("no incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -548,7 +549,7 @@ func (s *IncentivizedTransferTestSuite) TestPayPacketFeeAsync_SingleSender_NoCou }) t.Run("should be incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -574,7 +575,7 @@ func (s *IncentivizedTransferTestSuite) TestPayPacketFeeAsync_SingleSender_NoCou t.Run("with no counterparty address", func(t *testing.T) { t.Run("packets are relayed", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -625,7 +626,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncMultipleSenders }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := s.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -652,7 +653,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncMultipleSenders t.Run("pay packet fee", func(t *testing.T) { t.Run("no incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -671,7 +672,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncMultipleSenders }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee1 := packets[0].PacketFees[0].Fee @@ -719,7 +720,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncMultipleSenders }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) diff --git a/e2e/tests/transfer/localhost_test.go b/e2e/tests/transfer/localhost_test.go index 00825c266ed..1631e318c89 100644 --- a/e2e/tests/transfer/localhost_test.go +++ b/e2e/tests/transfer/localhost_test.go @@ -10,6 +10,7 @@ import ( testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" @@ -53,13 +54,13 @@ func (s *LocalhostTransferTestSuite) TestMsgTransfer_Localhost() { s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") t.Run("verify begin blocker was executed", func(t *testing.T) { - cs, err := s.QueryClientState(ctx, chainA, exported.LocalhostClientID) + cs, err := query.QueryClientState(ctx, chainA, exported.LocalhostClientID) s.Require().NoError(err) originalHeight := cs.GetLatestHeight() s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - cs, err = s.QueryClientState(ctx, chainA, exported.LocalhostClientID) + cs, err = query.QueryClientState(ctx, chainA, exported.LocalhostClientID) s.Require().NoError(err) s.Require().True(cs.GetLatestHeight().GT(originalHeight), "client state height was not incremented") }) @@ -115,11 +116,11 @@ func (s *LocalhostTransferTestSuite) TestMsgTransfer_Localhost() { }) t.Run("query localhost transfer channel ends", func(t *testing.T) { - channelEndA, err := s.QueryChannel(ctx, chainA, transfertypes.PortID, msgChanOpenInitRes.ChannelId) + channelEndA, err := query.QueryChannel(ctx, chainA, transfertypes.PortID, msgChanOpenInitRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndA) - channelEndB, err := s.QueryChannel(ctx, chainA, transfertypes.PortID, msgChanOpenTryRes.ChannelId) + channelEndB, err := query.QueryChannel(ctx, chainA, transfertypes.PortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndB) @@ -167,7 +168,7 @@ func (s *LocalhostTransferTestSuite) TestMsgTransfer_Localhost() { s.AssertPacketRelayed(ctx, chainA, transfertypes.PortID, msgChanOpenInitRes.ChannelId, 1) ibcToken := testsuite.GetIBCToken(chainADenom, transfertypes.PortID, msgChanOpenTryRes.ChannelId) - actualBalance, err := s.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), ibcToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), ibcToken.IBCDenom()) s.Require().NoError(err) diff --git a/e2e/tests/transfer/upgrades_test.go b/e2e/tests/transfer/upgrades_test.go index c1bd43898dd..72564e1189b 100644 --- a/e2e/tests/transfer/upgrades_test.go +++ b/e2e/tests/transfer/upgrades_test.go @@ -14,6 +14,7 @@ import ( sdkmath "cosmossdk.io/math" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" @@ -80,7 +81,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ }) t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) { - chA, err := s.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + chA, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.InitiateChannelUpgrade(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, s.CreateUpgradeFields(chA)) @@ -95,21 +96,21 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ t.Run("packets are relayed between chain A and chain B", func(t *testing.T) { // packet from chain A to chain B s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount s.Require().Equal(expected, actualBalance.Int64()) // packet from chain B to chain A s.AssertPacketRelayed(ctx, chainB, channelB.PortID, channelB.ChannelID, 1) - actualBalance, err = s.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) + actualBalance, err = query.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) s.Require().NoError(err) expected = testvalues.IBCTransferAmount s.Require().Equal(expected, actualBalance.Int64()) }) t.Run("verify channel A upgraded and is fee enabled", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + channel, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -118,13 +119,13 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := s.QueryFeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("verify channel B upgraded and is fee enabled", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + channel, err := query.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -133,14 +134,14 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := s.QueryFeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("prune packet acknowledgements", func(t *testing.T) { // there should be one ack for the packet that we sent before the upgrade - acks, err := s.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) + acks, err := query.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) s.Require().NoError(err) s.Require().Len(acks, 1) s.Require().Equal(uint64(1), acks[0].Sequence) @@ -149,7 +150,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.AssertTxSuccess(pruneAcksTxResponse) // after pruning there should not be any acks - acks, err = s.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) + acks, err = query.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) s.Require().NoError(err) s.Require().Empty(acks) }) @@ -177,7 +178,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ resp := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress()) s.AssertTxSuccess(resp) - address, err := s.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -188,7 +189,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ t.Run("send incentivized transfer packet", func(t *testing.T) { // before adding fees for the packet, there should not be incentivized packets - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) @@ -201,13 +202,13 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) t.Run("tokens are received by walletB", func(t *testing.T) { - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) // walletB has received two IBC transfers of value testvalues.IBCTransferAmount since the start of the test. @@ -269,7 +270,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ wg.Add(1) go func() { defer wg.Done() - chA, err := s.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + chA, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.InitiateChannelUpgrade(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, s.CreateUpgradeFields(chA)) }() @@ -277,7 +278,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ wg.Add(1) go func() { defer wg.Done() - chB, err := s.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + chB, err := query.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.InitiateChannelUpgrade(ctx, chainB, chainBWallet, channelB.PortID, channelB.ChannelID, s.CreateUpgradeFields(chB)) }() @@ -293,7 +294,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ }) t.Run("verify channel A upgraded and is fee enabled", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + channel, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -302,13 +303,13 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := s.QueryFeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("verify channel B upgraded and is fee enabled", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + channel, err := query.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -317,7 +318,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := s.QueryFeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) @@ -342,7 +343,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ }) t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) { - chA, err := s.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + chA, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.InitiateChannelUpgrade(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, s.CreateUpgradeFields(chA)) @@ -355,26 +356,26 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks") t.Run("verify channel A did not upgrade", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + channel, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Equal(channeltypes.OPEN, channel.State, "the channel state is not OPEN") s.Require().Equal(transfertypes.Version, channel.Version, "the channel version is not ics20-1") - errorReceipt, err := s.QueryUpgradeError(ctx, chainA, channelA.PortID, channelA.ChannelID) + errorReceipt, err := query.QueryUpgradeError(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Equal(uint64(1), errorReceipt.Sequence) s.Require().Contains(errorReceipt.Message, "restored channel to pre-upgrade state") }) t.Run("verify channel B did not upgrade", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + channel, err := query.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.Require().Equal(channeltypes.OPEN, channel.State, "the channel state is not OPEN") s.Require().Equal(transfertypes.Version, channel.Version, "the channel version is not ics20-1") - errorReceipt, err := s.QueryUpgradeError(ctx, chainB, channelB.PortID, channelB.ChannelID) + errorReceipt, err := query.QueryUpgradeError(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.Require().Equal(uint64(1), errorReceipt.Sequence) s.Require().Contains(errorReceipt.Message, "restored channel to pre-upgrade state") diff --git a/e2e/testsuite/query/grpc_query.go b/e2e/testsuite/query/grpc_query.go new file mode 100644 index 00000000000..737b2d5b849 --- /dev/null +++ b/e2e/testsuite/query/grpc_query.go @@ -0,0 +1,60 @@ +package query + +import ( + "context" + "fmt" + "strings" + + "github.com/strangelove-ventures/interchaintest/v8/ibc" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + + "github.com/cosmos/gogoproto/proto" +) + +// Queries the chain with a query request and deserializes the response to T +func GRPCQuery[T any](ctx context.Context, chain ibc.Chain, req proto.Message, opts ...grpc.CallOption) (*T, error) { + path, err := getProtoPath(req) + if err != nil { + return nil, err + } + + // Create a connection to the gRPC server. + grpcConn, err := grpc.Dial( + chain.GetHostGRPCAddress(), + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + if err != nil { + return nil, err + } + + defer grpcConn.Close() + + resp := new(T) + err = grpcConn.Invoke(ctx, path, req, resp, opts...) + if err != nil { + return nil, err + } + + return resp, nil +} + +func getProtoPath(req proto.Message) (string, error) { + typeURL := "/" + proto.MessageName(req) + + queryIndex := strings.Index(typeURL, "Query") + if queryIndex == -1 { + return "", fmt.Errorf("invalid typeURL: %s", typeURL) + } + + // Add to the index to account for the length of "Query" + queryIndex += len("Query") + + // Add a slash before the query + urlWithSlash := typeURL[:queryIndex] + "/" + typeURL[queryIndex:] + if !strings.HasSuffix(urlWithSlash, "Request") { + return "", fmt.Errorf("invalid typeURL: %s", typeURL) + } + + return strings.TrimSuffix(urlWithSlash, "Request"), nil +} diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/query/queries.go similarity index 64% rename from e2e/testsuite/grpc_query.go rename to e2e/testsuite/query/queries.go index 1b5c35e8a06..10e05735325 100644 --- a/e2e/testsuite/grpc_query.go +++ b/e2e/testsuite/query/queries.go @@ -1,80 +1,30 @@ -package testsuite +package query import ( "context" "fmt" "sort" - "strings" "cosmossdk.io/math" + "github.com/strangelove-ventures/interchaintest/v8/ibc" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" - channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v8/testing" - - "github.com/cosmos/gogoproto/proto" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ) -// Queries the chain with a query request and deserializes the response to T -func GRPCQuery[T any](ctx context.Context, chain ibc.Chain, req proto.Message, opts ...grpc.CallOption) (*T, error) { - path, err := getProtoPath(req) - if err != nil { - return nil, err - } - - // Create a connection to the gRPC server. - grpcConn, err := grpc.Dial( - chain.GetHostGRPCAddress(), - grpc.WithTransportCredentials(insecure.NewCredentials()), - ) - if err != nil { - return nil, err - } - - defer grpcConn.Close() - - resp := new(T) - err = grpcConn.Invoke(ctx, path, req, resp, opts...) - if err != nil { - return nil, err - } - - return resp, nil -} - -func getProtoPath(req proto.Message) (string, error) { - typeURL := "/" + proto.MessageName(req) - - queryIndex := strings.Index(typeURL, "Query") - if queryIndex == -1 { - return "", fmt.Errorf("invalid typeURL: %s", typeURL) - } - - // Add to the index to account for the length of "Query" - queryIndex += len("Query") - - // Add a slash before the query - urlWithSlash := typeURL[:queryIndex] + "/" + typeURL[queryIndex:] - if !strings.HasSuffix(urlWithSlash, "Request") { - return "", fmt.Errorf("invalid typeURL: %s", typeURL) - } - - return strings.TrimSuffix(urlWithSlash, "Request"), nil -} - // QueryModuleAccountAddress returns the address of the given module on the given chain. // Added because interchaintest's method doesn't work. -func (*E2ETestSuite) QueryModuleAccountAddress(ctx context.Context, moduleName string, chain ibc.Chain) (sdk.AccAddress, error) { +func QueryModuleAccountAddress(ctx context.Context, moduleName string, chain ibc.Chain) (sdk.AccAddress, error) { modAccResp, err := GRPCQuery[authtypes.QueryModuleAccountByNameResponse]( ctx, chain, &authtypes.QueryModuleAccountByNameRequest{Name: moduleName}, ) @@ -101,7 +51,7 @@ func (*E2ETestSuite) QueryModuleAccountAddress(ctx context.Context, moduleName s } // QueryClientState queries the client state on the given chain for the provided clientID. -func (*E2ETestSuite) QueryClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexported.ClientState, error) { +func QueryClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexported.ClientState, error) { clientStateResp, err := GRPCQuery[clienttypes.QueryClientStateResponse](ctx, chain, &clienttypes.QueryClientStateRequest{ ClientId: ibctesting.FirstClientID, }) @@ -120,7 +70,7 @@ func (*E2ETestSuite) QueryClientState(ctx context.Context, chain ibc.Chain, clie } // QueryClientStatus queries the status of the client by clientID -func (*E2ETestSuite) QueryClientStatus(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { +func QueryClientStatus(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { clientStatusResp, err := GRPCQuery[clienttypes.QueryClientStatusResponse](ctx, chain, &clienttypes.QueryClientStatusRequest{ ClientId: clientID, }) @@ -133,7 +83,7 @@ func (*E2ETestSuite) QueryClientStatus(ctx context.Context, chain ibc.Chain, cli // GetValidatorSetByHeight returns the validators of the given chain at the specified height. The returned validators // are sorted by address. -func (*E2ETestSuite) GetValidatorSetByHeight(ctx context.Context, chain ibc.Chain, height uint64) ([]*cmtservice.Validator, error) { +func GetValidatorSetByHeight(ctx context.Context, chain ibc.Chain, height uint64) ([]*cmtservice.Validator, error) { res, err := GRPCQuery[cmtservice.GetValidatorSetByHeightResponse](ctx, chain, &cmtservice.GetValidatorSetByHeightRequest{ Height: int64(height), }) @@ -149,7 +99,7 @@ func (*E2ETestSuite) GetValidatorSetByHeight(ctx context.Context, chain ibc.Chai } // QueryBalance returns the balance of a specific denomination for a given account by address. -func (*E2ETestSuite) QueryBalance(ctx context.Context, chain ibc.Chain, address string, denom string) (math.Int, error) { +func QueryBalance(ctx context.Context, chain ibc.Chain, address string, denom string) (math.Int, error) { res, err := GRPCQuery[banktypes.QueryBalanceResponse](ctx, chain, &banktypes.QueryBalanceRequest{ Address: address, Denom: denom, @@ -162,12 +112,11 @@ func (*E2ETestSuite) QueryBalance(ctx context.Context, chain ibc.Chain, address } // QueryChannel queries the channel on a given chain for the provided portID and channelID -func (s *E2ETestSuite) QueryChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.Channel, error) { +func QueryChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.Channel, error) { res, err := GRPCQuery[channeltypes.QueryChannelResponse](ctx, chain, &channeltypes.QueryChannelRequest{ PortId: portID, ChannelId: channelID, }) - if err != nil { return channeltypes.Channel{}, err } @@ -176,7 +125,7 @@ func (s *E2ETestSuite) QueryChannel(ctx context.Context, chain ibc.Chain, portID } // QueryCounterPartyPayee queries the counterparty payee of the given chain and relayer address on the specified channel. -func (s *E2ETestSuite) QueryCounterPartyPayee(ctx context.Context, chain ibc.Chain, relayerAddress, channelID string) (string, error) { +func QueryCounterPartyPayee(ctx context.Context, chain ibc.Chain, relayerAddress, channelID string) (string, error) { res, err := GRPCQuery[feetypes.QueryCounterpartyPayeeResponse](ctx, chain, &feetypes.QueryCounterpartyPayeeRequest{ ChannelId: channelID, Relayer: relayerAddress, @@ -189,7 +138,7 @@ func (s *E2ETestSuite) QueryCounterPartyPayee(ctx context.Context, chain ibc.Cha } // QueryIncentivizedPacketsForChannel queries the incentivized packets on the specified channel. -func (s *E2ETestSuite) QueryIncentivizedPacketsForChannel( +func QueryIncentivizedPacketsForChannel( ctx context.Context, chain ibc.Chain, portID, @@ -207,7 +156,7 @@ func (s *E2ETestSuite) QueryIncentivizedPacketsForChannel( } // QueryFeeEnabledChannel queries the fee-enabled status of a channel. -func (s *E2ETestSuite) QueryFeeEnabledChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (bool, error) { +func QueryFeeEnabledChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (bool, error) { res, err := GRPCQuery[feetypes.QueryFeeEnabledChannelResponse](ctx, chain, &feetypes.QueryFeeEnabledChannelRequest{ PortId: portID, ChannelId: channelID, @@ -218,3 +167,41 @@ func (s *E2ETestSuite) QueryFeeEnabledChannel(ctx context.Context, chain ibc.Cha } return res.FeeEnabled, nil } + +// QueryTotalEscrowForDenom queries the total amount of tokens in escrow for a denom +func QueryTotalEscrowForDenom(ctx context.Context, chain ibc.Chain, denom string) (sdk.Coin, error) { + res, err := GRPCQuery[transfertypes.QueryTotalEscrowForDenomResponse](ctx, chain, &transfertypes.QueryTotalEscrowForDenomRequest{ + Denom: denom, + }) + if err != nil { + return sdk.Coin{}, err + } + + return res.Amount, nil +} + +// QueryPacketAcknowledgements queries the packet acknowledgements on the given chain for the provided channel (optional) list of packet commitment sequences. +func QueryPacketAcknowledgements(ctx context.Context, chain ibc.Chain, portID, channelID string, packetCommitmentSequences []uint64) ([]*channeltypes.PacketState, error) { + res, err := GRPCQuery[channeltypes.QueryPacketAcknowledgementsResponse](ctx, chain, &channeltypes.QueryPacketAcknowledgementsRequest{ + PortId: portID, + ChannelId: channelID, + PacketCommitmentSequences: packetCommitmentSequences, + }) + if err != nil { + return nil, err + } + + return res.Acknowledgements, nil +} + +// QueryUpgradeError queries the upgrade error on the given chain for the provided channel. +func QueryUpgradeError(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.ErrorReceipt, error) { + res, err := GRPCQuery[channeltypes.QueryUpgradeErrorResponse](ctx, chain, &channeltypes.QueryUpgradeErrorRequest{ + PortId: portID, + ChannelId: channelID, + }) + if err != nil { + return channeltypes.ErrorReceipt{}, err + } + return res.ErrorReceipt, nil +} diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 8622c276711..dce6c2dd9de 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -22,6 +22,7 @@ import ( "github.com/cosmos/ibc-go/e2e/relayer" "github.com/cosmos/ibc-go/e2e/testsuite/diagnostics" + "github.com/cosmos/ibc-go/e2e/testsuite/query" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" @@ -309,7 +310,7 @@ func (s *E2ETestSuite) CreateUserOnChainB(ctx context.Context, amount int64) ibc func (s *E2ETestSuite) GetChainANativeBalance(ctx context.Context, user ibc.Wallet) (int64, error) { chainA, _ := s.GetChains() - balanceResp, err := GRPCQuery[banktypes.QueryBalanceResponse](ctx, chainA, &banktypes.QueryBalanceRequest{ + balanceResp, err := query.GRPCQuery[banktypes.QueryBalanceResponse](ctx, chainA, &banktypes.QueryBalanceRequest{ Address: user.FormattedAddress(), Denom: chainA.Config().Denom, }) @@ -324,7 +325,7 @@ func (s *E2ETestSuite) GetChainANativeBalance(ctx context.Context, user ibc.Wall func (s *E2ETestSuite) GetChainBNativeBalance(ctx context.Context, user ibc.Wallet) (int64, error) { _, chainB := s.GetChains() - balanceResp, err := GRPCQuery[banktypes.QueryBalanceResponse](ctx, chainB, &banktypes.QueryBalanceRequest{ + balanceResp, err := query.GRPCQuery[banktypes.QueryBalanceResponse](ctx, chainB, &banktypes.QueryBalanceRequest{ Address: user.FormattedAddress(), Denom: chainB.Config().Denom, }) @@ -338,7 +339,7 @@ func (s *E2ETestSuite) GetChainBNativeBalance(ctx context.Context, user ibc.Wall // AssertPacketRelayed asserts that the packet commitment does not exist on the sending chain. // The packet commitment will be deleted upon a packet acknowledgement or timeout. func (s *E2ETestSuite) AssertPacketRelayed(ctx context.Context, chain ibc.Chain, portID, channelID string, sequence uint64) { - commitmentResp, err := GRPCQuery[channeltypes.QueryPacketCommitmentResponse](ctx, chain, &channeltypes.QueryPacketCommitmentRequest{ + commitmentResp, err := query.GRPCQuery[channeltypes.QueryPacketCommitmentResponse](ctx, chain, &channeltypes.QueryPacketCommitmentRequest{ PortId: portID, ChannelId: channelID, Sequence: sequence, @@ -353,7 +354,7 @@ func (s *E2ETestSuite) AssertPacketRelayed(ctx context.Context, chain ibc.Chain, func (s *E2ETestSuite) AssertHumanReadableDenom(ctx context.Context, chain ibc.Chain, counterpartyNativeDenom string, counterpartyChannel ibc.ChannelOutput) { chainIBCDenom := GetIBCToken(counterpartyNativeDenom, counterpartyChannel.Counterparty.PortID, counterpartyChannel.Counterparty.ChannelID) - denomMetadataResp, err := GRPCQuery[banktypes.QueryDenomMetadataResponse](ctx, chain, &banktypes.QueryDenomMetadataRequest{ + denomMetadataResp, err := query.GRPCQuery[banktypes.QueryDenomMetadataResponse](ctx, chain, &banktypes.QueryDenomMetadataRequest{ Denom: chainIBCDenom.IBCDenom(), }) s.Require().NoError(err) @@ -450,7 +451,7 @@ func (s *E2ETestSuite) CreateUpgradeFields(channel channeltypes.Channel) channel // SetUpgradeTimeoutParam creates and submits a governance proposal to execute the message to update 04-channel params with a timeout of 1s func (s *E2ETestSuite) SetUpgradeTimeoutParam(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet) { const timeoutDelta = 1000000000 // use 1 second as relative timeout to force upgrade timeout on the counterparty - govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chain) + govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chain) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -461,7 +462,7 @@ func (s *E2ETestSuite) SetUpgradeTimeoutParam(ctx context.Context, chain ibc.Cha // InitiateChannelUpgrade creates and submits a governance proposal to execute the message to initiate a channel upgrade func (s *E2ETestSuite) InitiateChannelUpgrade(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet, portID, channelID string, upgradeFields channeltypes.UpgradeFields) { - govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chain) + govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chain) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index dfb38564460..6c2b6a595c8 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -23,6 +23,7 @@ import ( govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testsuite/sanitize" "github.com/cosmos/ibc-go/e2e/testvalues" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" @@ -183,7 +184,7 @@ func (*E2ETestSuite) waitForGovV1ProposalToPass(ctx context.Context, chain ibc.C var govProposal *govtypesv1.Proposal // poll for the query for the entire voting period to see if the proposal has passed. err := test.WaitForCondition(testvalues.VotingPeriod, 10*time.Second, func() (bool, error) { - proposalResp, err := GRPCQuery[govtypesv1.QueryProposalResponse](ctx, chain, &govtypesv1.QueryProposalRequest{ + proposalResp, err := query.GRPCQuery[govtypesv1.QueryProposalResponse](ctx, chain, &govtypesv1.QueryProposalRequest{ ProposalId: proposalID, }) if err != nil { @@ -220,7 +221,7 @@ func (s *E2ETestSuite) ExecuteAndPassGovV1Beta1Proposal(ctx context.Context, cha // TODO: replace with parsed proposal ID from MsgSubmitProposalResponse // https://github.com/cosmos/ibc-go/issues/2122 - proposalResp, err := GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, cosmosChain, &govtypesv1beta1.QueryProposalRequest{ + proposalResp, err := query.GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, cosmosChain, &govtypesv1beta1.QueryProposalRequest{ ProposalId: proposalID, }) s.Require().NoError(err) @@ -232,7 +233,7 @@ func (s *E2ETestSuite) ExecuteAndPassGovV1Beta1Proposal(ctx context.Context, cha s.Require().NoError(err) // ensure voting period has not passed before validators finished voting - proposalResp, err = GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, cosmosChain, &govtypesv1beta1.QueryProposalRequest{ + proposalResp, err = query.GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, cosmosChain, &govtypesv1beta1.QueryProposalRequest{ ProposalId: proposalID, }) s.Require().NoError(err) @@ -249,7 +250,7 @@ func (s *E2ETestSuite) ExecuteAndPassGovV1Beta1Proposal(ctx context.Context, cha func (*E2ETestSuite) waitForGovV1Beta1ProposalToPass(ctx context.Context, chain ibc.Chain, proposalID uint64) error { // poll for the query for the entire voting period to see if the proposal has passed. return test.WaitForCondition(testvalues.VotingPeriod, 10*time.Second, func() (bool, error) { - proposalResp, err := GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, chain, &govtypesv1beta1.QueryProposalRequest{ + proposalResp, err := query.GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, chain, &govtypesv1beta1.QueryProposalRequest{ ProposalId: proposalID, }) if err != nil { From 2054c12a14cd8c5e609d2453c1217a7fe2ad816e Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 16:06:59 +0700 Subject: [PATCH 05/18] test: fixed more tests --- e2e/tests/upgrades/genesis_test.go | 17 ++--- e2e/tests/upgrades/upgrade_test.go | 102 ++++++++++++++--------------- e2e/tests/wasm/grandpa_test.go | 38 +++-------- e2e/tests/wasm/upgrade_test.go | 12 ++-- 4 files changed, 71 insertions(+), 98 deletions(-) diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index 4b387bb128b..ccc768778cf 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -21,6 +21,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" @@ -103,7 +104,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics20: packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) @@ -112,10 +113,14 @@ func (s *GenesisTestSuite) TestIBCGenesis() { }) t.Run("ics27: verify interchain account", func(t *testing.T) { - var err error - hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + res, err := query.GRPCQuery[controllertypes.QueryInterchainAccountResponse](ctx, chainA, &controllertypes.QueryInterchainAccountRequest{ + Owner: controllerAddress, + ConnectionId: ibctesting.FirstConnectionID, + }) s.Require().NoError(err) - s.Require().NotZero(len(hostAccount)) + s.Require().NotZero(len(res.Address)) + + hostAccount = res.Address channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID) s.Require().NoError(err) @@ -229,10 +234,6 @@ func (s *GenesisTestSuite) HaltChainAndExportGenesis(ctx context.Context, chain err = chain.StartAllNodes(ctx) s.Require().NoError(err) - // we are reinitializing the clients because we need to update the hostGRPCAddress after - // the upgrade and subsequent restarting of nodes - s.InitGRPCClients(chain) - timeoutCtx, timeoutCtxCancel = context.WithTimeout(ctx, time.Minute*2) defer timeoutCtxCancel() diff --git a/e2e/tests/upgrades/upgrade_test.go b/e2e/tests/upgrades/upgrade_test.go index 91efd2516da..90e2eac0e17 100644 --- a/e2e/tests/upgrades/upgrade_test.go +++ b/e2e/tests/upgrades/upgrade_test.go @@ -25,6 +25,7 @@ import ( e2erelayer "github.com/cosmos/ibc-go/e2e/relayer" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" @@ -102,10 +103,6 @@ func (s *UpgradeTestSuite) UpgradeChain(ctx context.Context, chain *cosmos.Cosmo err = chain.StartAllNodes(ctx) s.Require().NoError(err, "error starting upgraded node(s)") - // we are reinitializing the clients because we need to update the hostGRPCAddress after - // the upgrade and subsequent restarting of nodes - s.InitGRPCClients(chain) - timeoutCtx, timeoutCtxCancel = context.WithTimeout(ctx, time.Minute*2) defer timeoutCtxCancel() @@ -166,7 +163,7 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) @@ -194,7 +191,7 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 2) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) @@ -213,7 +210,7 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) s.Require().NoError(err) @@ -244,7 +241,7 @@ func (s *UpgradeTestSuite) TestChainUpgrade() { }) t.Run("verify tokens sent", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chain, userWalletAddr, chain.Config().Denom) + balance, err := query.QueryBalance(ctx, chain, userWalletAddr, chain.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount * 2 @@ -268,7 +265,7 @@ func (s *UpgradeTestSuite) TestChainUpgrade() { }) t.Run("verify tokens sent", func(t *testing.T) { - balance, err := s.QueryBalance(ctx, chain, userWalletAddr, chain.Config().Denom) + balance, err := query.QueryBalance(ctx, chain, userWalletAddr, chain.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount * 3 @@ -310,11 +307,11 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") t.Run("check that both tendermint clients are active", func(t *testing.T) { - status, err := s.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(0)) + status, err := query.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(0)) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) - status, err = s.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(1)) + status, err = query.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(1)) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) }) @@ -349,7 +346,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { s.AssertTxSuccess(resp) t.Run("check that the solomachine is now active and that the clientstate is a pre-upgrade v2 solomachine clientstate", func(t *testing.T) { - status, err := s.QueryClientStatus(ctx, chainA, testvalues.SolomachineClientID(2)) + status, err := query.QueryClientStatus(ctx, chainA, testvalues.SolomachineClientID(2)) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) @@ -380,7 +377,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount @@ -404,11 +401,11 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { } t.Run("check that the tendermint clients are active again after upgrade", func(t *testing.T) { - status, err := s.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(0)) + status, err := query.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(0)) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) - status, err = s.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(1)) + status, err = query.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(1)) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) }) @@ -421,7 +418,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount * 2 @@ -475,7 +472,7 @@ func (s *UpgradeTestSuite) TestV7ToV7_1ChainUpgrade() { t.Run("packet is relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount @@ -490,20 +487,20 @@ func (s *UpgradeTestSuite) TestV7ToV7_1ChainUpgrade() { }) t.Run("ensure the localhost client is active and sentinel connection is stored in state", func(t *testing.T) { - status, err := s.QueryClientStatus(ctx, chainA, exported.LocalhostClientID) + status, err := query.QueryClientStatus(ctx, chainA, exported.LocalhostClientID) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) - connectionEnd, err := s.QueryConnection(ctx, chainA, exported.LocalhostConnectionID) + connectionResp, err := query.GRPCQuery[connectiontypes.QueryConnectionResponse](ctx, chainA, &connectiontypes.QueryConnectionRequest{ConnectionId: exported.LocalhostConnectionID}) s.Require().NoError(err) - s.Require().Equal(connectiontypes.OPEN, connectionEnd.State) - s.Require().Equal(exported.LocalhostClientID, connectionEnd.ClientId) - s.Require().Equal(exported.LocalhostClientID, connectionEnd.Counterparty.ClientId) - s.Require().Equal(exported.LocalhostConnectionID, connectionEnd.Counterparty.ConnectionId) + s.Require().Equal(connectiontypes.OPEN, connectionResp.Connection.State) + s.Require().Equal(exported.LocalhostClientID, connectionResp.Connection.ClientId) + s.Require().Equal(exported.LocalhostClientID, connectionResp.Connection.Counterparty.ClientId) + s.Require().Equal(exported.LocalhostConnectionID, connectionResp.Connection.Counterparty.ConnectionId) }) t.Run("ensure escrow amount for native denom is stored in state", func(t *testing.T) { - actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainA, chainADenom) + actualTotalEscrow, err := query.QueryTotalEscrowForDenom(ctx, chainA, chainADenom) s.Require().NoError(err) expectedTotalEscrow := sdk.NewCoin(chainADenom, sdkmath.NewInt(testvalues.IBCTransferAmount)) @@ -566,7 +563,7 @@ func (s *UpgradeTestSuite) TestV7ToV8ChainUpgrade() { t.Run("packet is relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount @@ -581,7 +578,7 @@ func (s *UpgradeTestSuite) TestV7ToV8ChainUpgrade() { }) t.Run("update params", func(t *testing.T) { - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainB) + authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainB) s.Require().NoError(err) s.Require().NotNil(authority) @@ -590,10 +587,10 @@ func (s *UpgradeTestSuite) TestV7ToV8ChainUpgrade() { }) t.Run("query params", func(t *testing.T) { - clientParams, err := s.GetChainGRCPClients(chainB).ClientQueryClient.ClientParams(ctx, &clienttypes.QueryClientParamsRequest{}) + clientParamsResp, err := query.GRPCQuery[clienttypes.QueryClientParamsResponse](ctx, chainB, &clienttypes.QueryClientParamsRequest{}) s.Require().NoError(err) - allowedClients := clientParams.Params.AllowedClients + allowedClients := clientParamsResp.Params.AllowedClients s.Require().Len(allowedClients, 2) s.Require().Contains(allowedClients, exported.Tendermint) @@ -652,7 +649,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { t.Run("pay packet fee", func(t *testing.T) { t.Run("no packet fees in escrow", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -667,7 +664,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { }) t.Run("query incentivized packets", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -696,7 +693,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { s.Require().Equal(expected, actualBalance) // query incentivised packets and assert calculated values are correct - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -705,7 +702,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { s.Require().True(actualFee.AckFee.Equal(testFee.AckFee)) s.Require().True(actualFee.TimeoutFee.Equal(testFee.TimeoutFee)) - escrowBalance, err := s.QueryBalance(ctx, chainA, authtypes.NewModuleAddress(feetypes.ModuleName).String(), chainADenom) + escrowBalance, err := query.QueryBalance(ctx, chainA, authtypes.NewModuleAddress(feetypes.ModuleName).String(), chainADenom) s.Require().NoError(err) expected = testFee.Total().AmountOf(chainADenom).Int64() @@ -721,7 +718,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { t.Run("packet is relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount @@ -828,26 +825,26 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { t.Run("query params", func(t *testing.T) { t.Run("on chain A", func(t *testing.T) { - channelParams, err := s.GetChainGRCPClients(chainA).ChannelQueryClient.ChannelParams(ctx, &channeltypes.QueryChannelParamsRequest{}) + channelParamsResp, err := query.GRPCQuery[channeltypes.QueryChannelParamsResponse](ctx, chainA, &channeltypes.QueryChannelParamsRequest{}) s.Require().NoError(err) - upgradeTimeout := channelParams.Params.UpgradeTimeout + upgradeTimeout := channelParamsResp.Params.UpgradeTimeout s.Require().Equal(clienttypes.ZeroHeight(), upgradeTimeout.Height) s.Require().Equal(uint64(time.Minute*10), upgradeTimeout.Timestamp) }) t.Run("on chain B", func(t *testing.T) { - channelParams, err := s.GetChainGRCPClients(chainB).ChannelQueryClient.ChannelParams(ctx, &channeltypes.QueryChannelParamsRequest{}) + channelParamsResp, err := query.GRPCQuery[channeltypes.QueryChannelParamsResponse](ctx, chainB, &channeltypes.QueryChannelParamsRequest{}) s.Require().NoError(err) - upgradeTimeout := channelParams.Params.UpgradeTimeout + upgradeTimeout := channelParamsResp.Params.UpgradeTimeout s.Require().Equal(clienttypes.ZeroHeight(), upgradeTimeout.Height) s.Require().Equal(uint64(time.Minute*10), upgradeTimeout.Timestamp) }) }) t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) { - chA, err := s.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + chA, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.InitiateChannelUpgrade(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, s.CreateUpgradeFields(chA)) @@ -861,20 +858,20 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { t.Run("packets are relayed between chain A and chain B", func(t *testing.T) { // packet from chain A to chain B - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount s.Require().Equal(expected, actualBalance.Int64()) // packet from chain B to chain A - actualBalance, err = s.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) + actualBalance, err = query.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) s.Require().NoError(err) expected = testvalues.IBCTransferAmount s.Require().Equal(expected, actualBalance.Int64()) }) t.Run("verify channel A upgraded and is fee enabled", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + channel, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -883,13 +880,13 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := s.QueryFeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("verify channel B upgraded and is fee enabled", func(t *testing.T) { - channel, err := s.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + channel, err := query.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -898,14 +895,14 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := s.QueryFeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("prune packet acknowledgements", func(t *testing.T) { // there should be one ack for the packet that we sent before the upgrade - acks, err := s.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) + acks, err := query.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) s.Require().NoError(err) s.Require().Len(acks, 1) s.Require().Equal(uint64(1), acks[0].Sequence) @@ -914,7 +911,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { s.AssertTxSuccess(pruneAcksTxResponse) // after pruning there should not be any acks - acks, err = s.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) + acks, err = query.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) s.Require().NoError(err) s.Require().Empty(acks) }) @@ -942,7 +939,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { resp := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress()) s.AssertTxSuccess(resp) - address, err := s.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -953,7 +950,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { t.Run("send incentivized transfer packet", func(t *testing.T) { // before adding fees for the packet, there should not be incentivized packets - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) @@ -975,13 +972,13 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) t.Run("tokens are received by walletB", func(t *testing.T) { - actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) // walletB has received two IBC transfers of value testvalues.IBCTransferAmount since the start of the test. @@ -1000,10 +997,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { // ClientState queries the current ClientState by clientID func (s *UpgradeTestSuite) ClientState(ctx context.Context, chain ibc.Chain, clientID string) (*clienttypes.QueryClientStateResponse, error) { - queryClient := s.GetChainGRCPClients(chain).ClientQueryClient - res, err := queryClient.ClientState(ctx, &clienttypes.QueryClientStateRequest{ - ClientId: clientID, - }) + res, err := query.GRPCQuery[clienttypes.QueryClientStateResponse](ctx, chain, &clienttypes.QueryClientStateRequest{ClientId: clientID}) if err != nil { return res, err } diff --git a/e2e/tests/wasm/grandpa_test.go b/e2e/tests/wasm/grandpa_test.go index b67a4c930e7..09da0ffb226 100644 --- a/e2e/tests/wasm/grandpa_test.go +++ b/e2e/tests/wasm/grandpa_test.go @@ -25,6 +25,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" @@ -86,8 +87,6 @@ func (s *GrandpaTestSuite) TestMsgTransfer_Succeeds_GrandpaContract() { options.SkipPathCreation = true }) - s.InitGRPCClients(cosmosChain) - cosmosWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) file, err := os.Open("contracts/ics10_grandpa_cw.wasm.gz") @@ -238,8 +237,6 @@ func (s *GrandpaTestSuite) TestMsgTransfer_TimesOut_GrandpaContract() { options.SkipPathCreation = true }) - s.InitGRPCClients(cosmosChain) - cosmosWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) file, err := os.Open("contracts/ics10_grandpa_cw.wasm.gz") @@ -352,8 +349,6 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_Success_GrandpaContract() { options.SkipPathCreation = true }) - s.InitGRPCClients(cosmosChain) - cosmosWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) file, err := os.Open("contracts/ics10_grandpa_cw.wasm.gz") @@ -408,7 +403,7 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_Success_GrandpaContract() { s.ExecuteAndPassGovV1Proposal(ctx, message, cosmosChain, cosmosWallet) - clientState, err := s.QueryClientState(ctx, cosmosChain, defaultWasmClientID) + clientState, err := query.QueryClientState(ctx, cosmosChain, defaultWasmClientID) s.Require().NoError(err) wasmClientState, ok := clientState.(*wasmtypes.ClientState) @@ -439,8 +434,6 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_ContractError_GrandpaContract( options.SkipPathCreation = true }) - s.InitGRPCClients(cosmosChain) - cosmosWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) file, err := os.Open("contracts/ics10_grandpa_cw.wasm.gz") @@ -531,8 +524,6 @@ func (s *GrandpaTestSuite) TestRecoverClient_Succeeds_GrandpaContract() { options.SkipPathCreation = true }) - s.InitGRPCClients(cosmosChain) - cosmosWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) file, err := os.Open("contracts/ics10_grandpa_cw_expiry.wasm.gz") @@ -583,19 +574,19 @@ func (s *GrandpaTestSuite) TestRecoverClient_Succeeds_GrandpaContract() { s.Require().NoError(err) // ensure subject client is expired - status, err := s.clientStatus(ctx, cosmosChain, subjectClientID) + status, err := query.QueryClientStatus(ctx, cosmosChain, subjectClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Expired.String(), status, "unexpected subject client status") // ensure substitute client is active - status, err = s.clientStatus(ctx, cosmosChain, substituteClientID) + status, err = query.QueryClientStatus(ctx, cosmosChain, substituteClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status, "unexpected substitute client status") version := cosmosChain.Nodes()[0].Image.Version if govV1FeatureReleases.IsSupported(version) { // create and execute a client recovery proposal - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, cosmosChain) + authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, cosmosChain) s.Require().NoError(err) msgRecoverClient := clienttypes.NewMsgRecoverClient(authority.String(), subjectClientID, substituteClientID) @@ -607,12 +598,12 @@ func (s *GrandpaTestSuite) TestRecoverClient_Succeeds_GrandpaContract() { } // ensure subject client is active - status, err = s.clientStatus(ctx, cosmosChain, subjectClientID) + status, err = query.QueryClientStatus(ctx, cosmosChain, subjectClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) // ensure substitute client is active - status, err = s.clientStatus(ctx, cosmosChain, substituteClientID) + status, err = query.QueryClientStatus(ctx, cosmosChain, substituteClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) } @@ -641,9 +632,10 @@ func (s *GrandpaTestSuite) PushNewWasmClientProposal(ctx context.Context, chain s.ExecuteAndPassGovV1Proposal(ctx, &message, chain, wallet) - checksumBz, err := s.QueryWasmCode(ctx, chain, computedChecksum) + codeResp, err := query.GRPCQuery[wasmtypes.QueryCodeResponse](ctx, chain, &wasmtypes.QueryCodeRequest{Checksum: computedChecksum}) s.Require().NoError(err) + checksumBz := codeResp.Data checksum32 := sha256.Sum256(checksumBz) actualChecksum := hex.EncodeToString(checksum32[:]) s.Require().Equal(computedChecksum, actualChecksum, "checksum returned from query did not match the computed checksum") @@ -651,18 +643,6 @@ func (s *GrandpaTestSuite) PushNewWasmClientProposal(ctx context.Context, chain return actualChecksum } -func (s *GrandpaTestSuite) clientStatus(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { - queryClient := s.GetChainGRCPClients(chain).ClientQueryClient - res, err := queryClient.ClientStatus(ctx, &clienttypes.QueryClientStatusRequest{ - ClientId: clientID, - }) - if err != nil { - return "", err - } - - return res.Status, nil -} - func (s *GrandpaTestSuite) fundUsers(ctx context.Context, fundAmount int64, polkadotChain ibc.Chain, cosmosChain ibc.Chain) (ibc.Wallet, ibc.Wallet) { users := interchaintest.GetAndFundTestUsers(s.T(), ctx, "user", sdkmath.NewInt(fundAmount), polkadotChain, cosmosChain) polkadotUser, cosmosUser := users[0], users[1] diff --git a/e2e/tests/wasm/upgrade_test.go b/e2e/tests/wasm/upgrade_test.go index a591bfb43fc..61a206c55d6 100644 --- a/e2e/tests/wasm/upgrade_test.go +++ b/e2e/tests/wasm/upgrade_test.go @@ -23,6 +23,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" ) @@ -72,9 +73,9 @@ func (s *IBCWasmUpgradeTestSuite) TestIBCWasmChainUpgrade() { }) t.Run("query wasm checksums", func(t *testing.T) { - checksums, err := s.QueryWasmChecksums(ctx, chain) + checksumsResp, err := query.GRPCQuery[wasmtypes.QueryChecksumsResponse](ctx, chain, &wasmtypes.QueryChecksumsRequest{}) s.Require().NoError(err) - s.Require().Contains(checksums, checksum) + s.Require().Contains(checksumsResp.Checksums, checksum) }) } @@ -116,10 +117,6 @@ func (s *IBCWasmUpgradeTestSuite) UpgradeChain(ctx context.Context, chain *cosmo err = chain.StartAllNodes(ctx) s.Require().NoError(err, "error starting upgraded node(s)") - // we are reinitializing the clients because we need to update the hostGRPCAddress after - // the upgrade and subsequent restarting of nodes - s.InitGRPCClients(chain) - timeoutCtx, timeoutCtxCancel = context.WithTimeout(ctx, time.Minute*2) defer timeoutCtxCancel() @@ -145,9 +142,10 @@ func (s *IBCWasmUpgradeTestSuite) ExecStoreCodeProposal(ctx context.Context, cha s.ExecuteAndPassGovV1Proposal(ctx, &msgStoreCode, chain, wallet) - checksumBz, err := s.QueryWasmCode(ctx, chain, computedChecksum) + codeResp, err := query.GRPCQuery[wasmtypes.QueryCodeResponse](ctx, chain, &wasmtypes.QueryCodeRequest{Checksum: computedChecksum}) s.Require().NoError(err) + checksumBz := codeResp.Data checksum32 := sha256.Sum256(checksumBz) actualChecksum := hex.EncodeToString(checksum32[:]) s.Require().Equal(computedChecksum, actualChecksum, "checksum returned from query did not match the computed checksum") From 59d1b5a27b15c75ef580eb59ddc8eca68b98c1c2 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 16:16:40 +0700 Subject: [PATCH 06/18] style: ran 'golangci-lint' --- e2e/tests/interchain_accounts/base_test.go | 2 +- e2e/tests/upgrades/genesis_test.go | 2 +- e2e/testsuite/query/grpc_query.go | 3 +-- e2e/testsuite/query/queries.go | 10 ++++------ 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index a91323c5369..300eb0e335a 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -45,7 +45,7 @@ type InterchainAccountsTestSuite struct { // QueryInterchainAccount queries the interchain account for the given owner and connectionID. func QueryInterchainAccount(ctx context.Context, chain ibc.Chain, address, connectionID string) (string, error) { res, err := query.GRPCQuery[controllertypes.QueryInterchainAccountResponse](ctx, chain, &controllertypes.QueryInterchainAccountRequest{ - Owner: address, + Owner: address, ConnectionId: connectionID, }) if err != nil { diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index ccc768778cf..02e1d7c1466 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -114,7 +114,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics27: verify interchain account", func(t *testing.T) { res, err := query.GRPCQuery[controllertypes.QueryInterchainAccountResponse](ctx, chainA, &controllertypes.QueryInterchainAccountRequest{ - Owner: controllerAddress, + Owner: controllerAddress, ConnectionId: ibctesting.FirstConnectionID, }) s.Require().NoError(err) diff --git a/e2e/testsuite/query/grpc_query.go b/e2e/testsuite/query/grpc_query.go index 737b2d5b849..3a05266583c 100644 --- a/e2e/testsuite/query/grpc_query.go +++ b/e2e/testsuite/query/grpc_query.go @@ -5,11 +5,10 @@ import ( "fmt" "strings" + "github.com/cosmos/gogoproto/proto" "github.com/strangelove-ventures/interchaintest/v8/ibc" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - - "github.com/cosmos/gogoproto/proto" ) // Queries the chain with a query request and deserializes the response to T diff --git a/e2e/testsuite/query/queries.go b/e2e/testsuite/query/queries.go index 10e05735325..dd5d93781d1 100644 --- a/e2e/testsuite/query/queries.go +++ b/e2e/testsuite/query/queries.go @@ -5,21 +5,21 @@ import ( "fmt" "sort" - "cosmossdk.io/math" - "github.com/strangelove-ventures/interchaintest/v8/ibc" + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v8/testing" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ) // QueryModuleAccountAddress returns the address of the given module on the given chain. @@ -128,7 +128,7 @@ func QueryChannel(ctx context.Context, chain ibc.Chain, portID, channelID string func QueryCounterPartyPayee(ctx context.Context, chain ibc.Chain, relayerAddress, channelID string) (string, error) { res, err := GRPCQuery[feetypes.QueryCounterpartyPayeeResponse](ctx, chain, &feetypes.QueryCounterpartyPayeeRequest{ ChannelId: channelID, - Relayer: relayerAddress, + Relayer: relayerAddress, }) if err != nil { return "", err @@ -148,7 +148,6 @@ func QueryIncentivizedPacketsForChannel( PortId: portID, ChannelId: channelID, }) - if err != nil { return nil, err } @@ -161,7 +160,6 @@ func QueryFeeEnabledChannel(ctx context.Context, chain ibc.Chain, portID, channe PortId: portID, ChannelId: channelID, }) - if err != nil { return false, err } From e31f5d5b9a8ddd375fc6e654b892305a5e45eb16 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 16:21:14 +0700 Subject: [PATCH 07/18] style: renamed query methods --- e2e/tests/core/02-client/client_test.go | 20 +++--- .../core/03-connection/connection_test.go | 4 +- e2e/tests/interchain_accounts/base_test.go | 20 +++--- e2e/tests/interchain_accounts/gov_test.go | 6 +- e2e/tests/interchain_accounts/groups_test.go | 4 +- .../interchain_accounts/incentivized_test.go | 24 +++---- .../interchain_accounts/localhost_test.go | 22 +++--- e2e/tests/interchain_accounts/params_test.go | 4 +- .../interchain_accounts/upgrades_test.go | 28 ++++---- e2e/tests/transfer/authz_test.go | 4 +- e2e/tests/transfer/base_test.go | 18 ++--- e2e/tests/transfer/incentivized_test.go | 46 ++++++------ e2e/tests/transfer/localhost_test.go | 10 +-- e2e/tests/transfer/upgrades_test.go | 48 ++++++------- e2e/tests/upgrades/genesis_test.go | 2 +- e2e/tests/upgrades/upgrade_test.go | 70 +++++++++---------- e2e/tests/wasm/grandpa_test.go | 12 ++-- e2e/testsuite/query/queries.go | 44 ++++++------ e2e/testsuite/testsuite.go | 4 +- 19 files changed, 195 insertions(+), 195 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index d3b6c52c997..6deb6cdcfbc 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -86,11 +86,11 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { var newChainID string t.Run("execute proposal for MsgIBCSoftwareUpgrade", func(t *testing.T) { - authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) - clientState, err := query.QueryClientState(ctx, chainB, ibctesting.FirstClientID) + clientState, err := query.ClientState(ctx, chainB, ibctesting.FirstClientID) s.Require().NoError(err) originalChainID := clientState.(*ibctm.ClientState).ChainId @@ -139,11 +139,11 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { }) t.Run("ensure legacy proposal does not succeed", func(t *testing.T) { - authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) - clientState, err := query.QueryClientState(ctx, chainB, ibctesting.FirstClientID) + clientState, err := query.ClientState(ctx, chainB, ibctesting.FirstClientID) s.Require().NoError(err) originalChainID := clientState.(*ibctm.ClientState).ChainId @@ -313,7 +313,7 @@ func (s *ClientTestSuite) TestRecoverClient_Succeeds() { }) t.Run("execute proposal for MsgRecoverClient", func(t *testing.T) { - authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) recoverClientMsg := clienttypes.NewMsgRecoverClient(authority.String(), subjectClientID, substituteClientID) s.Require().NotNil(recoverClientMsg) @@ -359,7 +359,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { err := relayer.UpdateClients(ctx, s.GetRelayerExecReporter(), s.GetPathName(0)) s.Require().NoError(err) - clientState, err = query.QueryClientState(ctx, chainA, ibctesting.FirstClientID) + clientState, err = query.ClientState(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) }) @@ -375,7 +375,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { err := relayer.UpdateClients(ctx, s.GetRelayerExecReporter(), s.GetPathName(0)) s.Require().NoError(err) - clientState, err = query.QueryClientState(ctx, chainA, ibctesting.FirstClientID) + clientState, err = query.ClientState(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) }) @@ -435,7 +435,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { }) t.Run("ensure client status is frozen", func(t *testing.T) { - status, err := query.QueryClientStatus(ctx, chainA, ibctesting.FirstClientID) + status, err := query.ClientStatus(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Frozen.String(), status) }) @@ -470,7 +470,7 @@ func (s *ClientTestSuite) TestAllowedClientsParam() { allowedClient := ibcexported.Solomachine t.Run("change the allowed client to only allow solomachine clients", func(t *testing.T) { if testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) { - authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) @@ -494,7 +494,7 @@ func (s *ClientTestSuite) TestAllowedClientsParam() { }) t.Run("ensure querying non-allowed client's status returns Unauthorized Status", func(t *testing.T) { - status, err := query.QueryClientStatus(ctx, chainA, ibctesting.FirstClientID) + status, err := query.ClientStatus(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Unauthorized.String(), status) }) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 803a0c7c098..59140da51f8 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -83,7 +83,7 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() { t.Run("change the delay to 60 seconds", func(t *testing.T) { delay := uint64(1 * time.Minute) if testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) { - authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) @@ -126,7 +126,7 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 300eb0e335a..2a80278e9fe 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -156,10 +156,10 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulTransfer(order chan }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = query.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) + _, err = query.Balance(ctx, chainB, hostAccount, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount @@ -210,7 +210,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("fail to execute bank transfer over ICA", func(t *testing.T) { t.Run("verify empty host wallet", func(t *testing.T) { - hostAccountBalance, err := query.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) + hostAccountBalance, err := query.Balance(ctx, chainB, hostAccount, chainB.Config().Denom) s.Require().NoError(err) s.Require().Zero(hostAccountBalance.Int64()) @@ -249,7 +249,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF }) t.Run("verify balance is the same", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount @@ -301,7 +301,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) - _, err = query.QueryChannel(ctx, chainA, portID, initialChannelID) + _, err = query.Channel(ctx, chainA, portID, initialChannelID) s.Require().NoError(err) }) @@ -361,17 +361,17 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop }) t.Run("verify channel is closed due to timeout on ordered channel", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainA, portID, initialChannelID) + channel, err := query.Channel(ctx, chainA, portID, initialChannelID) s.Require().NoError(err) s.Require().Equal(channeltypes.CLOSED, channel.State, "the channel was not in an expected state") }) t.Run("verify tokens not transferred", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = query.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) + _, err = query.Balance(ctx, chainB, hostAccount, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount @@ -390,7 +390,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop }) t.Run("verify new channel is now open and interchain account has been reregistered with the same portID", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainA, portID, channelIDAfterReopening) + channel, err := query.Channel(ctx, chainA, portID, channelIDAfterReopening) s.Require().NoError(err) s.Require().Equal(channeltypes.OPEN, channel.State, "the channel was not in an expected state") @@ -431,7 +431,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index 1774f1c15f7..ded3793b9e1 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -49,7 +49,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) chainBAddress := chainBAccount.FormattedAddress() - govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -110,10 +110,10 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = query.QueryBalance(ctx, chainB, interchainAccAddr, chainB.Config().Denom) + _, err = query.Balance(ctx, chainB, interchainAccAddr, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index 45e9c941b9e..cd22cb3f782 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -199,14 +199,14 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat t.Run("verify tokens transferred", func(t *testing.T) { s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks") - balance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAddress, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount s.Require().Equal(expected, balance.Int64()) - balance, err = query.QueryBalance(ctx, chainB, interchainAccAddr, chainB.Config().Denom) + balance, err = query.Balance(ctx, chainB, interchainAccAddr, chainB.Config().Denom) s.Require().NoError(err) expected = testvalues.StartingTokenAmount - testvalues.IBCTransferAmount diff --git a/e2e/tests/interchain_accounts/incentivized_test.go b/e2e/tests/interchain_accounts/incentivized_test.go index b70779868fa..1dc3a12adef 100644 --- a/e2e/tests/interchain_accounts/incentivized_test.go +++ b/e2e/tests/interchain_accounts/incentivized_test.go @@ -117,13 +117,13 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelOutput.Counterparty.ChannelID) + address, err := query.CounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelOutput.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) t.Run("no incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -165,7 +165,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -180,16 +180,16 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) t.Run("verify interchain account sent tokens", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = query.QueryBalance(ctx, chainB, interchainAcc, chainB.Config().Denom) + _, err = query.Balance(ctx, chainB, interchainAcc, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount @@ -285,13 +285,13 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelOutput.Counterparty.ChannelID) + address, err := query.CounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelOutput.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) t.Run("no incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -334,7 +334,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -349,16 +349,16 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelOutput.PortID, channelOutput.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) t.Run("verify interchain account did not send tokens", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = query.QueryBalance(ctx, chainB, interchainAcc, chainB.Config().Denom) + _, err = query.Balance(ctx, chainB, interchainAcc, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 325463b20a3..38c42aab1d6 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -109,11 +109,11 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( }) t.Run("query localhost interchain accounts channel ends", func(t *testing.T) { - channelEndA, err := query.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + channelEndA, err := query.Channel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndA) - channelEndB, err := query.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + channelEndB, err := query.Channel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndB) @@ -184,7 +184,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom) + balance, err := query.Balance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount @@ -264,11 +264,11 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("query localhost interchain accounts channel ends", func(t *testing.T) { - channelEndA, err := query.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + channelEndA, err := query.Channel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndA) - channelEndB, err := query.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + channelEndB, err := query.Channel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndB) @@ -336,12 +336,12 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("verify localhost interchain accounts channel is closed", func(t *testing.T) { - channelEndA, err := query.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + channelEndA, err := query.Channel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) s.Require().NoError(err) s.Require().Equal(channeltypes.CLOSED, channelEndA.State, "the channel was not in an expected state") - channelEndB, err := query.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + channelEndB, err := query.Channel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().Equal(channeltypes.CLOSED, channelEndB.State, "the channel was not in an expected state") @@ -394,11 +394,11 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("query localhost interchain accounts channel ends", func(t *testing.T) { - channelEndA, err := query.QueryChannel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + channelEndA, err := query.Channel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndA) - channelEndB, err := query.QueryChannel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + channelEndB, err := query.Channel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndB) @@ -410,7 +410,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) - balance, err := query.QueryBalance(ctx, chainA, interchainAccAddress, chainADenom) + balance, err := query.Balance(ctx, chainA, interchainAccAddress, chainADenom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount @@ -469,7 +469,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan t.Run("verify tokens transferred", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId, 1) - balance, err := query.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom) + balance, err := query.Balance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 08bfc3ec4f2..e694bcf38a9 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -68,7 +68,7 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t.Run("disable the controller", func(t *testing.T) { if testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) { - authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) @@ -125,7 +125,7 @@ func (s *InterchainAccountsParamsTestSuite) TestHostEnabledParam() { t.Run("disable the host", func(t *testing.T) { if testvalues.SelfParamsFeatureReleases.IsSupported(chainBVersion) { - authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainB) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainB) s.Require().NoError(err) s.Require().NotNil(authority) diff --git a/e2e/tests/interchain_accounts/upgrades_test.go b/e2e/tests/interchain_accounts/upgrades_test.go index dc0e7cc61cb..7b595a1f7cb 100644 --- a/e2e/tests/interchain_accounts/upgrades_test.go +++ b/e2e/tests/interchain_accounts/upgrades_test.go @@ -83,7 +83,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) - _, err = query.QueryChannel(ctx, chainA, portID, initialChannelID) + _, err = query.Channel(ctx, chainA, portID, initialChannelID) s.Require().NoError(err) }) @@ -130,21 +130,21 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount s.Require().Equal(expected, balance.Int64()) }) - channel, err := query.QueryChannel(ctx, chainA, portID, initialChannelID) + channel, err := query.Channel(ctx, chainA, portID, initialChannelID) s.Require().NoError(err) // upgrade the channel ordering to UNORDERED upgradeFields := channeltypes.NewUpgradeFields(channeltypes.UNORDERED, channel.ConnectionHops, channel.Version) t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) { - govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -155,7 +155,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra t.Run("verify channel A upgraded and is now unordered", func(t *testing.T) { var channel channeltypes.Channel waitErr := test.WaitForCondition(time.Minute*2, time.Second*5, func() (bool, error) { - channel, err = query.QueryChannel(ctx, chainA, portID, initialChannelID) + channel, err = query.Channel(ctx, chainA, portID, initialChannelID) if err != nil { return false, err } @@ -167,7 +167,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra t.Run("verify channel B upgraded and is now unordered", func(t *testing.T) { var channel channeltypes.Channel waitErr := test.WaitForCondition(time.Minute*2, time.Second*5, func() (bool, error) { - channel, err = query.QueryChannel(ctx, chainB, icatypes.HostPortID, initialChannelID) + channel, err = query.Channel(ctx, chainB, icatypes.HostPortID, initialChannelID) if err != nil { return false, err } @@ -209,7 +209,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra }) t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := 2*testvalues.IBCTransferAmount + testvalues.StartingTokenAmount @@ -269,7 +269,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann s.Require().NoError(err) s.Require().NotZero(len(interchainAccount)) - channelA, err = query.QueryChannel(ctx, chainA, controllerPortID, channelID) + channelA, err = query.Channel(ctx, chainA, controllerPortID, channelID) s.Require().NoError(err) }) @@ -280,7 +280,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks") t.Run("verify channel A upgraded and is fee enabled", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainA, controllerPortID, channelID) + channel, err := query.Channel(ctx, chainA, controllerPortID, channelID) s.Require().NoError(err) // check the channel version include the fee version @@ -289,13 +289,13 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainA, controllerPortID, channelID) + feeEnabled, err := query.FeeEnabledChannel(ctx, chainA, controllerPortID, channelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("verify channel B upgraded and is fee enabled", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainB, hostPortID, channelID) + channel, err := query.Channel(ctx, chainB, hostPortID, channelID) s.Require().NoError(err) // check the channel version include the fee version @@ -304,7 +304,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainB, hostPortID, channelID) + feeEnabled, err := query.FeeEnabledChannel(ctx, chainB, hostPortID, channelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) @@ -366,14 +366,14 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann }) t.Run("verify channel A is closed due to timeout on ordered channel", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainA, controllerPortID, channelID) + channel, err := query.Channel(ctx, chainA, controllerPortID, channelID) s.Require().NoError(err) s.Require().Equal(channeltypes.CLOSED, channel.State, "the channel was not in an expected state") }) t.Run("verify channel B is closed due to timeout on ordered channel", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainB, hostPortID, channelID) + channel, err := query.Channel(ctx, chainB, hostPortID, channelID) s.Require().NoError(err) s.Require().Equal(channeltypes.CLOSED, channel.State, "the channel was not in an expected state") diff --git a/e2e/tests/transfer/authz_test.go b/e2e/tests/transfer/authz_test.go index 8e06d45901d..446f27626cf 100644 --- a/e2e/tests/transfer/authz_test.go +++ b/e2e/tests/transfer/authz_test.go @@ -151,7 +151,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() { t.Run("verify receiver wallet amount", func(t *testing.T) { chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID) - actualBalance, err := query.QueryBalance(ctx, chainB, receiverWalletAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, receiverWalletAddress, chainBIBCToken.IBCDenom()) suite.Require().NoError(err) suite.Require().Equal(testvalues.IBCTransferAmount, actualBalance.Int64()) @@ -288,7 +288,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() { t.Run("verify receiver wallet amount", func(t *testing.T) { chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID) - actualBalance, err := query.QueryBalance(ctx, chainB, receiverWalletAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, receiverWalletAddress, chainBIBCToken.IBCDenom()) suite.Require().NoError(err) suite.Require().Equal(int64(0), actualBalance.Int64()) diff --git a/e2e/tests/transfer/base_test.go b/e2e/tests/transfer/base_test.go index b7a18886081..d470890d18c 100644 --- a/e2e/tests/transfer/base_test.go +++ b/e2e/tests/transfer/base_test.go @@ -82,7 +82,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { s.Require().Equal(expected, actualBalance) if testvalues.TotalEscrowFeatureReleases.IsSupported(chainAVersion) { - actualTotalEscrow, err := query.QueryTotalEscrowForDenom(ctx, chainA, chainADenom) + actualTotalEscrow, err := query.TotalEscrowForDenom(ctx, chainA, chainADenom) s.Require().NoError(err) expectedTotalEscrow := sdk.NewCoin(chainADenom, sdkmath.NewInt(testvalues.IBCTransferAmount)) @@ -99,7 +99,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount @@ -118,13 +118,13 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { }) t.Run("tokens are escrowed", func(t *testing.T) { - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) s.Require().Equal(sdkmath.ZeroInt(), actualBalance) if testvalues.TotalEscrowFeatureReleases.IsSupported(chainBVersion) { - actualTotalEscrow, err := query.QueryTotalEscrowForDenom(ctx, chainB, chainBIBCToken.IBCDenom()) + actualTotalEscrow, err := query.TotalEscrowForDenom(ctx, chainB, chainBIBCToken.IBCDenom()) s.Require().NoError(err) s.Require().Equal(sdk.NewCoin(chainBIBCToken.IBCDenom(), sdkmath.NewInt(0)), actualTotalEscrow) // total escrow is zero because sending chain is not source for tokens } @@ -144,7 +144,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { if testvalues.TotalEscrowFeatureReleases.IsSupported(chainAVersion) { t.Run("tokens are un-escrowed", func(t *testing.T) { - actualTotalEscrow, err := query.QueryTotalEscrowForDenom(ctx, chainA, chainADenom) + actualTotalEscrow, err := query.TotalEscrowForDenom(ctx, chainA, chainADenom) s.Require().NoError(err) s.Require().Equal(sdk.NewCoin(chainADenom, sdkmath.NewInt(0)), actualTotalEscrow) // total escrow is zero because tokens have come back }) @@ -263,7 +263,7 @@ func (s *TransferTestSuite) TestSendEnabledParam() { chainAVersion := chainA.Config().Images[0].Version isSelfManagingParams := testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) - govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -326,7 +326,7 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() { chainAVersion := chainA.Config().Images[0].Version isSelfManagingParams := testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) - govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -357,7 +357,7 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) s.Require().NoError(err) @@ -462,7 +462,7 @@ func (s *TransferTestSuite) TestMsgTransfer_WithMemo() { t.Run("packets relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) s.Require().Equal(testvalues.IBCTransferAmount, actualBalance.Int64()) diff --git a/e2e/tests/transfer/incentivized_test.go b/e2e/tests/transfer/incentivized_test.go index 61d7b28ad71..5535f9d37ae 100644 --- a/e2e/tests/transfer/incentivized_test.go +++ b/e2e/tests/transfer/incentivized_test.go @@ -73,7 +73,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Su }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.CounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -100,7 +100,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Su t.Run("pay packet fee", func(t *testing.T) { t.Run("no incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -114,7 +114,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Su }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -139,7 +139,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Su }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -190,7 +190,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.CounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -214,7 +214,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou t.Run("pay packet fee", func(t *testing.T) { t.Run("no incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -228,7 +228,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -253,7 +253,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -311,13 +311,13 @@ func (s *IncentivizedTransferTestSuite) TestMultiMsg_MsgPayPacketFeeSingleSender }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.CounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) t.Run("no incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -328,7 +328,7 @@ func (s *IncentivizedTransferTestSuite) TestMultiMsg_MsgPayPacketFeeSingleSender s.AssertTxSuccess(resp) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -352,7 +352,7 @@ func (s *IncentivizedTransferTestSuite) TestMultiMsg_MsgPayPacketFeeSingleSender }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -409,7 +409,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_SingleSender_TimesOu }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.CounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -440,7 +440,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_SingleSender_TimesOu packetFee := feetypes.NewPacketFee(testFee, chainAWallet.FormattedAddress(), nil) t.Run("no incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -451,7 +451,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_SingleSender_TimesOu }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -476,7 +476,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_SingleSender_TimesOu }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -535,7 +535,7 @@ func (s *IncentivizedTransferTestSuite) TestPayPacketFeeAsync_SingleSender_NoCou t.Run("pay packet fee", func(t *testing.T) { t.Run("no incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -549,7 +549,7 @@ func (s *IncentivizedTransferTestSuite) TestPayPacketFeeAsync_SingleSender_NoCou }) t.Run("should be incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -575,7 +575,7 @@ func (s *IncentivizedTransferTestSuite) TestPayPacketFeeAsync_SingleSender_NoCou t.Run("with no counterparty address", func(t *testing.T) { t.Run("packets are relayed", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -626,7 +626,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncMultipleSenders }) t.Run("verify counterparty payee", func(t *testing.T) { - address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.CounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -653,7 +653,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncMultipleSenders t.Run("pay packet fee", func(t *testing.T) { t.Run("no incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -672,7 +672,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncMultipleSenders }) t.Run("there should be incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee1 := packets[0].PacketFees[0].Fee @@ -720,7 +720,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncMultipleSenders }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) diff --git a/e2e/tests/transfer/localhost_test.go b/e2e/tests/transfer/localhost_test.go index 1631e318c89..77236efaf69 100644 --- a/e2e/tests/transfer/localhost_test.go +++ b/e2e/tests/transfer/localhost_test.go @@ -54,13 +54,13 @@ func (s *LocalhostTransferTestSuite) TestMsgTransfer_Localhost() { s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") t.Run("verify begin blocker was executed", func(t *testing.T) { - cs, err := query.QueryClientState(ctx, chainA, exported.LocalhostClientID) + cs, err := query.ClientState(ctx, chainA, exported.LocalhostClientID) s.Require().NoError(err) originalHeight := cs.GetLatestHeight() s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - cs, err = query.QueryClientState(ctx, chainA, exported.LocalhostClientID) + cs, err = query.ClientState(ctx, chainA, exported.LocalhostClientID) s.Require().NoError(err) s.Require().True(cs.GetLatestHeight().GT(originalHeight), "client state height was not incremented") }) @@ -116,11 +116,11 @@ func (s *LocalhostTransferTestSuite) TestMsgTransfer_Localhost() { }) t.Run("query localhost transfer channel ends", func(t *testing.T) { - channelEndA, err := query.QueryChannel(ctx, chainA, transfertypes.PortID, msgChanOpenInitRes.ChannelId) + channelEndA, err := query.Channel(ctx, chainA, transfertypes.PortID, msgChanOpenInitRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndA) - channelEndB, err := query.QueryChannel(ctx, chainA, transfertypes.PortID, msgChanOpenTryRes.ChannelId) + channelEndB, err := query.Channel(ctx, chainA, transfertypes.PortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndB) @@ -168,7 +168,7 @@ func (s *LocalhostTransferTestSuite) TestMsgTransfer_Localhost() { s.AssertPacketRelayed(ctx, chainA, transfertypes.PortID, msgChanOpenInitRes.ChannelId, 1) ibcToken := testsuite.GetIBCToken(chainADenom, transfertypes.PortID, msgChanOpenTryRes.ChannelId) - actualBalance, err := query.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), ibcToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainA, userBWallet.FormattedAddress(), ibcToken.IBCDenom()) s.Require().NoError(err) diff --git a/e2e/tests/transfer/upgrades_test.go b/e2e/tests/transfer/upgrades_test.go index 72564e1189b..2457590d0c6 100644 --- a/e2e/tests/transfer/upgrades_test.go +++ b/e2e/tests/transfer/upgrades_test.go @@ -81,7 +81,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ }) t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) { - chA, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + chA, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.InitiateChannelUpgrade(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, s.CreateUpgradeFields(chA)) @@ -96,21 +96,21 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ t.Run("packets are relayed between chain A and chain B", func(t *testing.T) { // packet from chain A to chain B s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount s.Require().Equal(expected, actualBalance.Int64()) // packet from chain B to chain A s.AssertPacketRelayed(ctx, chainB, channelB.PortID, channelB.ChannelID, 1) - actualBalance, err = query.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) + actualBalance, err = query.Balance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) s.Require().NoError(err) expected = testvalues.IBCTransferAmount s.Require().Equal(expected, actualBalance.Int64()) }) t.Run("verify channel A upgraded and is fee enabled", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + channel, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -119,13 +119,13 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + feeEnabled, err := query.FeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("verify channel B upgraded and is fee enabled", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + channel, err := query.Channel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -134,14 +134,14 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + feeEnabled, err := query.FeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("prune packet acknowledgements", func(t *testing.T) { // there should be one ack for the packet that we sent before the upgrade - acks, err := query.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) + acks, err := query.PacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) s.Require().NoError(err) s.Require().Len(acks, 1) s.Require().Equal(uint64(1), acks[0].Sequence) @@ -150,7 +150,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.AssertTxSuccess(pruneAcksTxResponse) // after pruning there should not be any acks - acks, err = query.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) + acks, err = query.PacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) s.Require().NoError(err) s.Require().Empty(acks) }) @@ -178,7 +178,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ resp := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress()) s.AssertTxSuccess(resp) - address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.CounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -189,7 +189,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ t.Run("send incentivized transfer packet", func(t *testing.T) { // before adding fees for the packet, there should not be incentivized packets - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) @@ -202,13 +202,13 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) t.Run("tokens are received by walletB", func(t *testing.T) { - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) // walletB has received two IBC transfers of value testvalues.IBCTransferAmount since the start of the test. @@ -270,7 +270,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ wg.Add(1) go func() { defer wg.Done() - chA, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + chA, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.InitiateChannelUpgrade(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, s.CreateUpgradeFields(chA)) }() @@ -278,7 +278,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ wg.Add(1) go func() { defer wg.Done() - chB, err := query.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + chB, err := query.Channel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.InitiateChannelUpgrade(ctx, chainB, chainBWallet, channelB.PortID, channelB.ChannelID, s.CreateUpgradeFields(chB)) }() @@ -294,7 +294,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ }) t.Run("verify channel A upgraded and is fee enabled", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + channel, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -303,13 +303,13 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + feeEnabled, err := query.FeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("verify channel B upgraded and is fee enabled", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + channel, err := query.Channel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -318,7 +318,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + feeEnabled, err := query.FeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) @@ -343,7 +343,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ }) t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) { - chA, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + chA, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.InitiateChannelUpgrade(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, s.CreateUpgradeFields(chA)) @@ -356,26 +356,26 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks") t.Run("verify channel A did not upgrade", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + channel, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Equal(channeltypes.OPEN, channel.State, "the channel state is not OPEN") s.Require().Equal(transfertypes.Version, channel.Version, "the channel version is not ics20-1") - errorReceipt, err := query.QueryUpgradeError(ctx, chainA, channelA.PortID, channelA.ChannelID) + errorReceipt, err := query.UpgradeError(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Equal(uint64(1), errorReceipt.Sequence) s.Require().Contains(errorReceipt.Message, "restored channel to pre-upgrade state") }) t.Run("verify channel B did not upgrade", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + channel, err := query.Channel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.Require().Equal(channeltypes.OPEN, channel.State, "the channel state is not OPEN") s.Require().Equal(transfertypes.Version, channel.Version, "the channel version is not ics20-1") - errorReceipt, err := query.QueryUpgradeError(ctx, chainB, channelB.PortID, channelB.ChannelID) + errorReceipt, err := query.UpgradeError(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.Require().Equal(uint64(1), errorReceipt.Sequence) s.Require().Contains(errorReceipt.Message, "restored channel to pre-upgrade state") diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index 02e1d7c1466..389058d8150 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -104,7 +104,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics20: packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) diff --git a/e2e/tests/upgrades/upgrade_test.go b/e2e/tests/upgrades/upgrade_test.go index 90e2eac0e17..1f740973f84 100644 --- a/e2e/tests/upgrades/upgrade_test.go +++ b/e2e/tests/upgrades/upgrade_test.go @@ -163,7 +163,7 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) @@ -191,7 +191,7 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 2) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) @@ -210,7 +210,7 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) s.Require().NoError(err) @@ -241,7 +241,7 @@ func (s *UpgradeTestSuite) TestChainUpgrade() { }) t.Run("verify tokens sent", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chain, userWalletAddr, chain.Config().Denom) + balance, err := query.Balance(ctx, chain, userWalletAddr, chain.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount * 2 @@ -265,7 +265,7 @@ func (s *UpgradeTestSuite) TestChainUpgrade() { }) t.Run("verify tokens sent", func(t *testing.T) { - balance, err := query.QueryBalance(ctx, chain, userWalletAddr, chain.Config().Denom) + balance, err := query.Balance(ctx, chain, userWalletAddr, chain.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount * 3 @@ -307,11 +307,11 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") t.Run("check that both tendermint clients are active", func(t *testing.T) { - status, err := query.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(0)) + status, err := query.ClientStatus(ctx, chainA, testvalues.TendermintClientID(0)) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) - status, err = query.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(1)) + status, err = query.ClientStatus(ctx, chainA, testvalues.TendermintClientID(1)) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) }) @@ -346,7 +346,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { s.AssertTxSuccess(resp) t.Run("check that the solomachine is now active and that the clientstate is a pre-upgrade v2 solomachine clientstate", func(t *testing.T) { - status, err := query.QueryClientStatus(ctx, chainA, testvalues.SolomachineClientID(2)) + status, err := query.ClientStatus(ctx, chainA, testvalues.SolomachineClientID(2)) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) @@ -377,7 +377,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount @@ -401,11 +401,11 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { } t.Run("check that the tendermint clients are active again after upgrade", func(t *testing.T) { - status, err := query.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(0)) + status, err := query.ClientStatus(ctx, chainA, testvalues.TendermintClientID(0)) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) - status, err = query.QueryClientStatus(ctx, chainA, testvalues.TendermintClientID(1)) + status, err = query.ClientStatus(ctx, chainA, testvalues.TendermintClientID(1)) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) }) @@ -418,7 +418,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { t.Run("packets are relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount * 2 @@ -472,7 +472,7 @@ func (s *UpgradeTestSuite) TestV7ToV7_1ChainUpgrade() { t.Run("packet is relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount @@ -487,7 +487,7 @@ func (s *UpgradeTestSuite) TestV7ToV7_1ChainUpgrade() { }) t.Run("ensure the localhost client is active and sentinel connection is stored in state", func(t *testing.T) { - status, err := query.QueryClientStatus(ctx, chainA, exported.LocalhostClientID) + status, err := query.ClientStatus(ctx, chainA, exported.LocalhostClientID) s.Require().NoError(err) s.Require().Equal(exported.Active.String(), status) @@ -500,7 +500,7 @@ func (s *UpgradeTestSuite) TestV7ToV7_1ChainUpgrade() { }) t.Run("ensure escrow amount for native denom is stored in state", func(t *testing.T) { - actualTotalEscrow, err := query.QueryTotalEscrowForDenom(ctx, chainA, chainADenom) + actualTotalEscrow, err := query.TotalEscrowForDenom(ctx, chainA, chainADenom) s.Require().NoError(err) expectedTotalEscrow := sdk.NewCoin(chainADenom, sdkmath.NewInt(testvalues.IBCTransferAmount)) @@ -563,7 +563,7 @@ func (s *UpgradeTestSuite) TestV7ToV8ChainUpgrade() { t.Run("packet is relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount @@ -578,7 +578,7 @@ func (s *UpgradeTestSuite) TestV7ToV8ChainUpgrade() { }) t.Run("update params", func(t *testing.T) { - authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainB) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainB) s.Require().NoError(err) s.Require().NotNil(authority) @@ -649,7 +649,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { t.Run("pay packet fee", func(t *testing.T) { t.Run("no packet fees in escrow", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) @@ -664,7 +664,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { }) t.Run("query incentivized packets", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -693,7 +693,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { s.Require().Equal(expected, actualBalance) // query incentivised packets and assert calculated values are correct - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Len(packets, 1) actualFee := packets[0].PacketFees[0].Fee @@ -702,7 +702,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { s.Require().True(actualFee.AckFee.Equal(testFee.AckFee)) s.Require().True(actualFee.TimeoutFee.Equal(testFee.TimeoutFee)) - escrowBalance, err := query.QueryBalance(ctx, chainA, authtypes.NewModuleAddress(feetypes.ModuleName).String(), chainADenom) + escrowBalance, err := query.Balance(ctx, chainA, authtypes.NewModuleAddress(feetypes.ModuleName).String(), chainADenom) s.Require().NoError(err) expected = testFee.Total().AmountOf(chainADenom).Int64() @@ -718,7 +718,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { t.Run("packet is relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount @@ -844,7 +844,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { }) t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) { - chA, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + chA, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.InitiateChannelUpgrade(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, s.CreateUpgradeFields(chA)) @@ -858,20 +858,20 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { t.Run("packets are relayed between chain A and chain B", func(t *testing.T) { // packet from chain A to chain B - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) expected := testvalues.IBCTransferAmount s.Require().Equal(expected, actualBalance.Int64()) // packet from chain B to chain A - actualBalance, err = query.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) + actualBalance, err = query.Balance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom()) s.Require().NoError(err) expected = testvalues.IBCTransferAmount s.Require().Equal(expected, actualBalance.Int64()) }) t.Run("verify channel A upgraded and is fee enabled", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + channel, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -880,13 +880,13 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + feeEnabled, err := query.FeeEnabledChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("verify channel B upgraded and is fee enabled", func(t *testing.T) { - channel, err := query.QueryChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + channel, err := query.Channel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) // check the channel version include the fee version @@ -895,14 +895,14 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { s.Require().Equal(feetypes.Version, version.FeeVersion, "the channel version did not include ics29") // extra check - feeEnabled, err := query.QueryFeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) + feeEnabled, err := query.FeeEnabledChannel(ctx, chainB, channelB.PortID, channelB.ChannelID) s.Require().NoError(err) s.Require().Equal(true, feeEnabled) }) t.Run("prune packet acknowledgements", func(t *testing.T) { // there should be one ack for the packet that we sent before the upgrade - acks, err := query.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) + acks, err := query.PacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) s.Require().NoError(err) s.Require().Len(acks, 1) s.Require().Equal(uint64(1), acks[0].Sequence) @@ -911,7 +911,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { s.AssertTxSuccess(pruneAcksTxResponse) // after pruning there should not be any acks - acks, err = query.QueryPacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) + acks, err = query.PacketAcknowledgements(ctx, chainA, channelA.PortID, channelA.ChannelID, []uint64{}) s.Require().NoError(err) s.Require().Empty(acks) }) @@ -939,7 +939,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { resp := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress()) s.AssertTxSuccess(resp) - address, err := query.QueryCounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) + address, err := query.CounterPartyPayee(ctx, chainB, chainBRelayerWallet.FormattedAddress(), channelA.Counterparty.ChannelID) s.Require().NoError(err) s.Require().Equal(chainARelayerWallet.FormattedAddress(), address) }) @@ -950,7 +950,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { t.Run("send incentivized transfer packet", func(t *testing.T) { // before adding fees for the packet, there should not be incentivized packets - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) @@ -972,13 +972,13 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { }) t.Run("packets are relayed", func(t *testing.T) { - packets, err := query.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) + packets, err := query.IncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) s.Require().NoError(err) s.Require().Empty(packets) }) t.Run("tokens are received by walletB", func(t *testing.T) { - actualBalance, err := query.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) + actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) // walletB has received two IBC transfers of value testvalues.IBCTransferAmount since the start of the test. diff --git a/e2e/tests/wasm/grandpa_test.go b/e2e/tests/wasm/grandpa_test.go index 09da0ffb226..c7cfc6995f6 100644 --- a/e2e/tests/wasm/grandpa_test.go +++ b/e2e/tests/wasm/grandpa_test.go @@ -403,7 +403,7 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_Success_GrandpaContract() { s.ExecuteAndPassGovV1Proposal(ctx, message, cosmosChain, cosmosWallet) - clientState, err := query.QueryClientState(ctx, cosmosChain, defaultWasmClientID) + clientState, err := query.ClientState(ctx, cosmosChain, defaultWasmClientID) s.Require().NoError(err) wasmClientState, ok := clientState.(*wasmtypes.ClientState) @@ -574,19 +574,19 @@ func (s *GrandpaTestSuite) TestRecoverClient_Succeeds_GrandpaContract() { s.Require().NoError(err) // ensure subject client is expired - status, err := query.QueryClientStatus(ctx, cosmosChain, subjectClientID) + status, err := query.ClientStatus(ctx, cosmosChain, subjectClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Expired.String(), status, "unexpected subject client status") // ensure substitute client is active - status, err = query.QueryClientStatus(ctx, cosmosChain, substituteClientID) + status, err = query.ClientStatus(ctx, cosmosChain, substituteClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status, "unexpected substitute client status") version := cosmosChain.Nodes()[0].Image.Version if govV1FeatureReleases.IsSupported(version) { // create and execute a client recovery proposal - authority, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, cosmosChain) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, cosmosChain) s.Require().NoError(err) msgRecoverClient := clienttypes.NewMsgRecoverClient(authority.String(), subjectClientID, substituteClientID) @@ -598,12 +598,12 @@ func (s *GrandpaTestSuite) TestRecoverClient_Succeeds_GrandpaContract() { } // ensure subject client is active - status, err = query.QueryClientStatus(ctx, cosmosChain, subjectClientID) + status, err = query.ClientStatus(ctx, cosmosChain, subjectClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) // ensure substitute client is active - status, err = query.QueryClientStatus(ctx, cosmosChain, substituteClientID) + status, err = query.ClientStatus(ctx, cosmosChain, substituteClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) } diff --git a/e2e/testsuite/query/queries.go b/e2e/testsuite/query/queries.go index dd5d93781d1..fab156eeeae 100644 --- a/e2e/testsuite/query/queries.go +++ b/e2e/testsuite/query/queries.go @@ -22,9 +22,9 @@ import ( ibctesting "github.com/cosmos/ibc-go/v8/testing" ) -// QueryModuleAccountAddress returns the address of the given module on the given chain. +// ModuleAccountAddress returns the address of the given module on the given chain. // Added because interchaintest's method doesn't work. -func QueryModuleAccountAddress(ctx context.Context, moduleName string, chain ibc.Chain) (sdk.AccAddress, error) { +func ModuleAccountAddress(ctx context.Context, moduleName string, chain ibc.Chain) (sdk.AccAddress, error) { modAccResp, err := GRPCQuery[authtypes.QueryModuleAccountByNameResponse]( ctx, chain, &authtypes.QueryModuleAccountByNameRequest{Name: moduleName}, ) @@ -50,8 +50,8 @@ func QueryModuleAccountAddress(ctx context.Context, moduleName string, chain ibc return govAccount.GetAddress(), nil } -// QueryClientState queries the client state on the given chain for the provided clientID. -func QueryClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexported.ClientState, error) { +// ClientState queries the client state on the given chain for the provided clientID. +func ClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexported.ClientState, error) { clientStateResp, err := GRPCQuery[clienttypes.QueryClientStateResponse](ctx, chain, &clienttypes.QueryClientStateRequest{ ClientId: ibctesting.FirstClientID, }) @@ -69,8 +69,8 @@ func QueryClientState(ctx context.Context, chain ibc.Chain, clientID string) (ib return clientState, nil } -// QueryClientStatus queries the status of the client by clientID -func QueryClientStatus(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { +// ClientStatus queries the status of the client by clientID +func ClientStatus(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { clientStatusResp, err := GRPCQuery[clienttypes.QueryClientStatusResponse](ctx, chain, &clienttypes.QueryClientStatusRequest{ ClientId: clientID, }) @@ -98,8 +98,8 @@ func GetValidatorSetByHeight(ctx context.Context, chain ibc.Chain, height uint64 return res.Validators, nil } -// QueryBalance returns the balance of a specific denomination for a given account by address. -func QueryBalance(ctx context.Context, chain ibc.Chain, address string, denom string) (math.Int, error) { +// Balance returns the balance of a specific denomination for a given account by address. +func Balance(ctx context.Context, chain ibc.Chain, address string, denom string) (math.Int, error) { res, err := GRPCQuery[banktypes.QueryBalanceResponse](ctx, chain, &banktypes.QueryBalanceRequest{ Address: address, Denom: denom, @@ -111,8 +111,8 @@ func QueryBalance(ctx context.Context, chain ibc.Chain, address string, denom st return res.Balance.Amount, nil } -// QueryChannel queries the channel on a given chain for the provided portID and channelID -func QueryChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.Channel, error) { +// Channel queries the channel on a given chain for the provided portID and channelID +func Channel(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.Channel, error) { res, err := GRPCQuery[channeltypes.QueryChannelResponse](ctx, chain, &channeltypes.QueryChannelRequest{ PortId: portID, ChannelId: channelID, @@ -124,8 +124,8 @@ func QueryChannel(ctx context.Context, chain ibc.Chain, portID, channelID string return *res.Channel, nil } -// QueryCounterPartyPayee queries the counterparty payee of the given chain and relayer address on the specified channel. -func QueryCounterPartyPayee(ctx context.Context, chain ibc.Chain, relayerAddress, channelID string) (string, error) { +// CounterPartyPayee queries the counterparty payee of the given chain and relayer address on the specified channel. +func CounterPartyPayee(ctx context.Context, chain ibc.Chain, relayerAddress, channelID string) (string, error) { res, err := GRPCQuery[feetypes.QueryCounterpartyPayeeResponse](ctx, chain, &feetypes.QueryCounterpartyPayeeRequest{ ChannelId: channelID, Relayer: relayerAddress, @@ -137,8 +137,8 @@ func QueryCounterPartyPayee(ctx context.Context, chain ibc.Chain, relayerAddress return res.CounterpartyPayee, nil } -// QueryIncentivizedPacketsForChannel queries the incentivized packets on the specified channel. -func QueryIncentivizedPacketsForChannel( +// IncentivizedPacketsForChannel queries the incentivized packets on the specified channel. +func IncentivizedPacketsForChannel( ctx context.Context, chain ibc.Chain, portID, @@ -154,8 +154,8 @@ func QueryIncentivizedPacketsForChannel( return res.IncentivizedPackets, err } -// QueryFeeEnabledChannel queries the fee-enabled status of a channel. -func QueryFeeEnabledChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (bool, error) { +// FeeEnabledChannel queries the fee-enabled status of a channel. +func FeeEnabledChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (bool, error) { res, err := GRPCQuery[feetypes.QueryFeeEnabledChannelResponse](ctx, chain, &feetypes.QueryFeeEnabledChannelRequest{ PortId: portID, ChannelId: channelID, @@ -166,8 +166,8 @@ func QueryFeeEnabledChannel(ctx context.Context, chain ibc.Chain, portID, channe return res.FeeEnabled, nil } -// QueryTotalEscrowForDenom queries the total amount of tokens in escrow for a denom -func QueryTotalEscrowForDenom(ctx context.Context, chain ibc.Chain, denom string) (sdk.Coin, error) { +// TotalEscrowForDenom queries the total amount of tokens in escrow for a denom +func TotalEscrowForDenom(ctx context.Context, chain ibc.Chain, denom string) (sdk.Coin, error) { res, err := GRPCQuery[transfertypes.QueryTotalEscrowForDenomResponse](ctx, chain, &transfertypes.QueryTotalEscrowForDenomRequest{ Denom: denom, }) @@ -178,8 +178,8 @@ func QueryTotalEscrowForDenom(ctx context.Context, chain ibc.Chain, denom string return res.Amount, nil } -// QueryPacketAcknowledgements queries the packet acknowledgements on the given chain for the provided channel (optional) list of packet commitment sequences. -func QueryPacketAcknowledgements(ctx context.Context, chain ibc.Chain, portID, channelID string, packetCommitmentSequences []uint64) ([]*channeltypes.PacketState, error) { +// PacketAcknowledgements queries the packet acknowledgements on the given chain for the provided channel (optional) list of packet commitment sequences. +func PacketAcknowledgements(ctx context.Context, chain ibc.Chain, portID, channelID string, packetCommitmentSequences []uint64) ([]*channeltypes.PacketState, error) { res, err := GRPCQuery[channeltypes.QueryPacketAcknowledgementsResponse](ctx, chain, &channeltypes.QueryPacketAcknowledgementsRequest{ PortId: portID, ChannelId: channelID, @@ -192,8 +192,8 @@ func QueryPacketAcknowledgements(ctx context.Context, chain ibc.Chain, portID, c return res.Acknowledgements, nil } -// QueryUpgradeError queries the upgrade error on the given chain for the provided channel. -func QueryUpgradeError(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.ErrorReceipt, error) { +// UpgradeError queries the upgrade error on the given chain for the provided channel. +func UpgradeError(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.ErrorReceipt, error) { res, err := GRPCQuery[channeltypes.QueryUpgradeErrorResponse](ctx, chain, &channeltypes.QueryUpgradeErrorRequest{ PortId: portID, ChannelId: channelID, diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index dce6c2dd9de..3aaf1ac598c 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -451,7 +451,7 @@ func (s *E2ETestSuite) CreateUpgradeFields(channel channeltypes.Channel) channel // SetUpgradeTimeoutParam creates and submits a governance proposal to execute the message to update 04-channel params with a timeout of 1s func (s *E2ETestSuite) SetUpgradeTimeoutParam(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet) { const timeoutDelta = 1000000000 // use 1 second as relative timeout to force upgrade timeout on the counterparty - govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chain) + govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chain) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -462,7 +462,7 @@ func (s *E2ETestSuite) SetUpgradeTimeoutParam(ctx context.Context, chain ibc.Cha // InitiateChannelUpgrade creates and submits a governance proposal to execute the message to initiate a channel upgrade func (s *E2ETestSuite) InitiateChannelUpgrade(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet, portID, channelID string, upgradeFields channeltypes.UpgradeFields) { - govModuleAddress, err := query.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chain) + govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chain) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) From 537dc2466d9387f7acb651c861b22fbef586ed6c Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 16:24:23 +0700 Subject: [PATCH 08/18] refactor: fix more golangci-lint errors --- e2e/tests/core/02-client/client_test.go | 28 ++++++------------- .../core/03-connection/connection_test.go | 1 + e2e/tests/upgrades/upgrade_test.go | 2 +- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 6deb6cdcfbc..e3725fc9c73 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -52,18 +52,6 @@ type ClientTestSuite struct { testsuite.E2ETestSuite } -// Status queries the current status of the client -func (s *ClientTestSuite) Status(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { - res, err := query.GRPCQuery[clienttypes.QueryClientStatusResponse](ctx, chain, &clienttypes.QueryClientStatusRequest{ - ClientId: clientID, - }) - if err != nil { - return "", err - } - - return res.Status, nil -} - // QueryAllowedClients queries the on-chain AllowedClients parameter for 02-client func (s *ClientTestSuite) QueryAllowedClients(ctx context.Context, chain ibc.Chain) []string { res, err := query.GRPCQuery[clienttypes.QueryClientParamsResponse](ctx, chain, &clienttypes.QueryClientParamsRequest{}) @@ -217,13 +205,13 @@ func (s *ClientTestSuite) TestClientUpdateProposal_Succeeds() { t.Run("check status of each client", func(t *testing.T) { t.Run("substitute should be active", func(t *testing.T) { - status, err := s.Status(ctx, chainA, substituteClientID) + status, err := query.ClientStatus(ctx, chainA, substituteClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) }) t.Run("subject should be expired", func(t *testing.T) { - status, err := s.Status(ctx, chainA, subjectClientID) + status, err := query.ClientStatus(ctx, chainA, subjectClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Expired.String(), status) }) @@ -236,13 +224,13 @@ func (s *ClientTestSuite) TestClientUpdateProposal_Succeeds() { t.Run("check status of each client", func(t *testing.T) { t.Run("substitute should be active", func(t *testing.T) { - status, err := s.Status(ctx, chainA, substituteClientID) + status, err := query.ClientStatus(ctx, chainA, substituteClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) }) t.Run("subject should be active", func(t *testing.T) { - status, err := s.Status(ctx, chainA, subjectClientID) + status, err := query.ClientStatus(ctx, chainA, subjectClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) }) @@ -300,13 +288,13 @@ func (s *ClientTestSuite) TestRecoverClient_Succeeds() { t.Run("check status of each client", func(t *testing.T) { t.Run("substitute should be active", func(t *testing.T) { - status, err := s.Status(ctx, chainA, substituteClientID) + status, err := query.ClientStatus(ctx, chainA, substituteClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) }) t.Run("subject should be expired", func(t *testing.T) { - status, err := s.Status(ctx, chainA, subjectClientID) + status, err := query.ClientStatus(ctx, chainA, subjectClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Expired.String(), status) }) @@ -322,13 +310,13 @@ func (s *ClientTestSuite) TestRecoverClient_Succeeds() { t.Run("check status of each client", func(t *testing.T) { t.Run("substitute should be active", func(t *testing.T) { - status, err := s.Status(ctx, chainA, substituteClientID) + status, err := query.ClientStatus(ctx, chainA, substituteClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) }) t.Run("subject should be active", func(t *testing.T) { - status, err := s.Status(ctx, chainA, subjectClientID) + status, err := query.ClientStatus(ctx, chainA, subjectClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) }) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 59140da51f8..e9a8cab12ad 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -45,6 +45,7 @@ func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Cont Subspace: ibcexported.ModuleName, Key: string(connectiontypes.KeyMaxExpectedTimePerBlock), }) + s.Require().NoError(err) // removing additional strings that are used for amino delay := strings.ReplaceAll(res.Param.Value, "\"", "") diff --git a/e2e/tests/upgrades/upgrade_test.go b/e2e/tests/upgrades/upgrade_test.go index 1f740973f84..7877cff08dd 100644 --- a/e2e/tests/upgrades/upgrade_test.go +++ b/e2e/tests/upgrades/upgrade_test.go @@ -996,7 +996,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { } // ClientState queries the current ClientState by clientID -func (s *UpgradeTestSuite) ClientState(ctx context.Context, chain ibc.Chain, clientID string) (*clienttypes.QueryClientStateResponse, error) { +func (*UpgradeTestSuite) ClientState(ctx context.Context, chain ibc.Chain, clientID string) (*clienttypes.QueryClientStateResponse, error) { res, err := query.GRPCQuery[clienttypes.QueryClientStateResponse](ctx, chain, &clienttypes.QueryClientStateRequest{ClientId: clientID}) if err != nil { return res, err From 31af2a1efe2efc0463d28f786095141b61d1da47 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 16:55:55 +0700 Subject: [PATCH 09/18] e2e: attempted fix of client state query --- e2e/testsuite/query/queries.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/e2e/testsuite/query/queries.go b/e2e/testsuite/query/queries.go index fab156eeeae..5cd30512256 100644 --- a/e2e/testsuite/query/queries.go +++ b/e2e/testsuite/query/queries.go @@ -61,7 +61,9 @@ func ClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexpo clientStateAny := clientStateResp.ClientState - clientState, err := clienttypes.UnpackClientState(clientStateAny) + cfg := chain.Config().EncodingConfig + var clientState ibcexported.ClientState + err = cfg.InterfaceRegistry.UnpackAny(clientStateAny, &clientState) if err != nil { return nil, err } From c81e897b5ee3e8404db5fc1f6f0c8d431c9564e5 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 17:11:10 +0700 Subject: [PATCH 10/18] test: fix and refactor --- e2e/tests/interchain_accounts/base_test.go | 19 +++------------- e2e/tests/interchain_accounts/gov_test.go | 2 +- e2e/tests/interchain_accounts/groups_test.go | 2 +- .../interchain_accounts/incentivized_test.go | 4 ++-- .../interchain_accounts/localhost_test.go | 12 +++++----- .../interchain_accounts/upgrades_test.go | 4 ++-- e2e/testsuite/query/queries.go | 22 ++++++++++++------- 7 files changed, 29 insertions(+), 36 deletions(-) diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 2a80278e9fe..1ec9c79494d 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -42,19 +42,6 @@ type InterchainAccountsTestSuite struct { testsuite.E2ETestSuite } -// QueryInterchainAccount queries the interchain account for the given owner and connectionID. -func QueryInterchainAccount(ctx context.Context, chain ibc.Chain, address, connectionID string) (string, error) { - res, err := query.GRPCQuery[controllertypes.QueryInterchainAccountResponse](ctx, chain, &controllertypes.QueryInterchainAccountRequest{ - Owner: address, - ConnectionId: connectionID, - }) - if err != nil { - return "", err - } - - return res.Address, nil -} - // RegisterInterchainAccount will attempt to register an interchain account on the counterparty chain. func (s *InterchainAccountsTestSuite) RegisterInterchainAccount(ctx context.Context, chain ibc.Chain, user ibc.Wallet, msgRegisterAccount *controllertypes.MsgRegisterInterchainAccount) { txResp := s.BroadcastMessages(ctx, chain, user, msgRegisterAccount) @@ -100,7 +87,7 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulTransfer(order chan t.Run("verify interchain account", func(t *testing.T) { var err error - hostAccount, err = QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + hostAccount, err = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) @@ -199,7 +186,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("verify interchain account", func(t *testing.T) { var err error - hostAccount, err = QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + hostAccount, err = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) @@ -297,7 +284,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop t.Run("verify interchain account", func(t *testing.T) { var err error - hostAccount, err = QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + hostAccount, err = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index ded3793b9e1..11cb8d358ab 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -68,7 +68,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() var interchainAccAddr string t.Run("verify interchain account registration success", func(t *testing.T) { var err error - interchainAccAddr, err = QueryInterchainAccount(ctx, chainA, govModuleAddress.String(), ibctesting.FirstConnectionID) + interchainAccAddr, err = query.InterchainAccount(ctx, chainA, govModuleAddress.String(), ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddr)) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index cd22cb3f782..2d1c51cda4b 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -141,7 +141,7 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat }) t.Run("verify interchain account registration success", func(t *testing.T) { - interchainAccAddr, err = QueryInterchainAccount(ctx, chainA, groupPolicyAddr, ibctesting.FirstConnectionID) + interchainAccAddr, err = query.InterchainAccount(ctx, chainA, groupPolicyAddr, ibctesting.FirstConnectionID) s.Require().NotEmpty(interchainAccAddr) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/incentivized_test.go b/e2e/tests/interchain_accounts/incentivized_test.go index 1dc3a12adef..fb98fe3e89d 100644 --- a/e2e/tests/interchain_accounts/incentivized_test.go +++ b/e2e/tests/interchain_accounts/incentivized_test.go @@ -86,7 +86,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe var channelOutput ibc.ChannelOutput t.Run("verify interchain account", func(t *testing.T) { var err error - interchainAcc, err = QueryInterchainAccount(ctx, chainA, controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID) + interchainAcc, err = query.InterchainAccount(ctx, chainA, controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAcc)) @@ -264,7 +264,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I var channelOutput ibc.ChannelOutput t.Run("verify interchain account", func(t *testing.T) { var err error - interchainAcc, err = QueryInterchainAccount(ctx, chainA, controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID) + interchainAcc, err = query.InterchainAccount(ctx, chainA, controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAcc)) diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 38c42aab1d6..232aa05a48c 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -121,7 +121,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( }) t.Run("verify interchain account registration and deposit funds", func(t *testing.T) { - interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) @@ -135,7 +135,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( }) t.Run("send packet localhost interchain accounts", func(t *testing.T) { - interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) @@ -276,7 +276,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("verify interchain account registration and deposit funds", func(t *testing.T) { - interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) @@ -290,7 +290,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("send localhost interchain accounts packet with timeout", func(t *testing.T) { - interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) @@ -406,7 +406,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("verify interchain account and existing balance", func(t *testing.T) { - interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) @@ -418,7 +418,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan }) t.Run("send packet localhost interchain accounts", func(t *testing.T) { - interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccAddress)) diff --git a/e2e/tests/interchain_accounts/upgrades_test.go b/e2e/tests/interchain_accounts/upgrades_test.go index 7b595a1f7cb..211c9a50073 100644 --- a/e2e/tests/interchain_accounts/upgrades_test.go +++ b/e2e/tests/interchain_accounts/upgrades_test.go @@ -79,7 +79,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra t.Run("verify interchain account", func(t *testing.T) { var err error - hostAccount, err = QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + hostAccount, err = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) @@ -265,7 +265,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann t.Run("verify interchain account", func(t *testing.T) { var err error - interchainAccount, err = QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + interchainAccount, err = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccount)) diff --git a/e2e/testsuite/query/queries.go b/e2e/testsuite/query/queries.go index 5cd30512256..8ed8a09012b 100644 --- a/e2e/testsuite/query/queries.go +++ b/e2e/testsuite/query/queries.go @@ -14,12 +14,12 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" - ibctesting "github.com/cosmos/ibc-go/v8/testing" ) // ModuleAccountAddress returns the address of the given module on the given chain. @@ -53,7 +53,7 @@ func ModuleAccountAddress(ctx context.Context, moduleName string, chain ibc.Chai // ClientState queries the client state on the given chain for the provided clientID. func ClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexported.ClientState, error) { clientStateResp, err := GRPCQuery[clienttypes.QueryClientStateResponse](ctx, chain, &clienttypes.QueryClientStateRequest{ - ClientId: ibctesting.FirstClientID, + ClientId: clientID, }) if err != nil { return nil, err @@ -79,7 +79,6 @@ func ClientStatus(ctx context.Context, chain ibc.Chain, clientID string) (string if err != nil { return "", err } - return clientStatusResp.Status, nil } @@ -109,7 +108,6 @@ func Balance(ctx context.Context, chain ibc.Chain, address string, denom string) if err != nil { return math.Int{}, err } - return res.Balance.Amount, nil } @@ -122,7 +120,6 @@ func Channel(ctx context.Context, chain ibc.Chain, portID, channelID string) (ch if err != nil { return channeltypes.Channel{}, err } - return *res.Channel, nil } @@ -135,7 +132,6 @@ func CounterPartyPayee(ctx context.Context, chain ibc.Chain, relayerAddress, cha if err != nil { return "", err } - return res.CounterpartyPayee, nil } @@ -176,7 +172,6 @@ func TotalEscrowForDenom(ctx context.Context, chain ibc.Chain, denom string) (sd if err != nil { return sdk.Coin{}, err } - return res.Amount, nil } @@ -190,7 +185,6 @@ func PacketAcknowledgements(ctx context.Context, chain ibc.Chain, portID, channe if err != nil { return nil, err } - return res.Acknowledgements, nil } @@ -205,3 +199,15 @@ func UpgradeError(ctx context.Context, chain ibc.Chain, portID, channelID string } return res.ErrorReceipt, nil } + +// InterchainAccount queries the interchain account for the given owner and connectionID. +func InterchainAccount(ctx context.Context, chain ibc.Chain, address, connectionID string) (string, error) { + res, err := GRPCQuery[controllertypes.QueryInterchainAccountResponse](ctx, chain, &controllertypes.QueryInterchainAccountRequest{ + Owner: address, + ConnectionId: connectionID, + }) + if err != nil { + return "", err + } + return res.Address, nil +} From ea357db3bcd994e566f2ee1623189ef9e6a115a8 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 18:08:47 +0700 Subject: [PATCH 11/18] test: attempted fix of cmttypes --- e2e/testsuite/query/grpc_query.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/e2e/testsuite/query/grpc_query.go b/e2e/testsuite/query/grpc_query.go index 3a05266583c..2d6e8ac251d 100644 --- a/e2e/testsuite/query/grpc_query.go +++ b/e2e/testsuite/query/grpc_query.go @@ -41,13 +41,20 @@ func GRPCQuery[T any](ctx context.Context, chain ibc.Chain, req proto.Message, o func getProtoPath(req proto.Message) (string, error) { typeURL := "/" + proto.MessageName(req) - queryIndex := strings.Index(typeURL, "Query") + serviceString := "Query" + // If the typeURL does not contain "Query", try "Service" + if !strings.Contains(typeURL, serviceString) { + // This exception is added for cmttypes + serviceString = "Service" + } + + queryIndex := strings.Index(typeURL, serviceString) if queryIndex == -1 { return "", fmt.Errorf("invalid typeURL: %s", typeURL) } // Add to the index to account for the length of "Query" - queryIndex += len("Query") + queryIndex += len(serviceString) // Add a slash before the query urlWithSlash := typeURL[:queryIndex] + "/" + typeURL[queryIndex:] From d88dd4ae14b610fbf2c7811fba4d23f929758809 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 18:32:40 +0700 Subject: [PATCH 12/18] imp: fixed queries for cmttypes --- e2e/testsuite/query/grpc_query.go | 39 +++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/e2e/testsuite/query/grpc_query.go b/e2e/testsuite/query/grpc_query.go index 2d6e8ac251d..55232f37e41 100644 --- a/e2e/testsuite/query/grpc_query.go +++ b/e2e/testsuite/query/grpc_query.go @@ -41,25 +41,44 @@ func GRPCQuery[T any](ctx context.Context, chain ibc.Chain, req proto.Message, o func getProtoPath(req proto.Message) (string, error) { typeURL := "/" + proto.MessageName(req) - serviceString := "Query" - // If the typeURL does not contain "Query", try "Service" - if !strings.Contains(typeURL, serviceString) { - // This exception is added for cmttypes - serviceString = "Service" + switch { + case strings.Contains(typeURL, "Query"): + return getQueryProtoPath(typeURL) + case strings.Contains(typeURL, "cosmos.base.tendermint"): + return getCmtProtoPath(typeURL) + default: + return "", fmt.Errorf("unsupported typeURL: %s", typeURL) } +} - queryIndex := strings.Index(typeURL, serviceString) +func getQueryProtoPath(queryTypeURL string) (string, error) { + queryIndex := strings.Index(queryTypeURL, "Query") if queryIndex == -1 { - return "", fmt.Errorf("invalid typeURL: %s", typeURL) + return "", fmt.Errorf("invalid typeURL: %s", queryTypeURL) } // Add to the index to account for the length of "Query" - queryIndex += len(serviceString) + queryIndex += len("Query") // Add a slash before the query - urlWithSlash := typeURL[:queryIndex] + "/" + typeURL[queryIndex:] + urlWithSlash := queryTypeURL[:queryIndex] + "/" + queryTypeURL[queryIndex:] + if !strings.HasSuffix(urlWithSlash, "Request") { + return "", fmt.Errorf("invalid typeURL: %s", queryTypeURL) + } + + return strings.TrimSuffix(urlWithSlash, "Request"), nil +} + +func getCmtProtoPath(cmtTypeURL string) (string, error) { + cmtIndex := strings.Index(cmtTypeURL, "Get") + if cmtIndex == -1 { + return "", fmt.Errorf("invalid typeURL: %s", cmtTypeURL) + } + + // Add a slash before the commitment + urlWithSlash := cmtTypeURL[:cmtIndex] + "Service/" + cmtTypeURL[cmtIndex:] if !strings.HasSuffix(urlWithSlash, "Request") { - return "", fmt.Errorf("invalid typeURL: %s", typeURL) + return "", fmt.Errorf("invalid typeURL: %s", cmtTypeURL) } return strings.TrimSuffix(urlWithSlash, "Request"), nil From 3e943fcb94ef538b85ef9a94adaac951cf31adbe Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 18:59:41 +0700 Subject: [PATCH 13/18] fix: attempted fix for assert relayed --- e2e/testsuite/testsuite.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 3aaf1ac598c..53557ac6613 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -344,7 +344,7 @@ func (s *E2ETestSuite) AssertPacketRelayed(ctx context.Context, chain ibc.Chain, ChannelId: channelID, Sequence: sequence, }) - s.Require().NoError(err) + s.Require().ErrorContains(err, "packet commitment hash not found") commitment := commitmentResp.Commitment s.Require().Empty(commitment) From ef4e8bc86bdc387ca5bc1254a7ff615dedd7040f Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 19:38:12 +0700 Subject: [PATCH 14/18] fix: assert relayed --- e2e/testsuite/testsuite.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 53557ac6613..d21a4bf1acf 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -339,15 +339,12 @@ func (s *E2ETestSuite) GetChainBNativeBalance(ctx context.Context, user ibc.Wall // AssertPacketRelayed asserts that the packet commitment does not exist on the sending chain. // The packet commitment will be deleted upon a packet acknowledgement or timeout. func (s *E2ETestSuite) AssertPacketRelayed(ctx context.Context, chain ibc.Chain, portID, channelID string, sequence uint64) { - commitmentResp, err := query.GRPCQuery[channeltypes.QueryPacketCommitmentResponse](ctx, chain, &channeltypes.QueryPacketCommitmentRequest{ + _, err := query.GRPCQuery[channeltypes.QueryPacketCommitmentResponse](ctx, chain, &channeltypes.QueryPacketCommitmentRequest{ PortId: portID, ChannelId: channelID, Sequence: sequence, }) s.Require().ErrorContains(err, "packet commitment hash not found") - - commitment := commitmentResp.Commitment - s.Require().Empty(commitment) } // AssertHumanReadableDenom asserts that a human readable denom is present for a given chain. From d4dad0b424170ff4238487c52f7a47f1e4227711 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 13 Mar 2024 20:11:42 +0700 Subject: [PATCH 15/18] imp: client fix --- e2e/tests/core/02-client/client_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index e3725fc9c73..785062dd0ba 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -106,11 +106,13 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { t.Run("check that IBC software upgrade has been scheduled successfully on chainA", func(t *testing.T) { // checks there is an upgraded client state stored upgradedCsResp, err := query.GRPCQuery[clienttypes.QueryUpgradedClientStateResponse](ctx, chainA, &clienttypes.QueryUpgradedClientStateRequest{}) + s.Require().NoError(err) clientStateAny := upgradedCsResp.UpgradedClientState - s.Require().NoError(err) - cs, err := clienttypes.UnpackClientState(clientStateAny) + cfg := chainA.Config().EncodingConfig + var cs ibcexported.ClientState + err = cfg.InterfaceRegistry.UnpackAny(clientStateAny, &cs) s.Require().NoError(err) upgradedClientState, ok := cs.(*ibctm.ClientState) From 692c6e9d43a61797109a9196222281bd43f0b741 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Fri, 15 Mar 2024 14:17:12 +0700 Subject: [PATCH 16/18] fix: new test --- e2e/tests/interchain_accounts/base_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index f6292fbc8c0..5113dbcc1e5 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -466,7 +466,7 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulGovProposal(order c t.Run("verify interchain account", func(t *testing.T) { var err error - hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + hostAccount, err = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(hostAccount)) @@ -490,7 +490,7 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulGovProposal(order c }) t.Run("broadcast MsgSendTx for MsgSubmitProposal", func(t *testing.T) { - govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainB) + govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainB) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -529,11 +529,11 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulGovProposal(order c s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB)) }) - t.Run("verify proposal executed", func(t *testing.T) { - proposal, err := s.QueryProposalV1(ctx, chainB, 1) + t.Run("verify proposal included", func(t *testing.T) { + proposalResp, err := query.GRPCQuery[govv1.QueryProposalResponse](ctx, chainB, &govv1.QueryProposalRequest{ProposalId: 1}) s.Require().NoError(err) - s.Require().Equal("e2e", proposal.Title) + s.Require().Equal("e2e", proposalResp.Proposal.Title) }) }) } From cb78e06edd6b723dc9518261ddedf13516dd868d Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 2 Apr 2024 22:08:51 +0700 Subject: [PATCH 17/18] docs: fix godocs --- e2e/testsuite/query/grpc_query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/testsuite/query/grpc_query.go b/e2e/testsuite/query/grpc_query.go index 55232f37e41..9b89d6c81aa 100644 --- a/e2e/testsuite/query/grpc_query.go +++ b/e2e/testsuite/query/grpc_query.go @@ -11,7 +11,7 @@ import ( "google.golang.org/grpc/credentials/insecure" ) -// Queries the chain with a query request and deserializes the response to T +// GRPCQuery queries the chain with a query request and deserializes the response to T func GRPCQuery[T any](ctx context.Context, chain ibc.Chain, req proto.Message, opts ...grpc.CallOption) (*T, error) { path, err := getProtoPath(req) if err != nil { From 168bd97ff3399c01d67716b7d2b21738826b5b1a Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 2 Apr 2024 22:48:20 +0700 Subject: [PATCH 18/18] style: ran golangci-lint --- e2e/testsuite/tx.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index c59f8b68781..0f6021cee36 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -320,14 +320,14 @@ func (s *E2ETestSuite) PruneAcknowledgements( // https://github.com/cosmos/cosmos-sdk/blob/65ab2530cc654fd9e252b124ed24cbaa18023b2b/x/auth/client/cli/query.go#L33 func (*E2ETestSuite) QueryTxsByEvents( ctx context.Context, chain ibc.Chain, - page, limit int, query, orderBy string, + page, limit int, queryReq, orderBy string, ) (*sdk.SearchTxsResult, error) { cosmosChain, ok := chain.(*cosmos.CosmosChain) if !ok { return nil, fmt.Errorf("QueryTxsByEvents must be passed a cosmos.CosmosChain") } - cmd := []string{"txs", "--query", query} + cmd := []string{"txs", "--query", queryReq} if orderBy != "" { cmd = append(cmd, "--order_by", orderBy) }