Skip to content

Commit

Permalink
Revert
Browse files Browse the repository at this point in the history
  • Loading branch information
bznein committed Apr 16, 2024
1 parent 944b3ab commit 0fcd769
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
4 changes: 1 addition & 3 deletions modules/light-clients/08-wasm/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 178 in modules/light-clients/08-wasm/keeper/msg_server_test.go

View workflow job for this annotation

GitHub Actions / lint

unchecked-type-assertion: type cast result is unchecked in clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), expClientStateBz).(*types.ClientState) - type assertion will panic if not matched (revive)
store.Set(host.ClientStateKey(), expClientStateBz)

data, err := json.Marshal(types.EmptyResult{})
Expand Down
28 changes: 14 additions & 14 deletions modules/light-clients/08-wasm/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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"})
Expand All @@ -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)
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 0fcd769

Please sign in to comment.