diff --git a/Makefile b/Makefile index 73d8fb71..f404f751 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ update_tools: ### Testing test: - go test $(shell go list ./... | grep -v vendor) + go test -tags extensive_tests $(shell go list ./... | grep -v vendor) gofuzz_binary: rm -rf tests/fuzz/binary/corpus/ diff --git a/amino.go b/amino.go index fac514a0..4f33d681 100644 --- a/amino.go +++ b/amino.go @@ -230,24 +230,51 @@ func (cdc *Codec) MarshalBinaryBare(o interface{}) ([]byte, error) { } bz = buf.Bytes() } - // If registered concrete, prepend prefix bytes. + // If registered concrete, prepend prefix bytes by wrapping + // message in RegisteredAny: if info.Registered { - // TODO: https://github.com/tendermint/go-amino/issues/267 - //return MarshalBinaryBare(RegisteredAny{ - // AminoPreOrDisfix: info.Prefix.Bytes(), - // Value: bz, - //}) - pb := info.Prefix.Bytes() - bz = append(pb, bz...) + rAny := RegisteredAny{ + AminoPreOrDisfix: info.Prefix.Bytes(), + Value: bz, + } + return MarshalBinaryBare(rAny) } return bz, nil } -//type RegisteredAny struct { -// AminoPreOrDisfix []byte -// Value []byte +// TODO: extensively document this! +// +// This will be compatible to the following proto3 message: +// +// message AminoRegisteredAny { +// // Prefix or Disfix (Prefix + Disamb) bytes +// bytes AminoPreOrDisfix = 1; +// // Must be a valid serialized protocol buffer with the above specified amino pre-/disfix. +// bytes Value = 2; //} +// +// This is comparable to proto.Any but instead of a URL scheme there, we use amino's +// disfix bytes instead. +type RegisteredAny struct { + // Amino Prefix or Disfix (Prefix + Disamb) bytes derived from + // the name while registering the type. + // You can get this values by using the NameToDisfix helper + // method. + // In most common cases you won't need the disambiguation bytes. + // + // The prefix bytes should be 4 bytes. In case disambiguation bytes are + // necessary, this field will hold 7 Disfix bytes + // (3 disambiguation and 4 prefix bytes). + AminoPreOrDisfix []byte + // Must be a valid serialized protocol buffer that was registered + // with a name resulting in the above specified amino pre-/disfix bytes. + // + // Users directly using protobuf in their application need to switch + // over the different prefix (disfix) bytes to know which concrete + // type they are receiving (or encoding). + Value []byte +} // Panics if error. func (cdc *Codec) MustMarshalBinaryBare(o interface{}) []byte { @@ -373,20 +400,23 @@ func (cdc *Codec) UnmarshalBinaryBare(bz []byte, ptr interface{}) error { // If registered concrete, consume and verify prefix bytes. if info.Registered { - // TODO: https://github.com/tendermint/go-amino/issues/267 + aminoAny := &RegisteredAny{} + if err = cdc.UnmarshalBinaryBare(bz, aminoAny); err != nil { + return err + } pb := info.Prefix.Bytes() - if len(bz) < 4 { + if len(aminoAny.AminoPreOrDisfix) < 4 { return fmt.Errorf( "unmarshalBinaryBare expected to read prefix bytes %X (since it is registered concrete) but got %X", - pb, bz, + pb, aminoAny.AminoPreOrDisfix, ) - } else if !bytes.Equal(bz[:4], pb) { + } else if !bytes.Equal(aminoAny.AminoPreOrDisfix[:4], pb) { return fmt.Errorf( "unmarshalBinaryBare expected to read prefix bytes %X (since it is registered concrete) but got %X", - pb, bz[:4], + pb, aminoAny.AminoPreOrDisfix[:4], ) } - bz = bz[4:] + bz = aminoAny.Value } // Only add length prefix if we have another typ3 then Typ3ByteLength. // Default is non-length prefixed: diff --git a/binary-decode.go b/binary-decode.go index 8259e919..8a83d543 100644 --- a/binary-decode.go +++ b/binary-decode.go @@ -345,11 +345,23 @@ func (cdc *Codec) decodeReflectBinaryInterface(bz []byte, iinfo *TypeInfo, rv re bz = buf } - // Consume disambiguation / prefix bytes. - disamb, hasDisamb, prefix, hasPrefix, _n, err := DecodeDisambPrefixBytes(bz) + // Consume disambiguation / prefix bytes by reading into a RegisteredAny message: + aminoAny := &RegisteredAny{} + if err = cdc.UnmarshalBinaryBare(bz, aminoAny); err != nil { + return + } + disamb, hasDisamb, prefix, hasPrefix, _n, err := DecodeDisambPrefixBytes(aminoAny.AminoPreOrDisfix) if slide(&bz, &n, _n) && err != nil { return n, err } + overhead := len(bz) - len(aminoAny.Value) + if overhead < 0 { + // we could as well panic here + err = errors.New("encoded value in RegisteredAny larger than original buffer") + return + } + slide(&bz, &n, overhead) + bz = aminoAny.Value // Get concrete type info from disfix/prefix. var cinfo *TypeInfo diff --git a/binary-encode.go b/binary-encode.go index d10ebfc7..ebd841a9 100644 --- a/binary-encode.go +++ b/binary-encode.go @@ -248,31 +248,31 @@ func (cdc *Codec) encodeReflectBinaryInterface(w io.Writer, iinfo *TypeInfo, rv } else if len(iinfo.Implementers[cinfo.Prefix]) > 1 { needDisamb = true } + disfix := make([]byte, 0) if needDisamb { - _, err = buf.Write(append([]byte{0x00}, cinfo.Disamb[:]...)) - if err != nil { - return - } + // 0x00 indicates that these are disfix bytes + disfix = append([]byte{0x00}, cinfo.Disamb[:]...) } + disfix = append(disfix, cinfo.Prefix.Bytes()...) + aminoAny := &RegisteredAny{AminoPreOrDisfix: disfix} - // Write prefix bytes. - _, err = buf.Write(cinfo.Prefix.Bytes()) + // Write actual concrete value. + err = cdc.encodeReflectBinary(buf, cinfo, crv, fopts, true) if err != nil { return } - - // Write actual concrete value. - err = cdc.encodeReflectBinary(buf, cinfo, crv, fopts, true) + aminoAny.Value = buf.Bytes() + bz, err := cdc.MarshalBinaryBare(aminoAny) if err != nil { return } if bare { // Write byteslice without byte-length prefixing. - _, err = w.Write(buf.Bytes()) + _, err = w.Write(bz) } else { // Write byte-length prefixed byteslice. - err = EncodeByteSlice(w, buf.Bytes()) + err = EncodeByteSlice(w, bz) } return err } diff --git a/example_test.go b/example_test.go index 6459c24e..9bc41966 100644 --- a/example_test.go +++ b/example_test.go @@ -65,7 +65,7 @@ func Example() { fmt.Printf("Decoded successfully: %v\n", *bm == *bm2) // Output: - // Encoded: 0B740613650A034142431064 (err: ) + // Encoded: 0F0A047406136512070A034142431064 (err: ) // Decoded: &{ABC 100} (err: ) // Decoded successfully: true } diff --git a/go.mod b/go.mod index b5b7a501..0293f88e 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.12 require ( github.com/davecgh/go-spew v1.1.1 + github.com/gogo/protobuf v1.2.1 github.com/golang/protobuf v1.3.2 github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf github.com/pkg/errors v0.8.1 diff --git a/go.sum b/go.sum index f9b84426..6de9d1c7 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,14 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -14,6 +18,7 @@ github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= diff --git a/reflect_test.go b/reflect_test.go index a4879f50..40d5ff4e 100644 --- a/reflect_test.go +++ b/reflect_test.go @@ -168,7 +168,7 @@ func TestCodecMarshalBinaryBarePassesOnRegistered(t *testing.T) { bz, err := cdc.MarshalBinaryBare(struct{ tests.Interface1 }{tests.Concrete1{}}) assert.NoError(t, err, "correctly registered") - assert.Equal(t, []byte{0xa, 0x4, 0xe3, 0xda, 0xb8, 0x33}, bz, + assert.Equal(t, []byte{0xa, 0x6, 0xa, 0x4, 0xe3, 0xda, 0xb8, 0x33}, bz, "prefix bytes did not match") } @@ -179,7 +179,7 @@ func TestCodecMarshalBinaryBareOnRegisteredMatches(t *testing.T) { bz, err := cdc.MarshalBinaryBare(struct{ tests.Interface1 }{tests.Concrete1{}}) assert.NoError(t, err, "correctly registered") - assert.Equal(t, []byte{0xa, 0x4, 0xe3, 0xda, 0xb8, 0x33}, bz, + assert.Equal(t, []byte{0xa, 0x6, 0xa, 0x4, 0xe3, 0xda, 0xb8, 0x33}, bz, "prefix bytes did not match") } @@ -192,7 +192,7 @@ func TestCodecMarhsalBinaryBareRegisteredAndDisamb(t *testing.T) { bz, err := cdc.MarshalBinaryBare(struct{ tests.Interface1 }{tests.Concrete1{}}) assert.NoError(t, err, "correctly registered") - assert.Equal(t, []byte{0xa, 0x8, 0x0, 0x12, 0xb5, 0x86, 0xe3, 0xda, 0xb8, 0x33}, bz, + assert.Equal(t, []byte{0xa, 0xa, 0xa, 0x8, 0x0, 0x12, 0xb5, 0x86, 0xe3, 0xda, 0xb8, 0x33}, bz, "prefix bytes did not match") } @@ -215,14 +215,14 @@ func TestCodecRegisterAndMarshalMultipleConcrete(t *testing.T) { { // test tests.Concrete1, no conflict. bz, err := cdc.MarshalBinaryBare(struct{ tests.Interface1 }{tests.Concrete1{}}) assert.NoError(t, err, "correctly registered") - assert.Equal(t, []byte{0xa, 0x4, 0xe3, 0xda, 0xb8, 0x33}, bz, + assert.Equal(t, []byte{0xa, 0x6, 0xa, 0x4, 0xe3, 0xda, 0xb8, 0x33}, bz, "disfix bytes did not match") } { // test tests.Concrete2, no conflict bz, err := cdc.MarshalBinaryBare(struct{ tests.Interface1 }{tests.Concrete2{}}) assert.NoError(t, err, "correctly registered") - assert.Equal(t, []byte{0xa, 0x4, 0x6a, 0x9, 0xca, 0x1}, bz, + assert.Equal(t, []byte{0xa, 0x6, 0xa, 0x4, 0x6a, 0x9, 0xca, 0x1}, bz, "disfix bytes did not match") } } @@ -242,7 +242,7 @@ func TestCodecRoundtripNonNilRegisteredTypeDef(t *testing.T) { bz, err := cdc.MarshalBinaryBare(c3) assert.Nil(t, err) - assert.Equal(t, []byte{0x11, 0x1e, 0x93, 0x82, 0xa, 0x4, 0x30, 0x31, 0x32, 0x33}, bz, + assert.Equal(t, []byte{0xa, 0x4, 0x11, 0x1e, 0x93, 0x82, 0x12, 0x6, 0xa, 0x4, 0x30, 0x31, 0x32, 0x33}, bz, "ConcreteTypeDef incorrectly serialized") var i1 tests.Interface1 @@ -266,7 +266,7 @@ func TestCodecRoundtripNonNilRegisteredWrappedValue(t *testing.T) { bz, err := cdc.MarshalBinaryBare(c3) assert.Nil(t, err) - assert.Equal(t, []byte{0x49, 0x3f, 0xa0, 0x4b, 0xa, 0x4, 0x30, 0x31, 0x32, 0x33}, bz, + assert.Equal(t, []byte{0xa, 0x4, 0x49, 0x3f, 0xa0, 0x4b, 0x12, 0x6, 0xa, 0x4, 0x30, 0x31, 0x32, 0x33}, bz, "ConcreteWrappedBytes incorrectly serialized") var i1 tests.Interface1 @@ -312,7 +312,7 @@ func TestCodecRoundtripMarshalOnConcreteNonNilRegisteredTypeDef(t *testing.T) { bz, err := cdc.MarshalBinaryBare(c3) assert.Nil(t, err) - assert.Equal(t, []byte{0x11, 0x1e, 0x93, 0x82, 0xa, 0x4, 0x30, 0x31, 0x32, 0x33}, bz, + assert.Equal(t, []byte{0xa, 0x4, 0x11, 0x1e, 0x93, 0x82, 0x12, 0x6, 0xa, 0x4, 0x30, 0x31, 0x32, 0x33}, bz, "ConcreteTypeDef incorrectly serialized") var i1 tests.Interface1 @@ -332,12 +332,12 @@ func TestCodecRoundtripUnarshalOnConcreteNonNilRegisteredTypeDef(t *testing.T) { bz, err := cdc.MarshalBinaryBare(c3a) assert.Nil(t, err) - assert.Equal(t, []byte{0x11, 0x1e, 0x93, 0x82, 0xa, 0x4, 0x30, 0x31, 0x32, 0x33}, bz, + assert.Equal(t, []byte{0xa, 0x4, 0x11, 0x1e, 0x93, 0x82, 0x12, 0x6, 0xa, 0x4, 0x30, 0x31, 0x32, 0x33}, bz, "ConcreteTypeDef incorrectly serialized") var c3b tests.ConcreteTypeDef err = cdc.UnmarshalBinaryBare(bz, &c3b) - assert.Nil(t, err) + assert.NoError(t, err) assert.Equal(t, c3a, c3b) } @@ -347,11 +347,10 @@ func TestCodecBinaryStructFieldNilInterface(t *testing.T) { cdc.RegisterConcrete((*tests.InterfaceFieldsStruct)(nil), "interfaceFields", nil) i1 := &tests.InterfaceFieldsStruct{F1: new(tests.InterfaceFieldsStruct), F2: nil} - bz, err := cdc.MarshalBinaryLengthPrefixed(i1) + bz, err := cdc.MarshalBinaryBare(i1) assert.NoError(t, err) - i2 := new(tests.InterfaceFieldsStruct) - err = cdc.UnmarshalBinaryLengthPrefixed(bz, i2) + err = cdc.UnmarshalBinaryBare(bz, i2) assert.NoError(t, err) require.Equal(t, i1, i2, "i1 and i2 should be the same after decoding") diff --git a/tests/proto3/proto/compat.pb.go b/tests/proto3/proto/compat.pb.go index 8c54fd07..ebe70218 100644 --- a/tests/proto3/proto/compat.pb.go +++ b/tests/proto3/proto/compat.pb.go @@ -1,12 +1,14 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. +// Code generated by protoc-gen-gogo. DO NOT EDIT. // source: compat.proto package proto3tests import ( + encoding_binary "encoding/binary" fmt "fmt" - proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" + proto "github.com/gogo/protobuf/proto" + types "github.com/gogo/protobuf/types" + io "io" math "math" ) @@ -19,13 +21,10 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package type TestInt32Varint struct { - Int32 int32 `protobuf:"zigzag32,1,opt,name=Int32,proto3" json:"Int32,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Int32 int32 `protobuf:"zigzag32,1,opt,name=Int32,proto3" json:"Int32,omitempty"` } func (m *TestInt32Varint) Reset() { *m = TestInt32Varint{} } @@ -34,18 +33,26 @@ func (*TestInt32Varint) ProtoMessage() {} func (*TestInt32Varint) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{0} } - func (m *TestInt32Varint) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestInt32Varint.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *TestInt32Varint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestInt32Varint.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_TestInt32Varint.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *TestInt32Varint) XXX_Merge(src proto.Message) { xxx_messageInfo_TestInt32Varint.Merge(m, src) } func (m *TestInt32Varint) XXX_Size() int { - return xxx_messageInfo_TestInt32Varint.Size(m) + return m.Size() } func (m *TestInt32Varint) XXX_DiscardUnknown() { xxx_messageInfo_TestInt32Varint.DiscardUnknown(m) @@ -61,10 +68,7 @@ func (m *TestInt32Varint) GetInt32() int32 { } type TestInt32Fixed struct { - Fixed32 uint32 `protobuf:"fixed32,1,opt,name=Fixed32,proto3" json:"Fixed32,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Fixed32 uint32 `protobuf:"fixed32,1,opt,name=Fixed32,proto3" json:"Fixed32,omitempty"` } func (m *TestInt32Fixed) Reset() { *m = TestInt32Fixed{} } @@ -73,18 +77,26 @@ func (*TestInt32Fixed) ProtoMessage() {} func (*TestInt32Fixed) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{1} } - func (m *TestInt32Fixed) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestInt32Fixed.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *TestInt32Fixed) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestInt32Fixed.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_TestInt32Fixed.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *TestInt32Fixed) XXX_Merge(src proto.Message) { xxx_messageInfo_TestInt32Fixed.Merge(m, src) } func (m *TestInt32Fixed) XXX_Size() int { - return xxx_messageInfo_TestInt32Fixed.Size(m) + return m.Size() } func (m *TestInt32Fixed) XXX_DiscardUnknown() { xxx_messageInfo_TestInt32Fixed.DiscardUnknown(m) @@ -100,11 +112,8 @@ func (m *TestInt32Fixed) GetFixed32() uint32 { } type Test32 struct { - Foo uint32 `protobuf:"fixed32,1,opt,name=foo,proto3" json:"foo,omitempty"` - Bar int32 `protobuf:"zigzag32,2,opt,name=bar,proto3" json:"bar,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Foo uint32 `protobuf:"fixed32,1,opt,name=foo,proto3" json:"foo,omitempty"` + Bar int32 `protobuf:"zigzag32,2,opt,name=bar,proto3" json:"bar,omitempty"` } func (m *Test32) Reset() { *m = Test32{} } @@ -113,18 +122,26 @@ func (*Test32) ProtoMessage() {} func (*Test32) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{2} } - func (m *Test32) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Test32.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *Test32) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Test32.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_Test32.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *Test32) XXX_Merge(src proto.Message) { xxx_messageInfo_Test32.Merge(m, src) } func (m *Test32) XXX_Size() int { - return xxx_messageInfo_Test32.Size(m) + return m.Size() } func (m *Test32) XXX_DiscardUnknown() { xxx_messageInfo_Test32.DiscardUnknown(m) @@ -147,10 +164,7 @@ func (m *Test32) GetBar() int32 { } type TestFixedInt64 struct { - Int64 uint64 `protobuf:"fixed64,1,opt,name=Int64,proto3" json:"Int64,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Int64 uint64 `protobuf:"fixed64,1,opt,name=Int64,proto3" json:"Int64,omitempty"` } func (m *TestFixedInt64) Reset() { *m = TestFixedInt64{} } @@ -159,18 +173,26 @@ func (*TestFixedInt64) ProtoMessage() {} func (*TestFixedInt64) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{3} } - func (m *TestFixedInt64) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestFixedInt64.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *TestFixedInt64) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestFixedInt64.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_TestFixedInt64.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *TestFixedInt64) XXX_Merge(src proto.Message) { xxx_messageInfo_TestFixedInt64.Merge(m, src) } func (m *TestFixedInt64) XXX_Size() int { - return xxx_messageInfo_TestFixedInt64.Size(m) + return m.Size() } func (m *TestFixedInt64) XXX_DiscardUnknown() { xxx_messageInfo_TestFixedInt64.DiscardUnknown(m) @@ -186,10 +208,7 @@ func (m *TestFixedInt64) GetInt64() uint64 { } type TestSFixedSInt64 struct { - SInt64 int64 `protobuf:"fixed64,1,opt,name=SInt64,proto3" json:"SInt64,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + SInt64 int64 `protobuf:"fixed64,1,opt,name=SInt64,proto3" json:"SInt64,omitempty"` } func (m *TestSFixedSInt64) Reset() { *m = TestSFixedSInt64{} } @@ -198,18 +217,26 @@ func (*TestSFixedSInt64) ProtoMessage() {} func (*TestSFixedSInt64) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{4} } - func (m *TestSFixedSInt64) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestSFixedSInt64.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *TestSFixedSInt64) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestSFixedSInt64.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_TestSFixedSInt64.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *TestSFixedSInt64) XXX_Merge(src proto.Message) { xxx_messageInfo_TestSFixedSInt64.Merge(m, src) } func (m *TestSFixedSInt64) XXX_Size() int { - return xxx_messageInfo_TestSFixedSInt64.Size(m) + return m.Size() } func (m *TestSFixedSInt64) XXX_DiscardUnknown() { xxx_messageInfo_TestSFixedSInt64.DiscardUnknown(m) @@ -225,10 +252,7 @@ func (m *TestSFixedSInt64) GetSInt64() int64 { } type EmbeddedStruct struct { - SomethingFixedLen int64 `protobuf:"fixed64,1,opt,name=somethingFixedLen,proto3" json:"somethingFixedLen,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + SomethingFixedLen int64 `protobuf:"fixed64,1,opt,name=somethingFixedLen,proto3" json:"somethingFixedLen,omitempty"` } func (m *EmbeddedStruct) Reset() { *m = EmbeddedStruct{} } @@ -237,18 +261,26 @@ func (*EmbeddedStruct) ProtoMessage() {} func (*EmbeddedStruct) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{5} } - func (m *EmbeddedStruct) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_EmbeddedStruct.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *EmbeddedStruct) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_EmbeddedStruct.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_EmbeddedStruct.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *EmbeddedStruct) XXX_Merge(src proto.Message) { xxx_messageInfo_EmbeddedStruct.Merge(m, src) } func (m *EmbeddedStruct) XXX_Size() int { - return xxx_messageInfo_EmbeddedStruct.Size(m) + return m.Size() } func (m *EmbeddedStruct) XXX_DiscardUnknown() { xxx_messageInfo_EmbeddedStruct.DiscardUnknown(m) @@ -265,10 +297,7 @@ func (m *EmbeddedStruct) GetSomethingFixedLen() int64 { type SomeStruct struct { // proto3 autom. turns this into a pointer ... - Emb *EmbeddedStruct `protobuf:"bytes,1,opt,name=emb,proto3" json:"emb,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Emb *EmbeddedStruct `protobuf:"bytes,1,opt,name=emb,proto3" json:"emb,omitempty"` } func (m *SomeStruct) Reset() { *m = SomeStruct{} } @@ -277,18 +306,26 @@ func (*SomeStruct) ProtoMessage() {} func (*SomeStruct) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{6} } - func (m *SomeStruct) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SomeStruct.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *SomeStruct) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SomeStruct.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_SomeStruct.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *SomeStruct) XXX_Merge(src proto.Message) { xxx_messageInfo_SomeStruct.Merge(m, src) } func (m *SomeStruct) XXX_Size() int { - return xxx_messageInfo_SomeStruct.Size(m) + return m.Size() } func (m *SomeStruct) XXX_DiscardUnknown() { xxx_messageInfo_SomeStruct.DiscardUnknown(m) @@ -304,10 +341,7 @@ func (m *SomeStruct) GetEmb() *EmbeddedStruct { } type ProtoGotTime struct { - T *timestamp.Timestamp `protobuf:"bytes,1,opt,name=T,proto3" json:"T,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + T *types.Timestamp `protobuf:"bytes,1,opt,name=T,proto3" json:"T,omitempty"` } func (m *ProtoGotTime) Reset() { *m = ProtoGotTime{} } @@ -316,18 +350,26 @@ func (*ProtoGotTime) ProtoMessage() {} func (*ProtoGotTime) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{7} } - func (m *ProtoGotTime) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ProtoGotTime.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *ProtoGotTime) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ProtoGotTime.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_ProtoGotTime.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *ProtoGotTime) XXX_Merge(src proto.Message) { xxx_messageInfo_ProtoGotTime.Merge(m, src) } func (m *ProtoGotTime) XXX_Size() int { - return xxx_messageInfo_ProtoGotTime.Size(m) + return m.Size() } func (m *ProtoGotTime) XXX_DiscardUnknown() { xxx_messageInfo_ProtoGotTime.DiscardUnknown(m) @@ -335,7 +377,7 @@ func (m *ProtoGotTime) XXX_DiscardUnknown() { var xxx_messageInfo_ProtoGotTime proto.InternalMessageInfo -func (m *ProtoGotTime) GetT() *timestamp.Timestamp { +func (m *ProtoGotTime) GetT() *types.Timestamp { if m != nil { return m.T } @@ -343,10 +385,7 @@ func (m *ProtoGotTime) GetT() *timestamp.Timestamp { } type TestInt32 struct { - Int32 int32 `protobuf:"varint,1,opt,name=Int32,proto3" json:"Int32,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Int32 int32 `protobuf:"varint,1,opt,name=Int32,proto3" json:"Int32,omitempty"` } func (m *TestInt32) Reset() { *m = TestInt32{} } @@ -355,18 +394,26 @@ func (*TestInt32) ProtoMessage() {} func (*TestInt32) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{8} } - func (m *TestInt32) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestInt32.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *TestInt32) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestInt32.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_TestInt32.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *TestInt32) XXX_Merge(src proto.Message) { xxx_messageInfo_TestInt32.Merge(m, src) } func (m *TestInt32) XXX_Size() int { - return xxx_messageInfo_TestInt32.Size(m) + return m.Size() } func (m *TestInt32) XXX_DiscardUnknown() { xxx_messageInfo_TestInt32.DiscardUnknown(m) @@ -382,11 +429,8 @@ func (m *TestInt32) GetInt32() int32 { } type TestInts struct { - Int32 int32 `protobuf:"varint,1,opt,name=Int32,proto3" json:"Int32,omitempty"` - Int64 int64 `protobuf:"varint,2,opt,name=Int64,proto3" json:"Int64,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Int32 int32 `protobuf:"varint,1,opt,name=Int32,proto3" json:"Int32,omitempty"` + Int64 int64 `protobuf:"varint,2,opt,name=Int64,proto3" json:"Int64,omitempty"` } func (m *TestInts) Reset() { *m = TestInts{} } @@ -395,18 +439,26 @@ func (*TestInts) ProtoMessage() {} func (*TestInts) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{9} } - func (m *TestInts) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestInts.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *TestInts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestInts.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_TestInts.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *TestInts) XXX_Merge(src proto.Message) { xxx_messageInfo_TestInts.Merge(m, src) } func (m *TestInts) XXX_Size() int { - return xxx_messageInfo_TestInts.Size(m) + return m.Size() } func (m *TestInts) XXX_DiscardUnknown() { xxx_messageInfo_TestInts.DiscardUnknown(m) @@ -429,10 +481,7 @@ func (m *TestInts) GetInt64() int64 { } type IntDef struct { - Val int64 `protobuf:"varint,1,opt,name=val,proto3" json:"val,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Val int64 `protobuf:"varint,1,opt,name=val,proto3" json:"val,omitempty"` } func (m *IntDef) Reset() { *m = IntDef{} } @@ -441,18 +490,26 @@ func (*IntDef) ProtoMessage() {} func (*IntDef) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{10} } - func (m *IntDef) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_IntDef.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *IntDef) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_IntDef.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_IntDef.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *IntDef) XXX_Merge(src proto.Message) { xxx_messageInfo_IntDef.Merge(m, src) } func (m *IntDef) XXX_Size() int { - return xxx_messageInfo_IntDef.Size(m) + return m.Size() } func (m *IntDef) XXX_DiscardUnknown() { xxx_messageInfo_IntDef.DiscardUnknown(m) @@ -468,10 +525,7 @@ func (m *IntDef) GetVal() int64 { } type IntArr struct { - Val []int64 `protobuf:"varint,1,rep,packed,name=val,proto3" json:"val,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Val []int64 `protobuf:"varint,1,rep,packed,name=val,proto3" json:"val,omitempty"` } func (m *IntArr) Reset() { *m = IntArr{} } @@ -480,18 +534,26 @@ func (*IntArr) ProtoMessage() {} func (*IntArr) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{11} } - func (m *IntArr) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_IntArr.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *IntArr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_IntArr.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_IntArr.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *IntArr) XXX_Merge(src proto.Message) { xxx_messageInfo_IntArr.Merge(m, src) } func (m *IntArr) XXX_Size() int { - return xxx_messageInfo_IntArr.Size(m) + return m.Size() } func (m *IntArr) XXX_DiscardUnknown() { xxx_messageInfo_IntArr.DiscardUnknown(m) @@ -518,12 +580,9 @@ type PrimitivesStruct struct { // Uint64 uint64 // Uvarint uint64 `binary:"varint"` // Uint uint - String_ string `protobuf:"bytes,14,opt,name=String,proto3" json:"String,omitempty"` - Bytes []byte `protobuf:"bytes,15,opt,name=Bytes,proto3" json:"Bytes,omitempty"` - Time *timestamp.Timestamp `protobuf:"bytes,16,opt,name=Time,proto3" json:"Time,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + String_ string `protobuf:"bytes,14,opt,name=String,proto3" json:"String,omitempty"` + Bytes []byte `protobuf:"bytes,15,opt,name=Bytes,proto3" json:"Bytes,omitempty"` + Time *types.Timestamp `protobuf:"bytes,16,opt,name=Time,proto3" json:"Time,omitempty"` } func (m *PrimitivesStruct) Reset() { *m = PrimitivesStruct{} } @@ -532,18 +591,26 @@ func (*PrimitivesStruct) ProtoMessage() {} func (*PrimitivesStruct) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{12} } - func (m *PrimitivesStruct) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PrimitivesStruct.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *PrimitivesStruct) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PrimitivesStruct.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_PrimitivesStruct.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *PrimitivesStruct) XXX_Merge(src proto.Message) { xxx_messageInfo_PrimitivesStruct.Merge(m, src) } func (m *PrimitivesStruct) XXX_Size() int { - return xxx_messageInfo_PrimitivesStruct.Size(m) + return m.Size() } func (m *PrimitivesStruct) XXX_DiscardUnknown() { xxx_messageInfo_PrimitivesStruct.DiscardUnknown(m) @@ -586,7 +653,7 @@ func (m *PrimitivesStruct) GetBytes() []byte { return nil } -func (m *PrimitivesStruct) GetTime() *timestamp.Timestamp { +func (m *PrimitivesStruct) GetTime() *types.Timestamp { if m != nil { return m.Time } @@ -594,10 +661,7 @@ func (m *PrimitivesStruct) GetTime() *timestamp.Timestamp { } type PrimitivesStructSl struct { - Structs []*PrimitivesStruct `protobuf:"bytes,1,rep,name=Structs,proto3" json:"Structs,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Structs []*PrimitivesStruct `protobuf:"bytes,1,rep,name=Structs,proto3" json:"Structs,omitempty"` } func (m *PrimitivesStructSl) Reset() { *m = PrimitivesStructSl{} } @@ -606,18 +670,26 @@ func (*PrimitivesStructSl) ProtoMessage() {} func (*PrimitivesStructSl) Descriptor() ([]byte, []int) { return fileDescriptor_bced3ff93dcaa7f8, []int{13} } - func (m *PrimitivesStructSl) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PrimitivesStructSl.Unmarshal(m, b) + return m.Unmarshal(b) } func (m *PrimitivesStructSl) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PrimitivesStructSl.Marshal(b, m, deterministic) + if deterministic { + return xxx_messageInfo_PrimitivesStructSl.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } func (m *PrimitivesStructSl) XXX_Merge(src proto.Message) { xxx_messageInfo_PrimitivesStructSl.Merge(m, src) } func (m *PrimitivesStructSl) XXX_Size() int { - return xxx_messageInfo_PrimitivesStructSl.Size(m) + return m.Size() } func (m *PrimitivesStructSl) XXX_DiscardUnknown() { xxx_messageInfo_PrimitivesStructSl.DiscardUnknown(m) @@ -632,6 +704,156 @@ func (m *PrimitivesStructSl) GetStructs() []*PrimitivesStruct { return nil } +type AminoRegisteredAny struct { + // Prefix or Disfix (Prefix + Disamb) bytes + AminoPreOrDisfix []byte `protobuf:"bytes,1,opt,name=AminoPreOrDisfix,proto3" json:"AminoPreOrDisfix,omitempty"` + // Must be a valid serialized protocol buffer with the above specified amino pre-/disfix. + Value []byte `protobuf:"bytes,2,opt,name=Value,proto3" json:"Value,omitempty"` +} + +func (m *AminoRegisteredAny) Reset() { *m = AminoRegisteredAny{} } +func (m *AminoRegisteredAny) String() string { return proto.CompactTextString(m) } +func (*AminoRegisteredAny) ProtoMessage() {} +func (*AminoRegisteredAny) Descriptor() ([]byte, []int) { + return fileDescriptor_bced3ff93dcaa7f8, []int{14} +} +func (m *AminoRegisteredAny) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AminoRegisteredAny) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AminoRegisteredAny.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AminoRegisteredAny) XXX_Merge(src proto.Message) { + xxx_messageInfo_AminoRegisteredAny.Merge(m, src) +} +func (m *AminoRegisteredAny) XXX_Size() int { + return m.Size() +} +func (m *AminoRegisteredAny) XXX_DiscardUnknown() { + xxx_messageInfo_AminoRegisteredAny.DiscardUnknown(m) +} + +var xxx_messageInfo_AminoRegisteredAny proto.InternalMessageInfo + +func (m *AminoRegisteredAny) GetAminoPreOrDisfix() []byte { + if m != nil { + return m.AminoPreOrDisfix + } + return nil +} + +func (m *AminoRegisteredAny) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +type EmbeddedRegisteredAny struct { + F1 *AminoRegisteredAny `protobuf:"bytes,1,opt,name=F1,proto3" json:"F1,omitempty"` +} + +func (m *EmbeddedRegisteredAny) Reset() { *m = EmbeddedRegisteredAny{} } +func (m *EmbeddedRegisteredAny) String() string { return proto.CompactTextString(m) } +func (*EmbeddedRegisteredAny) ProtoMessage() {} +func (*EmbeddedRegisteredAny) Descriptor() ([]byte, []int) { + return fileDescriptor_bced3ff93dcaa7f8, []int{15} +} +func (m *EmbeddedRegisteredAny) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EmbeddedRegisteredAny) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EmbeddedRegisteredAny.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EmbeddedRegisteredAny) XXX_Merge(src proto.Message) { + xxx_messageInfo_EmbeddedRegisteredAny.Merge(m, src) +} +func (m *EmbeddedRegisteredAny) XXX_Size() int { + return m.Size() +} +func (m *EmbeddedRegisteredAny) XXX_DiscardUnknown() { + xxx_messageInfo_EmbeddedRegisteredAny.DiscardUnknown(m) +} + +var xxx_messageInfo_EmbeddedRegisteredAny proto.InternalMessageInfo + +func (m *EmbeddedRegisteredAny) GetF1() *AminoRegisteredAny { + if m != nil { + return m.F1 + } + return nil +} + +type SimpleMsg struct { + Message string `protobuf:"bytes,1,opt,name=Message,proto3" json:"Message,omitempty"` + Height int64 `protobuf:"varint,2,opt,name=Height,proto3" json:"Height,omitempty"` +} + +func (m *SimpleMsg) Reset() { *m = SimpleMsg{} } +func (m *SimpleMsg) String() string { return proto.CompactTextString(m) } +func (*SimpleMsg) ProtoMessage() {} +func (*SimpleMsg) Descriptor() ([]byte, []int) { + return fileDescriptor_bced3ff93dcaa7f8, []int{16} +} +func (m *SimpleMsg) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SimpleMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SimpleMsg.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SimpleMsg) XXX_Merge(src proto.Message) { + xxx_messageInfo_SimpleMsg.Merge(m, src) +} +func (m *SimpleMsg) XXX_Size() int { + return m.Size() +} +func (m *SimpleMsg) XXX_DiscardUnknown() { + xxx_messageInfo_SimpleMsg.DiscardUnknown(m) +} + +var xxx_messageInfo_SimpleMsg proto.InternalMessageInfo + +func (m *SimpleMsg) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +func (m *SimpleMsg) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + func init() { proto.RegisterType((*TestInt32Varint)(nil), "proto3tests.TestInt32Varint") proto.RegisterType((*TestInt32Fixed)(nil), "proto3tests.TestInt32Fixed") @@ -647,38 +869,2483 @@ func init() { proto.RegisterType((*IntArr)(nil), "proto3tests.IntArr") proto.RegisterType((*PrimitivesStruct)(nil), "proto3tests.PrimitivesStruct") proto.RegisterType((*PrimitivesStructSl)(nil), "proto3tests.PrimitivesStructSl") + proto.RegisterType((*AminoRegisteredAny)(nil), "proto3tests.AminoRegisteredAny") + proto.RegisterType((*EmbeddedRegisteredAny)(nil), "proto3tests.EmbeddedRegisteredAny") + proto.RegisterType((*SimpleMsg)(nil), "proto3tests.SimpleMsg") } func init() { proto.RegisterFile("compat.proto", fileDescriptor_bced3ff93dcaa7f8) } var fileDescriptor_bced3ff93dcaa7f8 = []byte{ - // 445 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x6f, 0x6b, 0x13, 0x41, - 0x10, 0xc6, 0x39, 0xaf, 0xb9, 0xd8, 0x49, 0x48, 0xaf, 0x8b, 0xc8, 0x11, 0x11, 0xe3, 0xbe, 0xd0, - 0x50, 0xea, 0x15, 0x92, 0x12, 0x05, 0x41, 0x50, 0xfc, 0x43, 0x40, 0xa1, 0xec, 0x1d, 0xbe, 0xbf, - 0x6b, 0x36, 0x71, 0x21, 0x7b, 0x1b, 0x76, 0xa7, 0x45, 0xbf, 0x97, 0x1f, 0x50, 0xf6, 0xcf, 0x25, - 0x4d, 0x0d, 0xf4, 0x55, 0xe6, 0xd9, 0xf9, 0xcd, 0xce, 0xe6, 0x79, 0x0e, 0xfa, 0xd7, 0x4a, 0x6e, - 0x2a, 0xcc, 0x37, 0x5a, 0xa1, 0x22, 0x3d, 0xf7, 0x33, 0x45, 0x6e, 0xd0, 0x0c, 0x5f, 0xac, 0x94, - 0x5a, 0xad, 0xf9, 0x85, 0x3b, 0xab, 0x6f, 0x96, 0x17, 0x28, 0x24, 0x37, 0x58, 0xc9, 0x8d, 0xa7, - 0xe9, 0x6b, 0x38, 0x29, 0xb9, 0xc1, 0x79, 0x83, 0xd3, 0xc9, 0xcf, 0x4a, 0x8b, 0x06, 0xc9, 0x13, - 0xe8, 0x38, 0x99, 0x45, 0xa3, 0x68, 0x7c, 0xca, 0xbc, 0xa0, 0x67, 0x30, 0xd8, 0x82, 0x5f, 0xc5, - 0x6f, 0xbe, 0x20, 0x19, 0x74, 0x5d, 0x11, 0xc8, 0x2e, 0x6b, 0x25, 0x3d, 0x87, 0xc4, 0xb2, 0xd3, - 0x09, 0x49, 0x21, 0x5e, 0x2a, 0x15, 0xfa, 0xb6, 0xb4, 0x27, 0x75, 0xa5, 0xb3, 0x47, 0xee, 0x6e, - 0x5b, 0xd2, 0x57, 0xfe, 0x66, 0x37, 0x3c, 0x6f, 0x70, 0x76, 0x19, 0x5e, 0x30, 0xbb, 0x74, 0x73, - 0x09, 0xf3, 0x82, 0x9e, 0x41, 0x6a, 0xb9, 0xc2, 0x81, 0x85, 0x27, 0x9f, 0x42, 0x52, 0xec, 0xd0, - 0x94, 0x05, 0x45, 0x3f, 0xc0, 0xe0, 0x8b, 0xac, 0xf9, 0x62, 0xc1, 0x17, 0x05, 0xea, 0x9b, 0x6b, - 0x24, 0xe7, 0x70, 0x6a, 0x94, 0xe4, 0xf8, 0x4b, 0x34, 0x2b, 0x77, 0xc3, 0x77, 0xde, 0x84, 0xa1, - 0xff, 0x1b, 0xf4, 0x3d, 0x40, 0xa1, 0x24, 0x0f, 0xb3, 0x6f, 0x20, 0xe6, 0xb2, 0x76, 0x74, 0x6f, - 0xf2, 0x2c, 0xbf, 0x63, 0x70, 0xbe, 0xbf, 0x85, 0x59, 0x8e, 0xbe, 0x83, 0xfe, 0x95, 0x45, 0xbe, - 0x29, 0x2c, 0x85, 0xe4, 0x64, 0x0c, 0x51, 0x19, 0x86, 0x87, 0xb9, 0x0f, 0x24, 0x6f, 0x03, 0xc9, - 0xcb, 0x36, 0x10, 0x16, 0x95, 0xf4, 0x25, 0x1c, 0x6f, 0x4d, 0xde, 0xcf, 0xa1, 0xd3, 0xe6, 0x30, - 0x83, 0xc7, 0x01, 0x31, 0x87, 0x89, 0x9d, 0x7b, 0xd6, 0xe3, 0xb8, 0x75, 0x6f, 0x08, 0xc9, 0xbc, - 0xc1, 0xcf, 0x7c, 0x69, 0x13, 0xb8, 0xad, 0xd6, 0x6e, 0x26, 0x66, 0xb6, 0x0c, 0xbd, 0x8f, 0x5a, - 0xef, 0x7a, 0x71, 0xdb, 0xfb, 0x1b, 0x41, 0x7a, 0xa5, 0x85, 0x14, 0x28, 0x6e, 0xb9, 0x09, 0x86, - 0x6c, 0x17, 0xc7, 0x07, 0x17, 0x1f, 0xdd, 0x59, 0x6c, 0x23, 0xf2, 0x1f, 0x56, 0xd6, 0x71, 0xc7, - 0x41, 0xb9, 0xe8, 0x50, 0x8b, 0x66, 0x95, 0x0d, 0x46, 0xd1, 0xf8, 0x98, 0x05, 0x65, 0x6f, 0xf9, - 0xf4, 0x07, 0xb9, 0xc9, 0x4e, 0x46, 0xd1, 0xb8, 0xcf, 0xbc, 0x20, 0x39, 0x1c, 0x59, 0xa7, 0xb2, - 0xf4, 0x41, 0x1b, 0x1d, 0x47, 0x7f, 0x00, 0xb9, 0xff, 0xea, 0x62, 0x4d, 0xde, 0x42, 0xd7, 0xd7, - 0xc6, 0xfd, 0xc5, 0xde, 0xe4, 0xf9, 0x5e, 0x98, 0xf7, 0x27, 0x58, 0x4b, 0xd7, 0x89, 0xc7, 0xfe, - 0x05, 0x00, 0x00, 0xff, 0xff, 0x9d, 0x3c, 0xc6, 0x27, 0x6b, 0x03, 0x00, 0x00, + // 584 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xc1, 0x6e, 0xda, 0x40, + 0x10, 0x8d, 0xe3, 0x84, 0x94, 0x09, 0x4a, 0x1c, 0xab, 0xad, 0xac, 0x54, 0x75, 0xd2, 0x3d, 0xb4, + 0x08, 0xa5, 0x46, 0x81, 0x88, 0x56, 0xaa, 0x5a, 0x89, 0x28, 0xa5, 0x41, 0x2a, 0x2a, 0x5a, 0x23, + 0xee, 0x26, 0x0c, 0xce, 0x4a, 0xd8, 0x46, 0xde, 0x25, 0x4a, 0xfe, 0xa2, 0x1f, 0xd3, 0x8f, 0xe8, + 0x31, 0xc7, 0x1e, 0x2b, 0xf8, 0x91, 0x6a, 0xd7, 0x6b, 0x08, 0x21, 0x52, 0x4f, 0xcc, 0x9b, 0x79, + 0x33, 0xb3, 0x7e, 0x6f, 0x80, 0xd2, 0x55, 0x12, 0x4d, 0x02, 0xe1, 0x4d, 0xd2, 0x44, 0x24, 0xf6, + 0xae, 0xfa, 0xa9, 0x0b, 0xe4, 0x82, 0x1f, 0x1e, 0x85, 0x49, 0x12, 0x8e, 0xb1, 0xaa, 0x72, 0x83, + 0xe9, 0xa8, 0x2a, 0x58, 0x84, 0x5c, 0x04, 0xd1, 0x24, 0x63, 0x93, 0x77, 0xb0, 0xdf, 0x43, 0x2e, + 0xda, 0xb1, 0xa8, 0xd7, 0xfa, 0x41, 0xca, 0x62, 0x61, 0x3f, 0x87, 0x6d, 0x05, 0x1d, 0xe3, 0xd8, + 0x28, 0x1f, 0xd0, 0x0c, 0x90, 0x0a, 0xec, 0x2d, 0x88, 0x2d, 0x76, 0x8b, 0x43, 0xdb, 0x81, 0x1d, + 0x15, 0x68, 0xe6, 0x0e, 0xcd, 0x21, 0x39, 0x81, 0x82, 0xe4, 0xd6, 0x6b, 0xb6, 0x05, 0xe6, 0x28, + 0x49, 0x74, 0x5d, 0x86, 0x32, 0x33, 0x08, 0x52, 0x67, 0x53, 0xcd, 0x96, 0x21, 0x79, 0x9b, 0x4d, + 0x56, 0xcd, 0xed, 0x58, 0x34, 0xce, 0xf4, 0x0b, 0x1a, 0x67, 0xaa, 0xaf, 0x40, 0x33, 0x40, 0x2a, + 0x60, 0x49, 0x9e, 0xaf, 0x88, 0x7e, 0xc6, 0x7c, 0x09, 0x05, 0x7f, 0x49, 0xb5, 0xa8, 0x46, 0xe4, + 0x0b, 0xec, 0x7d, 0x8d, 0x06, 0x38, 0x1c, 0xe2, 0xd0, 0x17, 0xe9, 0xf4, 0x4a, 0xd8, 0x27, 0x70, + 0xc0, 0x93, 0x08, 0xc5, 0x35, 0x8b, 0x43, 0x35, 0xe1, 0x3b, 0xc6, 0xba, 0x69, 0xbd, 0x40, 0x3e, + 0x01, 0xf8, 0x49, 0x84, 0xba, 0xf7, 0x3d, 0x98, 0x18, 0x0d, 0x14, 0x7b, 0xb7, 0xf6, 0xca, 0x7b, + 0x20, 0xb0, 0xb7, 0xba, 0x85, 0x4a, 0x1e, 0xf9, 0x08, 0xa5, 0xae, 0xa4, 0x7c, 0x4b, 0x44, 0x8f, + 0x45, 0x68, 0x97, 0xc1, 0xe8, 0xe9, 0xe6, 0x43, 0x2f, 0x33, 0xc4, 0xcb, 0x0d, 0xf1, 0x7a, 0xb9, + 0x21, 0xd4, 0xe8, 0x91, 0x37, 0x50, 0x5c, 0x88, 0xbc, 0xea, 0xc3, 0x76, 0xee, 0x43, 0x03, 0x9e, + 0x69, 0x0a, 0x7f, 0x9a, 0xb1, 0x54, 0x4f, 0x6a, 0x6c, 0xe6, 0xea, 0x1d, 0x42, 0xa1, 0x1d, 0x8b, + 0x0b, 0x1c, 0x49, 0x07, 0x6e, 0x82, 0xb1, 0xea, 0x31, 0xa9, 0x0c, 0x75, 0xad, 0x99, 0xa6, 0xcb, + 0x9a, 0x99, 0xd7, 0x7e, 0x19, 0x60, 0x75, 0x53, 0x16, 0x31, 0xc1, 0x6e, 0x90, 0x6b, 0x41, 0x16, + 0x8b, 0xcd, 0x27, 0x17, 0x6f, 0x3d, 0x58, 0x2c, 0x2d, 0xca, 0x0e, 0xcb, 0xd9, 0x56, 0x69, 0x8d, + 0x94, 0x75, 0x22, 0x65, 0x71, 0xe8, 0xec, 0x1d, 0x1b, 0xe5, 0x22, 0xd5, 0x48, 0x4e, 0x39, 0xbf, + 0x13, 0xc8, 0x9d, 0xfd, 0x63, 0xa3, 0x5c, 0xa2, 0x19, 0xb0, 0x3d, 0xd8, 0x92, 0x4a, 0x39, 0xd6, + 0x7f, 0x65, 0x54, 0x3c, 0xd2, 0x01, 0xfb, 0xf1, 0xab, 0xfd, 0xb1, 0xfd, 0x01, 0x76, 0xb2, 0x98, + 0xab, 0x4f, 0xdc, 0xad, 0xbd, 0x5e, 0x31, 0xf3, 0x71, 0x07, 0xcd, 0xd9, 0xa4, 0x0f, 0x76, 0x33, + 0x62, 0x71, 0x42, 0x31, 0x64, 0x5c, 0x60, 0x8a, 0xc3, 0x66, 0x7c, 0x67, 0x57, 0xc0, 0x52, 0xd9, + 0x6e, 0x8a, 0x3f, 0xd2, 0x0b, 0xc6, 0x47, 0xec, 0x56, 0xc9, 0x5a, 0xa2, 0x6b, 0x79, 0xf9, 0x59, + 0xfd, 0x60, 0x3c, 0x45, 0xe5, 0x4a, 0x89, 0x66, 0x80, 0x5c, 0xc2, 0x8b, 0xfc, 0x82, 0x56, 0x47, + 0x57, 0x61, 0xb3, 0x75, 0xaa, 0x8f, 0xe6, 0x68, 0xe5, 0x91, 0xeb, 0xef, 0xa0, 0x9b, 0xad, 0x53, + 0xf2, 0x19, 0x8a, 0x3e, 0x8b, 0x26, 0x63, 0xec, 0xf0, 0x50, 0xfe, 0x35, 0x3b, 0xc8, 0x79, 0x10, + 0xa2, 0x1a, 0x51, 0xa4, 0x39, 0x94, 0xaa, 0x5f, 0x22, 0x0b, 0xaf, 0x85, 0xbe, 0x0e, 0x8d, 0xce, + 0x9d, 0xdf, 0x33, 0xd7, 0xb8, 0x9f, 0xb9, 0xc6, 0xdf, 0x99, 0x6b, 0xfc, 0x9c, 0xbb, 0x1b, 0xf7, + 0x73, 0x77, 0xe3, 0xcf, 0xdc, 0xdd, 0x18, 0x14, 0xb2, 0xe5, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, + 0xc1, 0xfc, 0x5f, 0x2c, 0x66, 0x04, 0x00, 0x00, +} + +func (m *TestInt32Varint) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestInt32Varint) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Int32 != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintCompat(dAtA, i, uint64((uint32(m.Int32)<<1)^uint32((m.Int32>>31)))) + } + return i, nil +} + +func (m *TestInt32Fixed) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestInt32Fixed) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Fixed32 != 0 { + dAtA[i] = 0xd + i++ + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.Fixed32)) + i += 4 + } + return i, nil +} + +func (m *Test32) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Test32) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Foo != 0 { + dAtA[i] = 0xd + i++ + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.Foo)) + i += 4 + } + if m.Bar != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintCompat(dAtA, i, uint64((uint32(m.Bar)<<1)^uint32((m.Bar>>31)))) + } + return i, nil +} + +func (m *TestFixedInt64) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestFixedInt64) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Int64 != 0 { + dAtA[i] = 0x9 + i++ + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Int64)) + i += 8 + } + return i, nil +} + +func (m *TestSFixedSInt64) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestSFixedSInt64) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.SInt64 != 0 { + dAtA[i] = 0x9 + i++ + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.SInt64)) + i += 8 + } + return i, nil +} + +func (m *EmbeddedStruct) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EmbeddedStruct) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.SomethingFixedLen != 0 { + dAtA[i] = 0x9 + i++ + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.SomethingFixedLen)) + i += 8 + } + return i, nil +} + +func (m *SomeStruct) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SomeStruct) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Emb != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.Emb.Size())) + n1, err := m.Emb.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + } + return i, nil +} + +func (m *ProtoGotTime) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ProtoGotTime) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.T != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.T.Size())) + n2, err := m.T.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n2 + } + return i, nil +} + +func (m *TestInt32) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestInt32) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Int32 != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.Int32)) + } + return i, nil +} + +func (m *TestInts) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestInts) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Int32 != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.Int32)) + } + if m.Int64 != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.Int64)) + } + return i, nil +} + +func (m *IntDef) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IntDef) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Val != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.Val)) + } + return i, nil } + +func (m *IntArr) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IntArr) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Val) > 0 { + dAtA4 := make([]byte, len(m.Val)*10) + var j3 int + for _, num1 := range m.Val { + num := uint64(num1) + for num >= 1<<7 { + dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j3++ + } + dAtA4[j3] = uint8(num) + j3++ + } + dAtA[i] = 0xa + i++ + i = encodeVarintCompat(dAtA, i, uint64(j3)) + i += copy(dAtA[i:], dAtA4[:j3]) + } + return i, nil +} + +func (m *PrimitivesStruct) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PrimitivesStruct) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Int32 != 0 { + dAtA[i] = 0x18 + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.Int32)) + } + if m.Int64 != 0 { + dAtA[i] = 0x20 + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.Int64)) + } + if m.Varint != 0 { + dAtA[i] = 0x28 + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.Varint)) + } + if len(m.String_) > 0 { + dAtA[i] = 0x72 + i++ + i = encodeVarintCompat(dAtA, i, uint64(len(m.String_))) + i += copy(dAtA[i:], m.String_) + } + if len(m.Bytes) > 0 { + dAtA[i] = 0x7a + i++ + i = encodeVarintCompat(dAtA, i, uint64(len(m.Bytes))) + i += copy(dAtA[i:], m.Bytes) + } + if m.Time != nil { + dAtA[i] = 0x82 + i++ + dAtA[i] = 0x1 + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.Time.Size())) + n5, err := m.Time.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n5 + } + return i, nil +} + +func (m *PrimitivesStructSl) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PrimitivesStructSl) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Structs) > 0 { + for _, msg := range m.Structs { + dAtA[i] = 0xa + i++ + i = encodeVarintCompat(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *AminoRegisteredAny) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AminoRegisteredAny) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.AminoPreOrDisfix) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintCompat(dAtA, i, uint64(len(m.AminoPreOrDisfix))) + i += copy(dAtA[i:], m.AminoPreOrDisfix) + } + if len(m.Value) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintCompat(dAtA, i, uint64(len(m.Value))) + i += copy(dAtA[i:], m.Value) + } + return i, nil +} + +func (m *EmbeddedRegisteredAny) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EmbeddedRegisteredAny) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.F1 != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.F1.Size())) + n6, err := m.F1.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n6 + } + return i, nil +} + +func (m *SimpleMsg) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SimpleMsg) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Message) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintCompat(dAtA, i, uint64(len(m.Message))) + i += copy(dAtA[i:], m.Message) + } + if m.Height != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintCompat(dAtA, i, uint64(m.Height)) + } + return i, nil +} + +func encodeVarintCompat(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *TestInt32Varint) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Int32 != 0 { + n += 1 + sozCompat(uint64(m.Int32)) + } + return n +} + +func (m *TestInt32Fixed) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Fixed32 != 0 { + n += 5 + } + return n +} + +func (m *Test32) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Foo != 0 { + n += 5 + } + if m.Bar != 0 { + n += 1 + sozCompat(uint64(m.Bar)) + } + return n +} + +func (m *TestFixedInt64) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Int64 != 0 { + n += 9 + } + return n +} + +func (m *TestSFixedSInt64) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SInt64 != 0 { + n += 9 + } + return n +} + +func (m *EmbeddedStruct) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SomethingFixedLen != 0 { + n += 9 + } + return n +} + +func (m *SomeStruct) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Emb != nil { + l = m.Emb.Size() + n += 1 + l + sovCompat(uint64(l)) + } + return n +} + +func (m *ProtoGotTime) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.T != nil { + l = m.T.Size() + n += 1 + l + sovCompat(uint64(l)) + } + return n +} + +func (m *TestInt32) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Int32 != 0 { + n += 1 + sovCompat(uint64(m.Int32)) + } + return n +} + +func (m *TestInts) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Int32 != 0 { + n += 1 + sovCompat(uint64(m.Int32)) + } + if m.Int64 != 0 { + n += 1 + sovCompat(uint64(m.Int64)) + } + return n +} + +func (m *IntDef) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Val != 0 { + n += 1 + sovCompat(uint64(m.Val)) + } + return n +} + +func (m *IntArr) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Val) > 0 { + l = 0 + for _, e := range m.Val { + l += sovCompat(uint64(e)) + } + n += 1 + sovCompat(uint64(l)) + l + } + return n +} + +func (m *PrimitivesStruct) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Int32 != 0 { + n += 1 + sovCompat(uint64(m.Int32)) + } + if m.Int64 != 0 { + n += 1 + sovCompat(uint64(m.Int64)) + } + if m.Varint != 0 { + n += 1 + sovCompat(uint64(m.Varint)) + } + l = len(m.String_) + if l > 0 { + n += 1 + l + sovCompat(uint64(l)) + } + l = len(m.Bytes) + if l > 0 { + n += 1 + l + sovCompat(uint64(l)) + } + if m.Time != nil { + l = m.Time.Size() + n += 2 + l + sovCompat(uint64(l)) + } + return n +} + +func (m *PrimitivesStructSl) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Structs) > 0 { + for _, e := range m.Structs { + l = e.Size() + n += 1 + l + sovCompat(uint64(l)) + } + } + return n +} + +func (m *AminoRegisteredAny) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AminoPreOrDisfix) + if l > 0 { + n += 1 + l + sovCompat(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovCompat(uint64(l)) + } + return n +} + +func (m *EmbeddedRegisteredAny) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.F1 != nil { + l = m.F1.Size() + n += 1 + l + sovCompat(uint64(l)) + } + return n +} + +func (m *SimpleMsg) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Message) + if l > 0 { + n += 1 + l + sovCompat(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovCompat(uint64(m.Height)) + } + return n +} + +func sovCompat(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozCompat(x uint64) (n int) { + return sovCompat(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *TestInt32Varint) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestInt32Varint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestInt32Varint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Int32", wireType) + } + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + v = int32((uint32(v) >> 1) ^ uint32(((v&1)<<31)>>31)) + m.Int32 = v + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TestInt32Fixed) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestInt32Fixed: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestInt32Fixed: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Fixed32", wireType) + } + m.Fixed32 = 0 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + m.Fixed32 = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Test32) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Test32: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Test32: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Foo", wireType) + } + m.Foo = 0 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + m.Foo = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Bar", wireType) + } + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + v = int32((uint32(v) >> 1) ^ uint32(((v&1)<<31)>>31)) + m.Bar = v + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TestFixedInt64) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestFixedInt64: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestFixedInt64: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Int64", wireType) + } + m.Int64 = 0 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + m.Int64 = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TestSFixedSInt64) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestSFixedSInt64: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestSFixedSInt64: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field SInt64", wireType) + } + m.SInt64 = 0 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + m.SInt64 = int64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EmbeddedStruct) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EmbeddedStruct: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EmbeddedStruct: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field SomethingFixedLen", wireType) + } + m.SomethingFixedLen = 0 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + m.SomethingFixedLen = int64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SomeStruct) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SomeStruct: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SomeStruct: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Emb", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Emb == nil { + m.Emb = &EmbeddedStruct{} + } + if err := m.Emb.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ProtoGotTime) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ProtoGotTime: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProtoGotTime: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field T", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.T == nil { + m.T = &types.Timestamp{} + } + if err := m.T.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TestInt32) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestInt32: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestInt32: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Int32", wireType) + } + m.Int32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Int32 |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TestInts) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestInts: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestInts: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Int32", wireType) + } + m.Int32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Int32 |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Int64", wireType) + } + m.Int64 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Int64 |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IntDef) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IntDef: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IntDef: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Val", wireType) + } + m.Val = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Val |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IntArr) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IntArr: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IntArr: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Val = append(m.Val, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Val) == 0 { + m.Val = make([]int64, 0, elementCount) + } + for iNdEx < postIndex { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Val = append(m.Val, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Val", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrimitivesStruct) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PrimitivesStruct: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrimitivesStruct: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Int32", wireType) + } + m.Int32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Int32 |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Int64", wireType) + } + m.Int64 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Int64 |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Varint", wireType) + } + m.Varint = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Varint |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field String_", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.String_ = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bytes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bytes = append(m.Bytes[:0], dAtA[iNdEx:postIndex]...) + if m.Bytes == nil { + m.Bytes = []byte{} + } + iNdEx = postIndex + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Time == nil { + m.Time = &types.Timestamp{} + } + if err := m.Time.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrimitivesStructSl) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PrimitivesStructSl: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrimitivesStructSl: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Structs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Structs = append(m.Structs, &PrimitivesStruct{}) + if err := m.Structs[len(m.Structs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AminoRegisteredAny) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AminoRegisteredAny: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AminoRegisteredAny: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AminoPreOrDisfix", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AminoPreOrDisfix = append(m.AminoPreOrDisfix[:0], dAtA[iNdEx:postIndex]...) + if m.AminoPreOrDisfix == nil { + m.AminoPreOrDisfix = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EmbeddedRegisteredAny) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EmbeddedRegisteredAny: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EmbeddedRegisteredAny: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field F1", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.F1 == nil { + m.F1 = &AminoRegisteredAny{} + } + if err := m.F1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SimpleMsg) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SimpleMsg: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SimpleMsg: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCompat(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCompat + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCompat + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCompat + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCompat + } + iNdEx += length + if iNdEx < 0 { + return 0, ErrInvalidLengthCompat + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCompat + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipCompat(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + if iNdEx < 0 { + return 0, ErrInvalidLengthCompat + } + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthCompat = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCompat = fmt.Errorf("proto: integer overflow") +) diff --git a/tests/proto3/proto/compat.proto b/tests/proto3/proto/compat.proto index 0b710915..c402d86b 100644 --- a/tests/proto3/proto/compat.proto +++ b/tests/proto3/proto/compat.proto @@ -75,4 +75,20 @@ message PrimitivesStruct { message PrimitivesStructSl { repeated PrimitivesStruct Structs = 1; +} + +message AminoRegisteredAny { + // Prefix or Disfix (Prefix + Disamb) bytes + bytes AminoPreOrDisfix = 1; + // Must be a valid serialized protocol buffer with the above specified amino pre-/disfix. + bytes Value = 2; +} + +message EmbeddedRegisteredAny { + AminoRegisteredAny F1 = 1; +} + +message SimpleMsg { + string Message = 1; + int64 Height = 2; } \ No newline at end of file diff --git a/tests/proto3/proto3_compat_test.go b/tests/proto3/proto3_compat_test.go index 8efb43d9..24abc747 100644 --- a/tests/proto3/proto3_compat_test.go +++ b/tests/proto3/proto3_compat_test.go @@ -7,6 +7,7 @@ import ( "bufio" "bytes" "encoding/binary" + "math" "testing" "time" @@ -14,8 +15,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + ptypes "github.com/gogo/protobuf/types" "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" p3 "github.com/tendermint/go-amino/tests/proto3/proto" @@ -250,14 +251,14 @@ func TestProto3CompatTimestampNow(t *testing.T) { pbRes := p3.ProtoGotTime{} err = proto.Unmarshal(ab1, &pbRes) assert.NoError(t, err) - got, err := ptypes.Timestamp(pbRes.T) + got, err := ptypes.TimestampFromProto(pbRes.T) assert.NoError(t, err) _, err = ptypes.TimestampProto(now) assert.NoError(t, err) err = proto.Unmarshal(pb, &pbRes) assert.NoError(t, err) // create time.Time from timestamp.Timestamp and check if they are the same: - got, err = ptypes.Timestamp(pbRes.T) + got, err = ptypes.TimestampFromProto(pbRes.T) assert.Equal(t, got.UTC(), now.UTC()) } @@ -268,7 +269,7 @@ func TestProto3EpochTime(t *testing.T) { assert.NoError(t, err) err = proto.Unmarshal(ab, &pbRes) assert.NoError(t, err) - ts, err := ptypes.Timestamp(pbRes.T) + ts, err := ptypes.TimestampFromProto(pbRes.T) assert.NoError(t, err) assert.EqualValues(t, ts, epoch) } @@ -285,7 +286,7 @@ func TestProtoNegativeSeconds(t *testing.T) { assert.EqualValues(t, ntm, *res.T) err = proto.Unmarshal(ab, &pbRes) assert.NoError(t, err) - got, err := ptypes.Timestamp(pbRes.T) + got, err := ptypes.TimestampFromProto(pbRes.T) assert.NoError(t, err) assert.Equal(t, got, ntm) } @@ -376,11 +377,11 @@ func TestIntVarintCompat(t *testing.T) { assert.Error(t, err) } -// See if encoding of type def types matches the proto3 encoding +// See if encoding of def types matches the proto3 encoding func TestTypeDefCompatibility(t *testing.T) { pNow := ptypes.TimestampNow() - now, err := ptypes.Timestamp(pNow) + now, err := ptypes.TimestampFromProto(pNow) require.NoError(t, err) strSl := tests.PrimitivesStructSl{ @@ -425,3 +426,105 @@ func TestTypeDefCompatibility(t *testing.T) { assert.Equal(t, pb, ab, "Amino and protobuf encoding do not match %v", i) } } + +// See if encoding of a registered type matches the proto3 encoding +func TestRegisteredTypesCompatibilitySimple(t *testing.T) { + type message interface{} + + const name = "simpleMsg" + type simpleMsg struct { + Message string + Height int + } + + type simpleMsgUnregistered struct { + Message string + Height int + } + + cdc := amino.NewCodec() + cdc.RegisterInterface((*message)(nil), nil) + cdc.RegisterConcrete(&simpleMsg{}, name, nil) + + bm := &simpleMsg{Message: "ABC", Height: 100} + pbm := &p3.SimpleMsg{Message: "ABC", Height: 100} + bmUnreg := &simpleMsgUnregistered{bm.Message, bm.Height} + + bz, err := cdc.MarshalBinaryBare(bm) + require.NoError(t, err) + + bzUnreg, err := cdc.MarshalBinaryBare(bmUnreg) + require.NoError(t, err) + + // encoded bytes decodeable via protobuf: + pAny := &p3.AminoRegisteredAny{} + err = proto.Unmarshal(bz, pAny) + require.NoError(t, err) + + // amino encoded value / prefix matches proto encoding + assert.Equal(t, pAny.Value, bzUnreg) + _, prefix := amino.NameToDisfix(name) + assert.Equal(t, pAny.AminoPreOrDisfix, prefix.Bytes()) + pbz, err := proto.Marshal(pbm) + require.NoError(t, err) + assert.Equal(t, pbz, bzUnreg) +} + +func TestDisambExample(t *testing.T) { + const name = "interfaceFields" + cdc := amino.NewCodec() + cdc.RegisterInterface((*tests.Interface1)(nil), &amino.InterfaceOptions{ + AlwaysDisambiguate: true, + }) + cdc.RegisterConcrete((*tests.InterfaceFieldsStruct)(nil), name, nil) + + i1 := &tests.InterfaceFieldsStruct{F1: new(tests.InterfaceFieldsStruct), F2: nil} + bz, err := cdc.MarshalBinaryBare(i1) + type fieldStructUnreg struct { + F1 tests.Interface1 + } + + concrete1 := &fieldStructUnreg{F1: new(tests.InterfaceFieldsStruct)} + bc, err := cdc.MarshalBinaryBare(concrete1) + require.NoError(t, err) + t.Logf("%#v", bz) + + pAny := &p3.AminoRegisteredAny{} + err = proto.Unmarshal(bz, pAny) + require.NoError(t, err) + + disamb, prefix := amino.NameToDisfix(name) + t.Logf("%#v", disamb[:]) + // + //t.Logf("%v",disfix[:]) + // TODO: apparently the disamb bytes are only used for the fields + // and not for the outer interface. Not sure why this makes sense. + // assert.Equal(t, disfix, pAny.AminoPreOrDisfix) + assert.Equal(t, prefix.Bytes(), pAny.AminoPreOrDisfix) + assert.Equal(t, bc, pAny.Value) + + embeddedAny := &p3.EmbeddedRegisteredAny{} + err = proto.Unmarshal(pAny.Value, embeddedAny) + t.Logf("embeddedAny = %#v", embeddedAny) + + require.NoError(t, err) + pAnyInner := &p3.AminoRegisteredAny{} + + t.Logf("pAny.Value = %#v", pAny.Value) + err = proto.Unmarshal(pAny.Value, pAnyInner) + require.NoError(t, err) + + //disfix := bytes.Join([][]byte{disamb[:], prefix[:]}, []byte("")) + //assert.Equal(t, disfix, pAnyInner.AminoPreOrDisfix) + t.Logf("aminoInner %#v", pAnyInner.AminoPreOrDisfix) + + aminoAnyInner := &amino.RegisteredAny{} + err = cdc.UnmarshalBinaryBare(pAny.Value, aminoAnyInner) + require.NoError(t, err) + //assert.Equal(t, disfix, aminoAnyInner.AminoPreOrDisfix) + + i2 := new(tests.InterfaceFieldsStruct) + err = cdc.UnmarshalBinaryBare(bz, i2) + require.NoError(t, err) + require.Equal(t, i1, i2, "i1 and i2 should be the same after decoding") +}