diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index fe7ade0ee46..8075139f3d4 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" @@ -51,23 +52,9 @@ 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) { - queryClient := s.GetChainGRCPClients(chain).ClientQueryClient - res, err := queryClient.ClientStatus(ctx, &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 { - queryClient := s.GetChainGRCPClients(chain).ClientQueryClient - res, err := queryClient.ClientParams(ctx, &clienttypes.QueryClientParamsRequest{}) + res, err := query.GRPCQuery[clienttypes.QueryClientParamsResponse](ctx, chain, &clienttypes.QueryClientParamsRequest{}) s.Require().NoError(err) return res.Params.AllowedClients @@ -87,11 +74,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.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) - clientState, err := s.QueryClientState(ctx, chainB, ibctesting.FirstClientID) + clientState, err := query.ClientState(ctx, chainB, ibctesting.FirstClientID) s.Require().NoError(err) originalChainID := clientState.(*ibctm.ClientState).ChainId @@ -119,26 +106,35 @@ 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 := query.GRPCQuery[clienttypes.QueryUpgradedClientStateResponse](ctx, chainA, &clienttypes.QueryUpgradedClientStateRequest{}) + s.Require().NoError(err) + + clientStateAny := upgradedCsResp.UpgradedClientState + + cfg := chainA.Config().EncodingConfig + var cs ibcexported.ClientState + err = cfg.InterfaceRegistry.UnpackAny(clientStateAny, &cs) 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 := query.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) }) t.Run("ensure legacy proposal does not succeed", func(t *testing.T) { - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) - clientState, err := s.QueryClientState(ctx, chainB, ibctesting.FirstClientID) + clientState, err := query.ClientState(ctx, chainB, ibctesting.FirstClientID) s.Require().NoError(err) originalChainID := clientState.(*ibctm.ClientState).ChainId @@ -212,13 +208,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) }) @@ -231,13 +227,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) }) @@ -295,20 +291,20 @@ 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) }) }) t.Run("execute proposal for MsgRecoverClient", func(t *testing.T) { - authority, err := s.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) @@ -317,13 +313,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) }) @@ -354,7 +350,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.ClientState(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) }) @@ -370,7 +366,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.ClientState(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) }) @@ -386,12 +382,16 @@ 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 := query.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) { - validators, err = s.GetValidatorSetByHeight(ctx, chainB, latestHeight.GetRevisionHeight()) + validators, err = query.GetValidatorSetByHeight(ctx, chainB, latestHeight.GetRevisionHeight()) s.Require().NoError(err) }) @@ -426,7 +426,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.ClientStatus(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Frozen.String(), status) }) @@ -461,7 +461,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.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) @@ -485,7 +485,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.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 6a634986307..e9a8cab12ad 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,14 +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) { - queryClient := s.GetChainGRCPClients(chain).ConnectionQueryClient - res, err := queryClient.ConnectionParams(ctx, &connectiontypes.QueryConnectionParamsRequest{}) + res, err := query.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 := query.GRPCQuery[paramsproposaltypes.QueryParamsResponse](ctx, chain, ¶msproposaltypes.QueryParamsRequest{ Subspace: ibcexported.ModuleName, Key: string(connectiontypes.KeyMaxExpectedTimePerBlock), }) @@ -85,7 +84,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.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) @@ -128,7 +127,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.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 e9ee29cf446..a8ffa27c0e3 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -21,6 +21,7 @@ import ( govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "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" @@ -88,7 +89,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 = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotEmpty(hostAccount) @@ -144,10 +145,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.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = s.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 @@ -187,7 +188,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 = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotEmpty(hostAccount) @@ -198,7 +199,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.Balance(ctx, chainB, hostAccount, chainB.Config().Denom) s.Require().NoError(err) s.Require().Zero(hostAccountBalance.Int64()) @@ -237,7 +238,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.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount @@ -285,11 +286,11 @@ 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 = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotEmpty(hostAccount) - _, err = s.QueryChannel(ctx, chainA, portID, initialChannelID) + _, err = query.Channel(ctx, chainA, portID, initialChannelID) s.Require().NoError(err) }) @@ -349,17 +350,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.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 := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = s.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) + _, err = query.Balance(ctx, chainB, hostAccount, chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.StartingTokenAmount @@ -378,7 +379,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.Channel(ctx, chainA, portID, channelIDAfterReopening) s.Require().NoError(err) s.Require().Equal(channeltypes.OPEN, channel.State, "the channel was not in an expected state") @@ -419,7 +420,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.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount @@ -465,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().NotEmpty(hostAccount) @@ -489,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) @@ -528,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) }) }) } diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index 212b5d173f4..11cb8d358ab 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.ModuleAccountAddress(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 = query.InterchainAccount(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.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = s.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 43faca17a3f..2d1c51cda4b 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,8 +68,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 := query.GRPCQuery[grouptypes.QueryGroupPoliciesByGroupResponse](ctx, chain, &grouptypes.QueryGroupPoliciesByGroupRequest{ GroupId: InitialGroupID, // always use the initial group id }) s.Require().NoError(err) @@ -141,7 +141,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 = query.InterchainAccount(ctx, chainA, groupPolicyAddr, ibctesting.FirstConnectionID) s.Require().NotEmpty(interchainAccAddr) s.Require().NoError(err) @@ -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 := s.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 = s.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 309a8e92b8f..fb98fe3e89d 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 = query.InterchainAccount(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.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 := s.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) }) @@ -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.IncentivizedPacketsForChannel(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.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 := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = s.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 @@ -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 = query.InterchainAccount(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.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 := s.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) }) @@ -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.IncentivizedPacketsForChannel(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.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 := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) - _, err = s.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 e7d9ad19078..7867a35e4a0 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.Channel(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.Channel(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 := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotEmpty(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 := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotEmpty(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.Balance(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.Channel(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.Channel(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 := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotEmpty(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 := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotEmpty(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.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 := s.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") @@ -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.Channel(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.Channel(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 := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotEmpty(interchainAccAddress) - balance, err := s.QueryBalance(ctx, chainA, interchainAccAddress, chainADenom) + balance, err := query.Balance(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 := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) s.Require().NoError(err) s.Require().NotEmpty(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.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 866ef71ebcb..3165caa143f 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -21,6 +21,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" @@ -40,8 +41,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 := query.GRPCQuery[controllertypes.QueryParamsResponse](ctx, chain, &controllertypes.QueryParamsRequest{}) s.Require().NoError(err) return *res.Params @@ -49,8 +49,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 := query.GRPCQuery[hosttypes.QueryParamsResponse](ctx, chain, &hosttypes.QueryParamsRequest{}) s.Require().NoError(err) return *res.Params @@ -78,7 +77,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.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) s.Require().NotNil(authority) @@ -153,7 +152,7 @@ func (s *InterchainAccountsParamsTestSuite) TestHostEnabledParam() { 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().NotEmpty(hostAccount) @@ -169,7 +168,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.ModuleAccountAddress(ctx, govtypes.ModuleName, chainB) s.Require().NoError(err) s.Require().NotNil(authority) @@ -241,11 +240,11 @@ func (s *InterchainAccountsParamsTestSuite) TestHostEnabledParam() { s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB)) t.Run("verify no tokens were transferred", func(t *testing.T) { - chainBAccountBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainB.Config().Denom) + chainBAccountBalance, err := query.Balance(ctx, chainB, chainBAddress, chainB.Config().Denom) s.Require().NoError(err) s.Require().Equal(testvalues.StartingTokenAmount, chainBAccountBalance.Int64()) - hostAccountBalance, err := s.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom) + hostAccountBalance, err := query.Balance(ctx, chainB, hostAccount, chainB.Config().Denom) s.Require().NoError(err) s.Require().Equal(testvalues.StartingTokenAmount, hostAccountBalance.Int64()) }) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 789f5d7b891..2b735bb94a3 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -17,6 +17,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" icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" @@ -64,7 +65,7 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { 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().NotEmpty(hostAccount) diff --git a/e2e/tests/interchain_accounts/upgrades_test.go b/e2e/tests/interchain_accounts/upgrades_test.go index bd27e276f0f..80045ab4954 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" @@ -78,11 +79,11 @@ 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 = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotEmpty(hostAccount) - _, err = s.QueryChannel(ctx, chainA, portID, initialChannelID) + _, err = query.Channel(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.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 := s.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 := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + govModuleAddress, err := query.ModuleAccountAddress(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.Channel(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.Channel(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.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) s.Require().NoError(err) expected := 2*testvalues.IBCTransferAmount + testvalues.StartingTokenAmount @@ -264,11 +265,11 @@ 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 = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) s.Require().NoError(err) s.Require().NotZero(len(interchainAccount)) - channelA, err = s.QueryChannel(ctx, chainA, controllerPortID, channelID) + channelA, err = query.Channel(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.Channel(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.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 := s.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 @@ -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.FeeEnabledChannel(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.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 := s.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 dd390ad3da5..446f27626cf 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.Balance(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.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 f3272e54a54..d470890d18c 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.TotalEscrowForDenom(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.Balance(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.Balance(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.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 } @@ -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.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 }) @@ -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.ModuleAccountAddress(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.ModuleAccountAddress(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.Balance(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.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 1902c9e0c66..5535f9d37ae 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.CounterPartyPayee(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.CounterPartyPayee(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.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 := s.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) }) @@ -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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.CounterPartyPayee(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.CounterPartyPayee(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.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 e7d5e7299dc..498782df5e3 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,7 +54,7 @@ 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.ClientState(ctx, chainA, exported.LocalhostClientID) s.Require().NoError(err) localhostClientState, ok := cs.(*localhost.ClientState) @@ -62,7 +63,7 @@ func (s *LocalhostTransferTestSuite) TestMsgTransfer_Localhost() { s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - cs, err = s.QueryClientState(ctx, chainA, exported.LocalhostClientID) + cs, err = query.ClientState(ctx, chainA, exported.LocalhostClientID) s.Require().NoError(err) s.Require().True(cs.(*localhost.ClientState).LatestHeight.GT(originalHeight), "client state height was not incremented") }) @@ -118,11 +119,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.Channel(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.Channel(ctx, chainA, transfertypes.PortID, msgChanOpenTryRes.ChannelId) s.Require().NoError(err) s.Require().NotNil(channelEndB) @@ -170,7 +171,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.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 c1bd43898dd..2457590d0c6 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.Channel(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.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 = s.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 := s.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 @@ -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.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 := s.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 @@ -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.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 := s.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) @@ -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.PacketAcknowledgements(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.CounterPartyPayee(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.IncentivizedPacketsForChannel(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.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 := s.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. @@ -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.Channel(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.Channel(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.Channel(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.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 := s.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 @@ -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.FeeEnabledChannel(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.Channel(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.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 := s.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 := s.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 := s.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 08d913d061e..77affeaba94 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.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) s.Require().NoError(err) @@ -112,9 +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(res.Address)) + + hostAccount = res.Address s.Require().NotEmpty(hostAccount) channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID) @@ -229,10 +235,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 c3d56fc4f76..c023fe3a7c8 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.Balance(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.Balance(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.Balance(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.Balance(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.Balance(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.ClientStatus(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.ClientStatus(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.ClientStatus(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.Balance(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.ClientStatus(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.ClientStatus(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.Balance(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.Balance(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.ClientStatus(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.TotalEscrowForDenom(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.Balance(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.ModuleAccountAddress(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.IncentivizedPacketsForChannel(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.Balance(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.Balance(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.Channel(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.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 = s.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 := s.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 @@ -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.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 := s.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 @@ -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.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 := s.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) @@ -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.PacketAcknowledgements(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.CounterPartyPayee(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.IncentivizedPacketsForChannel(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.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 := s.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. @@ -999,11 +996,8 @@ 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, - }) +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 } diff --git a/e2e/tests/wasm/grandpa_test.go b/e2e/tests/wasm/grandpa_test.go index 4b0824a6103..9ab58983b11 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" @@ -89,8 +90,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") @@ -244,8 +243,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") @@ -361,8 +358,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") @@ -417,7 +412,7 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_Success_GrandpaContract() { s.ExecuteAndPassGovV1Proposal(ctx, message, cosmosChain, cosmosWallet) - clientState, err := s.QueryClientState(ctx, cosmosChain, defaultWasmClientID) + clientState, err := query.ClientState(ctx, cosmosChain, defaultWasmClientID) s.Require().NoError(err) wasmClientState, ok := clientState.(*wasmtypes.ClientState) @@ -451,8 +446,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") @@ -546,8 +539,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") @@ -598,19 +589,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.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 = s.clientStatus(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 := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, cosmosChain) + authority, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, cosmosChain) s.Require().NoError(err) msgRecoverClient := clienttypes.NewMsgRecoverClient(authority.String(), subjectClientID, substituteClientID) @@ -622,12 +613,12 @@ func (s *GrandpaTestSuite) TestRecoverClient_Succeeds_GrandpaContract() { } // ensure subject client is active - status, err = s.clientStatus(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 = s.clientStatus(ctx, cosmosChain, substituteClientID) + status, err = query.ClientStatus(ctx, cosmosChain, substituteClientID) s.Require().NoError(err) s.Require().Equal(ibcexported.Active.String(), status) } @@ -656,9 +647,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") @@ -666,18 +658,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 d58ba5441b6..ba7ba22e15a 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") diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/grpc_query.go deleted file mode 100644 index 44ba2614d94..00000000000 --- a/e2e/testsuite/grpc_query.go +++ /dev/null @@ -1,464 +0,0 @@ -package testsuite - -import ( - "context" - "fmt" - "sort" - - "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" -) - -// 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 - } - - // Create a connection to the gRPC server. - grpcConn, err := grpc.Dial( - 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 -} - -// 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, - }) - 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 -} - -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 -} - -// 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 - } - - return &res.SdkBlock.Header, nil -} - -// 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 - } - - sort.SliceStable(res.Validators, func(i, j int) bool { - return res.Validators[i].Address < res.Validators[j].Address - }) - - return res.Validators, nil -} - -// QueryModuleAccountAddress returns the sdk.AccAddress of a given module name. -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, - }) - if err != nil { - return nil, err - } - - cfg := 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) - 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 - } - 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 - } - - return res.Checksums, nil -} diff --git a/e2e/testsuite/query/grpc_query.go b/e2e/testsuite/query/grpc_query.go new file mode 100644 index 00000000000..9b89d6c81aa --- /dev/null +++ b/e2e/testsuite/query/grpc_query.go @@ -0,0 +1,85 @@ +package query + +import ( + "context" + "fmt" + "strings" + + "github.com/cosmos/gogoproto/proto" + "github.com/strangelove-ventures/interchaintest/v8/ibc" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +// 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 { + 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) + + 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) + } +} + +func getQueryProtoPath(queryTypeURL string) (string, error) { + queryIndex := strings.Index(queryTypeURL, "Query") + if queryIndex == -1 { + return "", fmt.Errorf("invalid typeURL: %s", queryTypeURL) + } + + // Add to the index to account for the length of "Query" + queryIndex += len("Query") + + // Add a slash before the query + 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", cmtTypeURL) + } + + return strings.TrimSuffix(urlWithSlash, "Request"), nil +} diff --git a/e2e/testsuite/query/queries.go b/e2e/testsuite/query/queries.go new file mode 100644 index 00000000000..8ed8a09012b --- /dev/null +++ b/e2e/testsuite/query/queries.go @@ -0,0 +1,213 @@ +package query + +import ( + "context" + "fmt" + "sort" + + "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" + + 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" +) + +// ModuleAccountAddress returns the address of the given module on the given chain. +// Added because interchaintest's method doesn't work. +func ModuleAccountAddress(ctx context.Context, moduleName string, chain ibc.Chain) (sdk.AccAddress, error) { + modAccResp, err := GRPCQuery[authtypes.QueryModuleAccountByNameResponse]( + ctx, chain, &authtypes.QueryModuleAccountByNameRequest{Name: moduleName}, + ) + if err != nil { + return nil, err + } + + cfg := chain.Config().EncodingConfig + var account sdk.AccountI + err = cfg.InterfaceRegistry.UnpackAny(modAccResp.Account, &account) + if err != nil { + return nil, err + } + + govAccount, ok := account.(sdk.ModuleAccountI) + if !ok { + return nil, fmt.Errorf("account is not a module account") + } + if govAccount.GetAddress().String() == "" { + return nil, fmt.Errorf("module account address is empty") + } + + return govAccount.GetAddress(), nil +} + +// 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: clientID, + }) + if err != nil { + return nil, err + } + + clientStateAny := clientStateResp.ClientState + + cfg := chain.Config().EncodingConfig + var clientState ibcexported.ClientState + err = cfg.InterfaceRegistry.UnpackAny(clientStateAny, &clientState) + if err != nil { + return nil, err + } + + return clientState, nil +} + +// 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, + }) + 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 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 +} + +// 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, + }) + if err != nil { + return math.Int{}, err + } + return res.Balance.Amount, nil +} + +// 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, + }) + if err != nil { + return channeltypes.Channel{}, err + } + return *res.Channel, nil +} + +// 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, + }) + if err != nil { + return "", err + } + return res.CounterpartyPayee, nil +} + +// IncentivizedPacketsForChannel queries the incentivized packets on the specified channel. +func IncentivizedPacketsForChannel( + 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 +} + +// 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, + }) + if err != nil { + return false, err + } + return res.FeeEnabled, nil +} + +// 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, + }) + if err != nil { + return sdk.Coin{}, err + } + return res.Amount, nil +} + +// 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, + PacketCommitmentSequences: packetCommitmentSequences, + }) + if err != nil { + return nil, err + } + return res.Acknowledgements, nil +} + +// 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, + }) + if err != nil { + return channeltypes.ErrorReceipt{}, err + } + 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 +} diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index f7aed822821..1e6bd840ad3 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -19,11 +19,13 @@ 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/internal/directories" "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" @@ -45,7 +47,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 @@ -142,8 +143,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] @@ -211,9 +210,6 @@ func (s *E2ETestSuite) SetupSingleChain(ctx context.Context) ibc.Chain { SkipPathCreation: true, })) - s.InitGRPCClients(chainA) - s.InitGRPCClients(chainB) - return chainA } @@ -360,44 +356,54 @@ 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 := query.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 := query.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) - s.Require().Empty(commitment) + _, err := query.GRPCQuery[channeltypes.QueryPacketCommitmentResponse](ctx, chain, &channeltypes.QueryPacketCommitmentRequest{ + PortId: portID, + ChannelId: channelID, + Sequence: sequence, + }) + s.Require().ErrorContains(err, "packet commitment hash not found") } // AssertHumanReadableDenom asserts that a human readable denom is present for a given 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 := query.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) @@ -488,7 +494,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.ModuleAccountAddress(ctx, govtypes.ModuleName, chain) s.Require().NoError(err) s.Require().NotNil(govModuleAddress) @@ -499,7 +505,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.ModuleAccountAddress(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 ecbde19b3ad..0f6021cee36 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -26,6 +26,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "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" @@ -182,16 +183,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 := query.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 }) @@ -221,16 +224,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 := query.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 = query.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) @@ -239,13 +250,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 := query.GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, chain, &govtypesv1beta1.QueryProposalRequest{ + ProposalId: proposalID, + }) if err != nil { return false, err } + + proposal := proposalResp.Proposal return proposal.Status == govtypesv1beta1.StatusPassed, nil }) } @@ -305,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) }