test: add unit test
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user