From 44cbb080a75434da98836946ba9d508df598c1ec Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Sat, 5 Dec 2020 00:08:32 +0100 Subject: [PATCH] adding test --- codec/codec_common_test.go | 3 +++ codec/proto_codec_test.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/codec/codec_common_test.go b/codec/codec_common_test.go index 10820ecc5097..12e9bd2224e1 100644 --- a/codec/codec_common_test.go +++ b/codec/codec_common_test.go @@ -17,6 +17,9 @@ type interfaceMarshaler struct { } func testInterfaceMarshaling(require *require.Assertions, cdc interfaceMarshaler, isAminoBin bool) { + _, err := cdc.marshal(nil) + require.Error(err, "can't marshal a nil value") + dog := &testdata.Dog{Name: "rufus"} var dogI testdata.Animal = dog bz, err := cdc.marshal(dogI) diff --git a/codec/proto_codec_test.go b/codec/proto_codec_test.go index 72346e929d4d..706d025d5994 100644 --- a/codec/proto_codec_test.go +++ b/codec/proto_codec_test.go @@ -28,6 +28,8 @@ func TestProtoMarsharlInterface(t *testing.T) { cdc := codec.NewProtoCodec(createTestInterfaceRegistry()) m := interfaceMarshaler{cdc.MarshalInterface, cdc.UnmarshalInterface} testInterfaceMarshaling(require.New(t), m, false) + m = interfaceMarshaler{cdc.MarshalInterfaceJSON, cdc.UnmarshalInterfaceJSON} + testInterfaceMarshaling(require.New(t), m, false) } func TestProtoCodec(t *testing.T) {