@@ -31,6 +31,7 @@ import (
3131
3232 "github.com/cosmos/ibc-go/e2e/dockerutil"
3333 "github.com/cosmos/ibc-go/e2e/testsuite"
34+ "github.com/cosmos/ibc-go/e2e/testsuite/query"
3435 "github.com/cosmos/ibc-go/e2e/testvalues"
3536 wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
3637 clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
@@ -51,23 +52,9 @@ type ClientTestSuite struct {
5152 testsuite.E2ETestSuite
5253}
5354
54- // Status queries the current status of the client
55- func (s * ClientTestSuite ) Status (ctx context.Context , chain ibc.Chain , clientID string ) (string , error ) {
56- queryClient := s .GetChainGRCPClients (chain ).ClientQueryClient
57- res , err := queryClient .ClientStatus (ctx , & clienttypes.QueryClientStatusRequest {
58- ClientId : clientID ,
59- })
60- if err != nil {
61- return "" , err
62- }
63-
64- return res .Status , nil
65- }
66-
6755// QueryAllowedClients queries the on-chain AllowedClients parameter for 02-client
6856func (s * ClientTestSuite ) QueryAllowedClients (ctx context.Context , chain ibc.Chain ) []string {
69- queryClient := s .GetChainGRCPClients (chain ).ClientQueryClient
70- res , err := queryClient .ClientParams (ctx , & clienttypes.QueryClientParamsRequest {})
57+ res , err := query .GRPCQuery [clienttypes.QueryClientParamsResponse ](ctx , chain , & clienttypes.QueryClientParamsRequest {})
7158 s .Require ().NoError (err )
7259
7360 return res .Params .AllowedClients
@@ -87,11 +74,11 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() {
8774 var newChainID string
8875
8976 t .Run ("execute proposal for MsgIBCSoftwareUpgrade" , func (t * testing.T ) {
90- authority , err := s . QueryModuleAccountAddress (ctx , govtypes .ModuleName , chainA )
77+ authority , err := query . ModuleAccountAddress (ctx , govtypes .ModuleName , chainA )
9178 s .Require ().NoError (err )
9279 s .Require ().NotNil (authority )
9380
94- clientState , err := s . QueryClientState (ctx , chainB , ibctesting .FirstClientID )
81+ clientState , err := query . ClientState (ctx , chainB , ibctesting .FirstClientID )
9582 s .Require ().NoError (err )
9683
9784 originalChainID := clientState .(* ibctm.ClientState ).ChainId
@@ -119,26 +106,35 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() {
119106
120107 t .Run ("check that IBC software upgrade has been scheduled successfully on chainA" , func (t * testing.T ) {
121108 // checks there is an upgraded client state stored
122- cs , err := s .QueryUpgradedClientState (ctx , chainA , ibctesting .FirstClientID )
109+ upgradedCsResp , err := query .GRPCQuery [clienttypes.QueryUpgradedClientStateResponse ](ctx , chainA , & clienttypes.QueryUpgradedClientStateRequest {})
110+ s .Require ().NoError (err )
111+
112+ clientStateAny := upgradedCsResp .UpgradedClientState
113+
114+ cfg := chainA .Config ().EncodingConfig
115+ var cs ibcexported.ClientState
116+ err = cfg .InterfaceRegistry .UnpackAny (clientStateAny , & cs )
123117 s .Require ().NoError (err )
124118
125119 upgradedClientState , ok := cs .(* ibctm.ClientState )
126120 s .Require ().True (ok )
127121 s .Require ().Equal (upgradedClientState .ChainId , newChainID )
128122
129- plan , err := s . QueryCurrentUpgradePlan (ctx , chainA )
123+ planResponse , err := query . GRPCQuery [upgradetypes. QueryCurrentPlanResponse ] (ctx , chainA , & upgradetypes. QueryCurrentPlanRequest {} )
130124 s .Require ().NoError (err )
131125
126+ plan := planResponse .Plan
127+
132128 s .Require ().Equal ("upgrade-client" , plan .Name )
133129 s .Require ().Equal (planHeight , plan .Height )
134130 })
135131
136132 t .Run ("ensure legacy proposal does not succeed" , func (t * testing.T ) {
137- authority , err := s . QueryModuleAccountAddress (ctx , govtypes .ModuleName , chainA )
133+ authority , err := query . ModuleAccountAddress (ctx , govtypes .ModuleName , chainA )
138134 s .Require ().NoError (err )
139135 s .Require ().NotNil (authority )
140136
141- clientState , err := s . QueryClientState (ctx , chainB , ibctesting .FirstClientID )
137+ clientState , err := query . ClientState (ctx , chainB , ibctesting .FirstClientID )
142138 s .Require ().NoError (err )
143139
144140 originalChainID := clientState .(* ibctm.ClientState ).ChainId
@@ -212,13 +208,13 @@ func (s *ClientTestSuite) TestClientUpdateProposal_Succeeds() {
212208
213209 t .Run ("check status of each client" , func (t * testing.T ) {
214210 t .Run ("substitute should be active" , func (t * testing.T ) {
215- status , err := s . Status (ctx , chainA , substituteClientID )
211+ status , err := query . ClientStatus (ctx , chainA , substituteClientID )
216212 s .Require ().NoError (err )
217213 s .Require ().Equal (ibcexported .Active .String (), status )
218214 })
219215
220216 t .Run ("subject should be expired" , func (t * testing.T ) {
221- status , err := s . Status (ctx , chainA , subjectClientID )
217+ status , err := query . ClientStatus (ctx , chainA , subjectClientID )
222218 s .Require ().NoError (err )
223219 s .Require ().Equal (ibcexported .Expired .String (), status )
224220 })
@@ -231,13 +227,13 @@ func (s *ClientTestSuite) TestClientUpdateProposal_Succeeds() {
231227
232228 t .Run ("check status of each client" , func (t * testing.T ) {
233229 t .Run ("substitute should be active" , func (t * testing.T ) {
234- status , err := s . Status (ctx , chainA , substituteClientID )
230+ status , err := query . ClientStatus (ctx , chainA , substituteClientID )
235231 s .Require ().NoError (err )
236232 s .Require ().Equal (ibcexported .Active .String (), status )
237233 })
238234
239235 t .Run ("subject should be active" , func (t * testing.T ) {
240- status , err := s . Status (ctx , chainA , subjectClientID )
236+ status , err := query . ClientStatus (ctx , chainA , subjectClientID )
241237 s .Require ().NoError (err )
242238 s .Require ().Equal (ibcexported .Active .String (), status )
243239 })
@@ -295,20 +291,20 @@ func (s *ClientTestSuite) TestRecoverClient_Succeeds() {
295291
296292 t .Run ("check status of each client" , func (t * testing.T ) {
297293 t .Run ("substitute should be active" , func (t * testing.T ) {
298- status , err := s . Status (ctx , chainA , substituteClientID )
294+ status , err := query . ClientStatus (ctx , chainA , substituteClientID )
299295 s .Require ().NoError (err )
300296 s .Require ().Equal (ibcexported .Active .String (), status )
301297 })
302298
303299 t .Run ("subject should be expired" , func (t * testing.T ) {
304- status , err := s . Status (ctx , chainA , subjectClientID )
300+ status , err := query . ClientStatus (ctx , chainA , subjectClientID )
305301 s .Require ().NoError (err )
306302 s .Require ().Equal (ibcexported .Expired .String (), status )
307303 })
308304 })
309305
310306 t .Run ("execute proposal for MsgRecoverClient" , func (t * testing.T ) {
311- authority , err := s . QueryModuleAccountAddress (ctx , govtypes .ModuleName , chainA )
307+ authority , err := query . ModuleAccountAddress (ctx , govtypes .ModuleName , chainA )
312308 s .Require ().NoError (err )
313309 recoverClientMsg := clienttypes .NewMsgRecoverClient (authority .String (), subjectClientID , substituteClientID )
314310 s .Require ().NotNil (recoverClientMsg )
@@ -317,13 +313,13 @@ func (s *ClientTestSuite) TestRecoverClient_Succeeds() {
317313
318314 t .Run ("check status of each client" , func (t * testing.T ) {
319315 t .Run ("substitute should be active" , func (t * testing.T ) {
320- status , err := s . Status (ctx , chainA , substituteClientID )
316+ status , err := query . ClientStatus (ctx , chainA , substituteClientID )
321317 s .Require ().NoError (err )
322318 s .Require ().Equal (ibcexported .Active .String (), status )
323319 })
324320
325321 t .Run ("subject should be active" , func (t * testing.T ) {
326- status , err := s . Status (ctx , chainA , subjectClientID )
322+ status , err := query . ClientStatus (ctx , chainA , subjectClientID )
327323 s .Require ().NoError (err )
328324 s .Require ().Equal (ibcexported .Active .String (), status )
329325 })
@@ -354,7 +350,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() {
354350 err := relayer .UpdateClients (ctx , s .GetRelayerExecReporter (), s .GetPathName (0 ))
355351 s .Require ().NoError (err )
356352
357- clientState , err = s . QueryClientState (ctx , chainA , ibctesting .FirstClientID )
353+ clientState , err = query . ClientState (ctx , chainA , ibctesting .FirstClientID )
358354 s .Require ().NoError (err )
359355 })
360356
@@ -370,7 +366,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() {
370366 err := relayer .UpdateClients (ctx , s .GetRelayerExecReporter (), s .GetPathName (0 ))
371367 s .Require ().NoError (err )
372368
373- clientState , err = s . QueryClientState (ctx , chainA , ibctesting .FirstClientID )
369+ clientState , err = query . ClientState (ctx , chainA , ibctesting .FirstClientID )
374370 s .Require ().NoError (err )
375371 })
376372
@@ -386,12 +382,16 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() {
386382 var validators []* cmtservice.Validator
387383
388384 t .Run ("fetch block header at latest client state height" , func (t * testing.T ) {
389- header , err = s .GetBlockHeaderByHeight (ctx , chainB , latestHeight .GetRevisionHeight ())
385+ headerResp , err := query .GRPCQuery [cmtservice.GetBlockByHeightResponse ](ctx , chainB , & cmtservice.GetBlockByHeightRequest {
386+ Height : int64 (latestHeight .GetRevisionHeight ()),
387+ })
390388 s .Require ().NoError (err )
389+
390+ header = & headerResp .SdkBlock .Header
391391 })
392392
393393 t .Run ("get validators at latest height" , func (t * testing.T ) {
394- validators , err = s .GetValidatorSetByHeight (ctx , chainB , latestHeight .GetRevisionHeight ())
394+ validators , err = query .GetValidatorSetByHeight (ctx , chainB , latestHeight .GetRevisionHeight ())
395395 s .Require ().NoError (err )
396396 })
397397
@@ -426,7 +426,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() {
426426 })
427427
428428 t .Run ("ensure client status is frozen" , func (t * testing.T ) {
429- status , err := s . QueryClientStatus (ctx , chainA , ibctesting .FirstClientID )
429+ status , err := query . ClientStatus (ctx , chainA , ibctesting .FirstClientID )
430430 s .Require ().NoError (err )
431431 s .Require ().Equal (ibcexported .Frozen .String (), status )
432432 })
@@ -461,7 +461,7 @@ func (s *ClientTestSuite) TestAllowedClientsParam() {
461461 allowedClient := ibcexported .Solomachine
462462 t .Run ("change the allowed client to only allow solomachine clients" , func (t * testing.T ) {
463463 if testvalues .SelfParamsFeatureReleases .IsSupported (chainAVersion ) {
464- authority , err := s . QueryModuleAccountAddress (ctx , govtypes .ModuleName , chainA )
464+ authority , err := query . ModuleAccountAddress (ctx , govtypes .ModuleName , chainA )
465465 s .Require ().NoError (err )
466466 s .Require ().NotNil (authority )
467467
@@ -485,7 +485,7 @@ func (s *ClientTestSuite) TestAllowedClientsParam() {
485485 })
486486
487487 t .Run ("ensure querying non-allowed client's status returns Unauthorized Status" , func (t * testing.T ) {
488- status , err := s . QueryClientStatus (ctx , chainA , ibctesting .FirstClientID )
488+ status , err := query . ClientStatus (ctx , chainA , ibctesting .FirstClientID )
489489 s .Require ().NoError (err )
490490 s .Require ().Equal (ibcexported .Unauthorized .String (), status )
491491 })
0 commit comments