Skip to content

Commit

Permalink
test: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
dadamu committed Feb 24, 2023
1 parent fd03235 commit 6d8018a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions x/wasm/keeper/query_plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,31 @@ func TestConvertProtoToJSONMarshal(t *testing.T) {
}
}

func TestResetProtoMarshalerAfterJsonMarshal(t *testing.T) {
appCodec := app.MakeEncodingConfig().Marshaler

protoMarshaler := &banktypes.QueryAllBalancesResponse{}
expected := appCodec.MustMarshalJSON(&banktypes.QueryAllBalancesResponse{
Balances: sdk.NewCoins(sdk.NewCoin("bar", sdk.NewInt(30))),
Pagination: &query.PageResponse{
NextKey: []byte("foo"),
},
})

bz, err := hex.DecodeString("0a090a036261721202333012050a03666f6f")
require.NoError(t, err)

// first marshal
response, err := keeper.ConvertProtoToJSONMarshal(appCodec, protoMarshaler, bz)
require.NoError(t, err)
require.Equal(t, expected, response)

// second marshal
response, err = keeper.ConvertProtoToJSONMarshal(appCodec, protoMarshaler, bz)
require.NoError(t, err)
require.Equal(t, expected, response)
}

// TestDeterministicJsonMarshal tests that we get deterministic JSON marshalled response upon
// proto struct update in the state machine.
func TestDeterministicJsonMarshal(t *testing.T) {
Expand Down

0 comments on commit 6d8018a

Please sign in to comment.