From 98370b37ed9639997630e550558720030325bb7c Mon Sep 17 00:00:00 2001 From: zemyblue Date: Wed, 8 May 2024 14:41:49 +0900 Subject: [PATCH] chore: change error message. Signed-off-by: zemyblue --- app/wasm_filter.go | 2 +- app/wasm_filter_test.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/wasm_filter.go b/app/wasm_filter.go index 4adab0c4..6b4e41dc 100644 --- a/app/wasm_filter.go +++ b/app/wasm_filter.go @@ -25,7 +25,7 @@ func wasmFilteredEncodeStargateMsg(unpakcer codectypes.AnyUnpacker) wasmkeeper.S return func(sender sdk.AccAddress, msg *wasmvmtypes.StargateMsg) ([]sdk.Msg, error) { for _, msgName := range deniedMsgInStargateMsg { if strings.HasPrefix(msg.TypeURL, msgName) { - return nil, sdkerrors.Wrapf(wasmtypes.ErrUnsupportedForContract, "messages of the type in %s are not supported by Stargate", msgName) + return nil, sdkerrors.Wrapf(wasmtypes.ErrUnsupportedForContract, "%s is not supported by Stargate", msg.TypeURL) } } diff --git a/app/wasm_filter_test.go b/app/wasm_filter_test.go index c6075732..5eb78e6e 100644 --- a/app/wasm_filter_test.go +++ b/app/wasm_filter_test.go @@ -57,6 +57,7 @@ func TestFilteredStargateMsgEncoders(t *testing.T) { output []sdk.Msg // set if invalid isError bool + errMsg string }{ "stargate encoded bank msg": { sender: addr2, @@ -87,6 +88,7 @@ func TestFilteredStargateMsgEncoders(t *testing.T) { }, }, isError: true, + errMsg: "Cannot unpack proto message with type URL: /cosmos.bank.v2.MsgSend: invalid CosmosMsg from the contract", }, "stargate encoded filtered (fswap)": { sender: addr1, @@ -97,6 +99,7 @@ func TestFilteredStargateMsgEncoders(t *testing.T) { }, }, isError: true, + errMsg: "/lbm.fswap.v1.MsgSwap is not supported by Stargate: unsupported for this contract", }, "stargate encoded filtered (fbridge)": { sender: addr1, @@ -107,6 +110,7 @@ func TestFilteredStargateMsgEncoders(t *testing.T) { }, }, isError: true, + errMsg: "/lbm.fbridge.v1.MsgTransfer is not supported by Stargate: unsupported for this contract", }, } encodingConfig := MakeEncodingConfig() @@ -115,10 +119,11 @@ func TestFilteredStargateMsgEncoders(t *testing.T) { t.Run(name, func(t *testing.T) { var ctx sdk.Context encoder := wasmkeeper.DefaultEncoders(encodingConfig.Marshaler, tc.transferPortSource) - encoder.Merge(filteredStargateMsgEncoders(encodingConfig.Marshaler)) + encoder = encoder.Merge(filteredStargateMsgEncoders(encodingConfig.Marshaler)) res, err := encoder.Encode(ctx, tc.sender, tc.srcContractIBCPort, tc.srcMsg) if tc.isError { require.Error(t, err) + require.Equal(t, err.Error(), tc.errMsg) } else { require.NoError(t, err) assert.Equal(t, tc.output, res)