From 0fcd769771d8a75182a445bc4c1f695134cbbf4e Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 16 Apr 2024 10:18:51 +0100 Subject: [PATCH] Revert --- .../08-wasm/keeper/msg_server_test.go | 4 +-- .../08-wasm/keeper/querier_test.go | 28 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/modules/light-clients/08-wasm/keeper/msg_server_test.go b/modules/light-clients/08-wasm/keeper/msg_server_test.go index 568294fa38d..6c4dfa59abc 100644 --- a/modules/light-clients/08-wasm/keeper/msg_server_test.go +++ b/modules/light-clients/08-wasm/keeper/msg_server_test.go @@ -175,9 +175,7 @@ func (suite *KeeperTestSuite) TestMsgMigrateContract() { suite.mockVM.MigrateFn = func(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ []byte, store wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.ContractResult, uint64, error) { // the checksum written in the client state will later be overwritten by the message server. expClientStateBz := wasmtesting.CreateMockClientStateBz(suite.chainA.App.AppCodec(), []byte("invalid checksum")) - var ok bool - expClientState, ok = clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), expClientStateBz).(*types.ClientState) - suite.Require().True(ok) + expClientState = clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), expClientStateBz).(*types.ClientState) store.Set(host.ClientStateKey(), expClientStateBz) data, err := json.Marshal(types.EmptyResult{}) diff --git a/modules/light-clients/08-wasm/keeper/querier_test.go b/modules/light-clients/08-wasm/keeper/querier_test.go index b27c5adcc55..f41ee194d0e 100644 --- a/modules/light-clients/08-wasm/keeper/querier_test.go +++ b/modules/light-clients/08-wasm/keeper/querier_test.go @@ -47,17 +47,17 @@ func mockCustomQuerier() func(sdk.Context, json.RawMessage) ([]byte, error) { func (suite *KeeperTestSuite) TestCustomQuery() { testCases := []struct { name string - malleate func() + malleate func(k *keeper.Keeper) expError error }{ { "success: custom query", - func() { + func(k *keeper.Keeper) { querierPlugin := keeper.QueryPlugins{ Custom: mockCustomQuerier(), } - GetSimApp(suite.chainA).WasmClientKeeper.SetQueryPlugins(querierPlugin) + k.SetQueryPlugins(querierPlugin) suite.mockVM.RegisterQueryCallback(types.StatusMsg{}, func(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ []byte, _ wasmvm.KVStore, _ wasmvm.GoAPI, querier wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.QueryResult, uint64, error) { echo := CustomQuery{ Echo: &QueryEcho{ @@ -87,7 +87,7 @@ func (suite *KeeperTestSuite) TestCustomQuery() { }, { "failure: default query", - func() { + func(k *keeper.Keeper) { suite.mockVM.RegisterQueryCallback(types.StatusMsg{}, func(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ []byte, _ wasmvm.KVStore, _ wasmvm.GoAPI, querier wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.QueryResult, uint64, error) { resp, err := querier.Query(wasmvmtypes.QueryRequest{Custom: json.RawMessage("{}")}, math.MaxUint64) suite.Require().ErrorIs(err, wasmvmtypes.UnsupportedRequest{Kind: "Custom queries are not allowed"}) @@ -109,10 +109,10 @@ func (suite *KeeperTestSuite) TestCustomQuery() { err := endpoint.CreateClient() suite.Require().NoError(err) - tc.malleate() - wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper + tc.malleate(&wasmClientKeeper) + clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), endpoint.ClientID) clientState, ok := endpoint.GetClientState().(*types.ClientState) suite.Require().True(ok) @@ -148,17 +148,17 @@ func (suite *KeeperTestSuite) TestStargateQuery() { testCases := []struct { name string - malleate func() + malleate func(k *keeper.Keeper) expError error }{ { "success: custom query", - func() { + func(k *keeper.Keeper) { querierPlugin := keeper.QueryPlugins{ Stargate: keeper.AcceptListStargateQuerier([]string{typeURL}, GetSimApp(suite.chainA).GRPCQueryRouter()), } - GetSimApp(suite.chainA).WasmClientKeeper.SetQueryPlugins(querierPlugin) + k.SetQueryPlugins(querierPlugin) suite.mockVM.RegisterQueryCallback(types.TimestampAtHeightMsg{}, func(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ []byte, store wasmvm.KVStore, _ wasmvm.GoAPI, querier wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.QueryResult, uint64, error) { queryRequest := types.QueryChecksumsRequest{} @@ -200,12 +200,12 @@ func (suite *KeeperTestSuite) TestStargateQuery() { // This exercises the full flow through the grpc handler and into the light client for verification, handling encoding and routing. // Furthermore we write a test key and assert that the state changes made by this handler were discarded by the cachedCtx at the grpc handler. "success: verify membership query", - func() { + func(k *keeper.Keeper) { querierPlugin := keeper.QueryPlugins{ Stargate: keeper.AcceptListStargateQuerier([]string{""}, GetSimApp(suite.chainA).GRPCQueryRouter()), } - GetSimApp(suite.chainA).WasmClientKeeper.SetQueryPlugins(querierPlugin) + k.SetQueryPlugins(querierPlugin) store := suite.chainA.GetContext().KVStore(GetSimApp(suite.chainA).GetKey(exported.StoreKey)) store.Set(proofKey, value) @@ -277,7 +277,7 @@ func (suite *KeeperTestSuite) TestStargateQuery() { }, { "failure: default querier", - func() { + func(k *keeper.Keeper) { suite.mockVM.RegisterQueryCallback(types.TimestampAtHeightMsg{}, func(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ []byte, store wasmvm.KVStore, _ wasmvm.GoAPI, querier wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.QueryResult, uint64, error) { queryRequest := types.QueryChecksumsRequest{} bz, err := queryRequest.Marshal() @@ -311,10 +311,10 @@ func (suite *KeeperTestSuite) TestStargateQuery() { err := endpoint.CreateClient() suite.Require().NoError(err) - tc.malleate() - wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper + tc.malleate(&wasmClientKeeper) + payload := types.QueryMsg{ TimestampAtHeight: &types.TimestampAtHeightMsg{ Height: clienttypes.NewHeight(1, 100),