Make JSONMarshaler methods require proto.Message (#7054)
* Make JSONMarshaler require proto.Message * Use &msg with MarshalJSON * Use *LegacyAmino in queriers instead of JSONMarshaler * Revert ABCIMessageLogs String() and coins tests * Use LegacyAmino in client/debug and fix subspace tests * Use LegacyAmino in all legacy queriers and adapt simulation * Make AminoCodec implement Marshaler and some godoc fixes * Test fixes * Remove unrelevant comment * Use TxConfig.TxJSONEncoder * Use encoding/json in genutil cli migrate/validate genesis cmds * Address simulation related comments * Use JSONMarshaler in cli tests * Use proto.Message as respType in cli tests * Use tmjson for tm GenesisDoc * Update types/module/simulation.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update types/module/module_test.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Add godoc comments * Remove unused InsertKeyJSON * Fix tests Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Federico Kunze
Aaron Craelius
parent
b5bc864862
commit
7f59723d88
@@ -122,26 +122,6 @@ func TestProtoCodec(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestProtoCodecMarshalAnyNonProtoErrors(t *testing.T) {
|
||||
cdc := codec.NewProtoCodec(createTestInterfaceRegistry())
|
||||
|
||||
input := "this one that one"
|
||||
_, err := cdc.MarshalJSON(input)
|
||||
require.Error(t, err)
|
||||
require.Equal(t, err, errors.New("cannot protobuf JSON encode unsupported type: string"))
|
||||
|
||||
require.Panics(t, func() { cdc.MustMarshalJSON(input) })
|
||||
}
|
||||
|
||||
func TestProtoCodecUnmarshalAnyNonProtoErrors(t *testing.T) {
|
||||
cdc := codec.NewProtoCodec(createTestInterfaceRegistry())
|
||||
|
||||
recv := new(int)
|
||||
err := cdc.UnmarshalJSON([]byte("foo"), recv)
|
||||
require.Error(t, err)
|
||||
require.Equal(t, err, errors.New("cannot protobuf JSON decode unsupported type: *int"))
|
||||
}
|
||||
|
||||
type lyingProtoMarshaler struct {
|
||||
codec.ProtoMarshaler
|
||||
falseSize int
|
||||
|
||||
Reference in New Issue
Block a user