Commit 03104e71 authored by Jason Yellick's avatar Jason Yellick Committed by Gari Singh
Browse files

FAB-10292 Update protobuf to v1.1.0



Protobuf was slated to be updated already, but there is a long list of
incompatibilities with the current source tree.

Thi CR updates protobuf to v1.1.0, and addresses those
incompatibilities.  Most of the changes are quite rote and fall into one
of three buckets.

1. Code which uses non-keyed field initialization.  (ie, initializing a
struct like MyStruct{value1, value2, value3}).  The newer generated
protos produces structs which have additional non-field members.
Structs should always be initialized with named fields, regardless of
whether they are protos or not.

2. Code which assumes that reflect.DeepEqual between two protos with the
same fields will return true.  This has never been the case, especially
when considering protos with slice or map fields, but with proto v1.1.0
with the addition of caching and other members to the proto structs, it
is even less true.  The correct call is proto.Equal.

3. Code which assumes that proto fails on bad inputs -- the proto spec
has always stated that failure _may_ occur, not that it must.  Certain
code would attempt to determine proto message type based on failure to
unmarshal, which was unsafe in v1.0.0, but is even more likely to cause
problems in v1.1.0.

4. On average, half of gossip identity digests aren't valid UTF8 strings,
   and proto v1.1.0 now enforces UTF8 validity checks for string fields.
   Therefore, the field was converted to bytes.

Change-Id: I74cc037903137705dbe3f4e27e34d1307596db3b
Signed-off-by: default avatarJason Yellick <jyellick@us.ibm.com>
Signed-off-by: default avataryacovm <yacovm@il.ibm.com>
parent 6be352ae
...@@ -176,6 +176,7 @@ ...@@ -176,6 +176,7 @@
"protoc-gen-go", "protoc-gen-go",
"protoc-gen-go/descriptor", "protoc-gen-go/descriptor",
"protoc-gen-go/generator", "protoc-gen-go/generator",
"protoc-gen-go/generator/internal/remap",
"protoc-gen-go/grpc", "protoc-gen-go/grpc",
"protoc-gen-go/plugin", "protoc-gen-go/plugin",
"ptypes", "ptypes",
...@@ -185,7 +186,8 @@ ...@@ -185,7 +186,8 @@
"ptypes/struct", "ptypes/struct",
"ptypes/timestamp" "ptypes/timestamp"
] ]
revision = "fec3b39b059c0f88fa6b20f5ed012b1aa203a8b4" revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
version = "v1.1.0"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -635,6 +637,6 @@ ...@@ -635,6 +637,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "cfc117a7d01b8ba0859a4d444c9467aee912043423228f20bbff1c5642e59d2a" inputs-digest = "c20fcba8a0db19d3c1436b5b2796d7acd03a73a7336da0bff52847b93fdbc962"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1
...@@ -37,7 +37,7 @@ ignored = [ ...@@ -37,7 +37,7 @@ ignored = [
[[constraint]] [[constraint]]
name = "github.com/golang/protobuf" name = "github.com/golang/protobuf"
revision = "fec3b39b059c0f88fa6b20f5ed012b1aa203a8b4" version = "1.1.0"
[[constraint]] [[constraint]]
name = "github.com/gorilla/mux" name = "github.com/gorilla/mux"
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"io" "io"
"time" "time"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/timestamp" "github.com/golang/protobuf/ptypes/timestamp"
"github.com/hyperledger/fabric/common/deliver" "github.com/hyperledger/fabric/common/deliver"
"github.com/hyperledger/fabric/common/deliver/mock" "github.com/hyperledger/fabric/common/deliver/mock"
...@@ -190,7 +191,7 @@ var _ = Describe("Deliver", func() { ...@@ -190,7 +191,7 @@ var _ = Describe("Deliver", func() {
Expect(fakeInspector.InspectCallCount()).To(Equal(1)) Expect(fakeInspector.InspectCallCount()).To(Equal(1))
ctx, header := fakeInspector.InspectArgsForCall(0) ctx, header := fakeInspector.InspectArgsForCall(0)
Expect(ctx).To(Equal(context.Background())) Expect(ctx).To(Equal(context.Background()))
Expect(header).To(Equal(channelHeader)) Expect(proto.Equal(header, channelHeader)).To(BeTrue())
}) })
Context("when channel header validation fails", func() { Context("when channel header validation fails", func() {
...@@ -230,7 +231,7 @@ var _ = Describe("Deliver", func() { ...@@ -230,7 +231,7 @@ var _ = Describe("Deliver", func() {
Expect(fakePolicyChecker.CheckPolicyCallCount()).To(BeNumerically(">=", 1)) Expect(fakePolicyChecker.CheckPolicyCallCount()).To(BeNumerically(">=", 1))
e, cid := fakePolicyChecker.CheckPolicyArgsForCall(0) e, cid := fakePolicyChecker.CheckPolicyArgsForCall(0)
Expect(e).To(Equal(envelope)) Expect(proto.Equal(e, envelope)).To(BeTrue())
Expect(cid).To(Equal("chain-id")) Expect(cid).To(Equal("chain-id"))
}) })
...@@ -240,7 +241,7 @@ var _ = Describe("Deliver", func() { ...@@ -240,7 +241,7 @@ var _ = Describe("Deliver", func() {
Expect(fakeBlockReader.IteratorCallCount()).To(Equal(1)) Expect(fakeBlockReader.IteratorCallCount()).To(Equal(1))
startPosition := fakeBlockReader.IteratorArgsForCall(0) startPosition := fakeBlockReader.IteratorArgsForCall(0)
Expect(startPosition).To(Equal(seekInfo.Start)) Expect(proto.Equal(startPosition, seekInfo.Start)).To(BeTrue())
}) })
Context("when multiple blocks are requested", func() { Context("when multiple blocks are requested", func() {
......
...@@ -28,6 +28,8 @@ import ( ...@@ -28,6 +28,8 @@ import (
"reflect" "reflect"
"runtime" "runtime"
"testing" "testing"
"github.com/golang/protobuf/proto"
) )
// AssertNil varifies that the value is nil // AssertNil varifies that the value is nil
...@@ -63,6 +65,14 @@ func AssertEquals(t testing.TB, actual interface{}, expected interface{}) { ...@@ -63,6 +65,14 @@ func AssertEquals(t testing.TB, actual interface{}, expected interface{}) {
actual = convertJSONToMap(actual) actual = convertJSONToMap(actual)
expected = convertJSONToMap(expected) expected = convertJSONToMap(expected)
if pa, ok := actual.(proto.Message); ok {
if pe, ok := actual.(proto.Message); ok {
if proto.Equal(pa, pe) {
return
}
}
}
if !reflect.DeepEqual(actual, expected) { if !reflect.DeepEqual(actual, expected) {
t.Fatalf("Values are not equal.\n Actual=[%#v], \n Expected=[%#v]\n %s", actual, expected, getCallerInfo()) t.Fatalf("Values are not equal.\n Actual=[%#v], \n Expected=[%#v]\n %s", actual, expected, getCallerInfo())
} }
......
...@@ -212,7 +212,10 @@ func TestPrincipalUniqueSet(t *testing.T) { ...@@ -212,7 +212,10 @@ func TestPrincipalUniqueSet(t *testing.T) {
v := reflect.Indirect(reflect.ValueOf(msp.MSPPrincipal{})) v := reflect.Indirect(reflect.ValueOf(msp.MSPPrincipal{}))
// Ensure msp.MSPPrincipal has only 2 fields. // Ensure msp.MSPPrincipal has only 2 fields.
// This is essential for 'UniqueSet' to work properly // This is essential for 'UniqueSet' to work properly
assert.Equal(t, 2, v.NumField()) // XXX This is a rather brittle check and brittle way to fix the test
// There seems to be an assumption that the number of fields in the proto
// struct matches the number of fields in the proto message
assert.Equal(t, 5, v.NumField())
} }
func TestPrincipalSetContainingOnly(t *testing.T) { func TestPrincipalSetContainingOnly(t *testing.T) {
......
...@@ -39,13 +39,20 @@ var ( ...@@ -39,13 +39,20 @@ var (
Data: &cb.BlockData{ Data: &cb.BlockData{
Data: [][]byte{ Data: [][]byte{
utils.MarshalOrPanic(&cb.Envelope{ utils.MarshalOrPanic(&cb.Envelope{
Payload: utils.MarshalOrPanic(&cb.Payload{
Header: &cb.Header{
ChannelHeader: utils.MarshalOrPanic(&cb.ChannelHeader{
Type: int32(cb.HeaderType_CONFIG),
}),
},
}),
Signature: []byte("bar"), Signature: []byte("bar"),
}), }),
}, },
}, },
} }
testOutput = `{"data":{"data":[{"signature":"YmFy"}]},"header":{"number":"0","previous_hash":"Zm9v"}}` testOutput = `{"data":{"data":[{"payload":{"data":{"config":null,"last_update":null},"header":{"channel_header":{"channel_id":"","epoch":"0","extension":null,"timestamp":null,"tls_cert_hash":null,"tx_id":"","type":1,"version":0},"signature_header":{"creator":{"id_bytes":null,"mspid":""},"nonce":null}}},"signature":"YmFy"}]},"header":{"data_hash":null,"number":"0","previous_hash":"Zm9v"},"metadata":null}`
) )
func TestProtolatorDecode(t *testing.T) { func TestProtolatorDecode(t *testing.T) {
...@@ -82,7 +89,7 @@ func TestProtolatorEncode(t *testing.T) { ...@@ -82,7 +89,7 @@ func TestProtolatorEncode(t *testing.T) {
err := proto.Unmarshal(rec.Body.Bytes(), outputMsg) err := proto.Unmarshal(rec.Body.Bytes(), outputMsg)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, testProto, outputMsg) assert.True(t, proto.Equal(testProto, outputMsg))
} }
func TestProtolatorDecodeNonExistantProto(t *testing.T) { func TestProtolatorDecodeNonExistantProto(t *testing.T) {
......
...@@ -8,6 +8,7 @@ package protolator_test ...@@ -8,6 +8,7 @@ package protolator_test
import ( import (
"bytes" "bytes"
"os"
"testing" "testing"
"github.com/hyperledger/fabric/common/tools/configtxgen/configtxgentest" "github.com/hyperledger/fabric/common/tools/configtxgen/configtxgentest"
...@@ -73,3 +74,21 @@ func TestGenesisBlock(t *testing.T) { ...@@ -73,3 +74,21 @@ func TestGenesisBlock(t *testing.T) {
bidirectionalMarshal(t, gb) bidirectionalMarshal(t, gb)
} }
func TestEmitDefaultsBug(t *testing.T) {
block := &cb.Block{
Header: &cb.BlockHeader{
PreviousHash: []byte("foo"),
},
Data: &cb.BlockData{
Data: [][]byte{
utils.MarshalOrPanic(&cb.Envelope{
Signature: []byte("bar"),
}),
},
},
}
err := DeepMarshalJSON(os.Stdout, block)
assert.NoError(t, err)
}
...@@ -79,6 +79,10 @@ type plainField struct { ...@@ -79,6 +79,10 @@ type plainField struct {
} }
func (pf *plainField) PopulateFrom(source interface{}) error { func (pf *plainField) PopulateFrom(source interface{}) error {
if source == nil {
return nil
}
if !reflect.TypeOf(source).AssignableTo(pf.fType) { if !reflect.TypeOf(source).AssignableTo(pf.fType) {
return fmt.Errorf("expected field %s for message %T to be assignable from %v but was not. Is %T", pf.name, pf.msg, pf.fType, source) return fmt.Errorf("expected field %s for message %T to be assignable from %v but was not. Is %T", pf.name, pf.msg, pf.fType, source)
} }
...@@ -94,6 +98,11 @@ func (pf *plainField) PopulateTo() (interface{}, error) { ...@@ -94,6 +98,11 @@ func (pf *plainField) PopulateTo() (interface{}, error) {
if !pf.value.Type().AssignableTo(pf.vType) { if !pf.value.Type().AssignableTo(pf.vType) {
return nil, fmt.Errorf("expected field %s for message %T to be assignable to %v but was not. Got %T.", pf.name, pf.msg, pf.fType, pf.value) return nil, fmt.Errorf("expected field %s for message %T to be assignable to %v but was not. Got %T.", pf.name, pf.msg, pf.fType, pf.value)
} }
if pf.value.Type().Kind() == reflect.Ptr && pf.value.IsNil() {
return nil, nil
}
value, err := pf.populateTo(pf.value) value, err := pf.populateTo(pf.value)
if err != nil { if err != nil {
return nil, fmt.Errorf("error in PopulateTo for field %s for message %T: %s", pf.name, pf.msg, err) return nil, fmt.Errorf("error in PopulateTo for field %s for message %T: %s", pf.name, pf.msg, err)
...@@ -213,6 +222,9 @@ func stringInSlice(target string, slice []string) bool { ...@@ -213,6 +222,9 @@ func stringInSlice(target string, slice []string) bool {
// protoToJSON is a simple shortcut wrapper around the proto JSON marshaler // protoToJSON is a simple shortcut wrapper around the proto JSON marshaler
func protoToJSON(msg proto.Message) ([]byte, error) { func protoToJSON(msg proto.Message) ([]byte, error) {
if reflect.ValueOf(msg).IsNil() {
panic("We're nil here")
}
var b bytes.Buffer var b bytes.Buffer
m := jsonpb.Marshaler{ m := jsonpb.Marshaler{
EnumsAsInts: false, EnumsAsInts: false,
......
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// source: sample.proto // source: sample.proto
/* package testprotos // import "github.com/hyperledger/fabric/common/tools/protolator/testprotos"
Package testprotos is a generated protocol buffer package.
It is generated from these files:
sample.proto
It has these top-level messages:
SimpleMsg
NestedMsg
StaticallyOpaqueMsg
VariablyOpaqueMsg
DynamicMsg
ContextlessMsg
*/
package testprotos
import proto "github.com/golang/protobuf/proto" import proto "github.com/golang/protobuf/proto"
import fmt "fmt" import fmt "fmt"
...@@ -35,15 +21,37 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package ...@@ -35,15 +21,37 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
// SimpleMsg is designed to test that all three types of message fields, plain, map, // SimpleMsg is designed to test that all three types of message fields, plain, map,
// and slice are handled by the protolator tool // and slice are handled by the protolator tool
type SimpleMsg struct { type SimpleMsg struct {
PlainField string `protobuf:"bytes,1,opt,name=plain_field,json=plainField" json:"plain_field,omitempty"` PlainField string `protobuf:"bytes,1,opt,name=plain_field,json=plainField" json:"plain_field,omitempty"`
MapField map[string]string `protobuf:"bytes,2,rep,name=map_field,json=mapField" json:"map_field,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` MapField map[string]string `protobuf:"bytes,2,rep,name=map_field,json=mapField" json:"map_field,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
SliceField []string `protobuf:"bytes,3,rep,name=slice_field,json=sliceField" json:"slice_field,omitempty"` SliceField []string `protobuf:"bytes,3,rep,name=slice_field,json=sliceField" json:"slice_field,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *SimpleMsg) Reset() { *m = SimpleMsg{} } func (m *SimpleMsg) Reset() { *m = SimpleMsg{} }
func (m *SimpleMsg) String() string { return proto.CompactTextString(m) } func (m *SimpleMsg) String() string { return proto.CompactTextString(m) }
func (*SimpleMsg) ProtoMessage() {} func (*SimpleMsg) ProtoMessage() {}
func (*SimpleMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (*SimpleMsg) Descriptor() ([]byte, []int) {
return fileDescriptor_sample_fde2d2951f3e63f3, []int{0}
}
func (m *SimpleMsg) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SimpleMsg.Unmarshal(m, b)
}
func (m *SimpleMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SimpleMsg.Marshal(b, m, deterministic)
}
func (dst *SimpleMsg) XXX_Merge(src proto.Message) {
xxx_messageInfo_SimpleMsg.Merge(dst, src)
}
func (m *SimpleMsg) XXX_Size() int {
return xxx_messageInfo_SimpleMsg.Size(m)
}
func (m *SimpleMsg) XXX_DiscardUnknown() {
xxx_messageInfo_SimpleMsg.DiscardUnknown(m)
}
var xxx_messageInfo_SimpleMsg proto.InternalMessageInfo
func (m *SimpleMsg) GetPlainField() string { func (m *SimpleMsg) GetPlainField() string {
if m != nil { if m != nil {
...@@ -68,15 +76,37 @@ func (m *SimpleMsg) GetSliceField() []string { ...@@ -68,15 +76,37 @@ func (m *SimpleMsg) GetSliceField() []string {
// NestedMsg is designed to test the nested message component // NestedMsg is designed to test the nested message component
type NestedMsg struct { type NestedMsg struct {
PlainNestedField *SimpleMsg `protobuf:"bytes,1,opt,name=plain_nested_field,json=plainNestedField" json:"plain_nested_field,omitempty"` PlainNestedField *SimpleMsg `protobuf:"bytes,1,opt,name=plain_nested_field,json=plainNestedField" json:"plain_nested_field,omitempty"`
MapNestedField map[string]*SimpleMsg `protobuf:"bytes,2,rep,name=map_nested_field,json=mapNestedField" json:"map_nested_field,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` MapNestedField map[string]*SimpleMsg `protobuf:"bytes,2,rep,name=map_nested_field,json=mapNestedField" json:"map_nested_field,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
SliceNestedField []*SimpleMsg `protobuf:"bytes,3,rep,name=slice_nested_field,json=sliceNestedField" json:"slice_nested_field,omitempty"` SliceNestedField []*SimpleMsg `protobuf:"bytes,3,rep,name=slice_nested_field,json=sliceNestedField" json:"slice_nested_field,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *NestedMsg) Reset() { *m = NestedMsg{} } func (m *NestedMsg) Reset() { *m = NestedMsg{} }
func (m *NestedMsg) String() string { return proto.CompactTextString(m) } func (m *NestedMsg) String() string { return proto.CompactTextString(m) }
func (*NestedMsg) ProtoMessage() {} func (*NestedMsg) ProtoMessage() {}
func (*NestedMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } func (*NestedMsg) Descriptor() ([]byte, []int) {
return fileDescriptor_sample_fde2d2951f3e63f3, []int{1}
}
func (m *NestedMsg) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NestedMsg.Unmarshal(m, b)
}
func (m *NestedMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NestedMsg.Marshal(b, m, deterministic)
}
func (dst *NestedMsg) XXX_Merge(src proto.Message) {
xxx_messageInfo_NestedMsg.Merge(dst, src)
}
func (m *NestedMsg) XXX_Size() int {
return xxx_messageInfo_NestedMsg.Size(m)
}
func (m *NestedMsg) XXX_DiscardUnknown() {
xxx_messageInfo_NestedMsg.DiscardUnknown(m)
}
var xxx_messageInfo_NestedMsg proto.InternalMessageInfo
func (m *NestedMsg) GetPlainNestedField() *SimpleMsg { func (m *NestedMsg) GetPlainNestedField() *SimpleMsg {
if m != nil { if m != nil {
...@@ -102,15 +132,37 @@ func (m *NestedMsg) GetSliceNestedField() []*SimpleMsg { ...@@ -102,15 +132,37 @@ func (m *NestedMsg) GetSliceNestedField() []*SimpleMsg {
// StaticallyOpaqueMsg is designed to test the statically opaque message component // StaticallyOpaqueMsg is designed to test the statically opaque message component
// All fields are statically marshaled to the NestedMsg type // All fields are statically marshaled to the NestedMsg type
type StaticallyOpaqueMsg struct { type StaticallyOpaqueMsg struct {
PlainOpaqueField []byte `protobuf:"bytes,1,opt,name=plain_opaque_field,json=plainOpaqueField,proto3" json:"plain_opaque_field,omitempty"` PlainOpaqueField []byte `protobuf:"bytes,1,opt,name=plain_opaque_field,json=plainOpaqueField,proto3" json:"plain_opaque_field,omitempty"`
MapOpaqueField map[string][]byte `protobuf:"bytes,2,rep,name=map_opaque_field,json=mapOpaqueField" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value,proto3"` MapOpaqueField map[string][]byte `protobuf:"bytes,2,rep,name=map_opaque_field,json=mapOpaqueField" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value,proto3"`
SliceOpaqueField [][]byte `protobuf:"bytes,3,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_opaque_field,omitempty"` SliceOpaqueField [][]byte `protobuf:"bytes,3,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_opaque_field,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StaticallyOpaqueMsg) Reset() { *m = StaticallyOpaqueMsg{} }
func (m *StaticallyOpaqueMsg) String() string { return proto.CompactTextString(m) }
func (*StaticallyOpaqueMsg) ProtoMessage() {}
func (*StaticallyOpaqueMsg) Descriptor() ([]byte, []int) {
return fileDescriptor_sample_fde2d2951f3e63f3, []int{2}
}
func (m *StaticallyOpaqueMsg) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StaticallyOpaqueMsg.Unmarshal(m, b)
}
func (m *StaticallyOpaqueMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StaticallyOpaqueMsg.Marshal(b, m, deterministic)
}
func (dst *StaticallyOpaqueMsg) XXX_Merge(src proto.Message) {
xxx_messageInfo_StaticallyOpaqueMsg.Merge(dst, src)
}
func (m *StaticallyOpaqueMsg) XXX_Size() int {
return xxx_messageInfo_StaticallyOpaqueMsg.Size(m)
}
func (m *StaticallyOpaqueMsg) XXX_DiscardUnknown() {
xxx_messageInfo_StaticallyOpaqueMsg.DiscardUnknown(m)
} }
func (m *StaticallyOpaqueMsg) Reset() { *m = StaticallyOpaqueMsg{} } var xxx_messageInfo_StaticallyOpaqueMsg proto.InternalMessageInfo
func (m *StaticallyOpaqueMsg) String() string { return proto.CompactTextString(m) }
func (*StaticallyOpaqueMsg) ProtoMessage() {}
func (*StaticallyOpaqueMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *StaticallyOpaqueMsg) GetPlainOpaqueField() []byte { func (m *StaticallyOpaqueMsg) GetPlainOpaqueField() []byte {
if m != nil { if m != nil {
...@@ -136,16 +188,38 @@ func (m *StaticallyOpaqueMsg) GetSliceOpaqueField() [][]byte { ...@@ -136,16 +188,38 @@ func (m *StaticallyOpaqueMsg) GetSliceOpaqueField() [][]byte {
// VariablyOpaqueMsg is designed to test the staticaly opaque message component // VariablyOpaqueMsg is designed to test the staticaly opaque message component
// The opaque type is determined by opaque_type // The opaque type is determined by opaque_type
type VariablyOpaqueMsg struct { type VariablyOpaqueMsg struct {
OpaqueType string `protobuf:"bytes,1,opt,name=opaque_type,json=opaqueType" json:"opaque_type,omitempty"` OpaqueType string `protobuf:"bytes,1,opt,name=opaque_type,json=opaqueType" json:"opaque_type,omitempty"`
PlainOpaqueField []byte `protobuf:"bytes,2,opt,name=plain_opaque_field,json=plainOpaqueField,proto3" json:"plain_opaque_field,omitempty"` PlainOpaqueField []byte `protobuf:"bytes,2,opt,name=plain_opaque_field,json=plainOpaqueField,proto3" json:"plain_opaque_field,omitempty"`
MapOpaqueField map[string][]byte `protobuf:"bytes,3,rep,name=map_opaque_field,json=mapOpaqueField" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value,proto3"` MapOpaqueField map[string][]byte `protobuf:"bytes,3,rep,name=map_opaque_field,json=mapOpaqueField" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value,proto3"`
SliceOpaqueField [][]byte `protobuf:"bytes,4,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_opaque_field,omitempty"` SliceOpaqueField [][]byte `protobuf:"bytes,4,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_opaque_field,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *VariablyOpaqueMsg) Reset() { *m = VariablyOpaqueMsg{} } func (m *VariablyOpaqueMsg) Reset() { *m = VariablyOpaqueMsg{} }
func (m *VariablyOpaqueMsg) String() string { return proto.CompactTextString(m) } func (m *VariablyOpaqueMsg) String() string { return proto.CompactTextString(m) }
func (*VariablyOpaqueMsg) ProtoMessage() {} func (*VariablyOpaqueMsg) ProtoMessage() {}
func (*VariablyOpaqueMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } func (*VariablyOpaqueMsg) Descriptor() ([]byte, []int) {
return fileDescriptor_sample_fde2d2951f3e63f3, []int{3}
}
func (m *VariablyOpaqueMsg) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_VariablyOpaqueMsg.Unmarshal(m, b)
}
func (m *VariablyOpaqueMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_VariablyOpaqueMsg.Marshal(b, m, deterministic)
}
func (dst *VariablyOpaqueMsg) XXX_Merge(src proto.Message) {
xxx_messageInfo_VariablyOpaqueMsg.Merge(dst, src)
}
func (m *VariablyOpaqueMsg) XXX_Size() int {
return xxx_messageInfo_VariablyOpaqueMsg.Size(m)
}
func (m *VariablyOpaqueMsg) XXX_DiscardUnknown() {
xxx_messageInfo_VariablyOpaqueMsg.DiscardUnknown(m)
}
var xxx_messageInfo_VariablyOpaqueMsg proto.InternalMessageInfo
func (m *VariablyOpaqueMsg) GetOpaqueType() string { func (m *VariablyOpaqueMsg) GetOpaqueType() string {
if m != nil { if m != nil {
...@@ -179,16 +253,38 @@ func (m *VariablyOpaqueMsg) GetSliceOpaqueField() [][]byte { ...@@ -179,16 +253,38 @@ func (m *VariablyOpaqueMsg) GetSliceOpaqueField() [][]byte {
// The dynamic wrapper applied to ContextlessMsg is determined by // The dynamic wrapper applied to ContextlessMsg is determined by
// dynamic_type // dynamic_type
type DynamicMsg struct { type DynamicMsg struct {
DynamicType string `protobuf:"bytes,1,opt,name=dynamic_type,json=dynamicType" json:"dynamic_type,omitempty"` DynamicType string `protobuf:"bytes,1,opt,name=dynamic_type,json=dynamicType" json:"dynamic_type,omitempty"`
PlainDynamicField *ContextlessMsg `protobuf:"bytes,2,opt,name=plain_dynamic_field,json=plainDynamicField" json:"plain_dynamic_field,omitempty"` PlainDynamicField *ContextlessMsg `protobuf:"bytes,2,opt,name=plain_dynamic_field,json=plainDynamicField" json:"plain_dynamic_field,omitempty"`
MapDynamicField map[string]*ContextlessMsg `protobuf:"bytes,3,rep,name=map_dynamic_field,json=mapDynamicField" json:"map_dynamic_field,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` MapDynamicField map[string]*ContextlessMsg `protobuf:"bytes,3,rep,name=map_dynamic_field,json=mapDynamicField" json:"map_dynamic_field,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
SliceDynamicField []*ContextlessMsg `protobuf:"bytes,4,rep,name=slice_dynamic_field,json=sliceDynamicField" json:"slice_dynamic_field,omitempty"` SliceDynamicField []*ContextlessMsg `protobuf:"bytes,4,rep,name=slice_dynamic_field,json=sliceDynamicField" json:"slice_dynamic_field,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *DynamicMsg) Reset() { *m = DynamicMsg{} } func (m *DynamicMsg) Reset() { *m = DynamicMsg{} }
func (m *DynamicMsg) String() string { return proto.CompactTextString(m) } func (m *DynamicMsg) String() string { return proto.CompactTextString(m) }
func (*DynamicMsg) ProtoMessage() {} func (*DynamicMsg) ProtoMessage() {}
func (*DynamicMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } func (*DynamicMsg) Descriptor() ([]byte, []int) {
return fileDescriptor_sample_fde2d2951f3e63f3, []int{4}
}
func (m *DynamicMsg) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DynamicMsg.Unmarshal(m, b)
}
func (m *DynamicMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DynamicMsg.Marshal(b, m, deterministic)
}
func (dst *DynamicMsg) XXX_Merge(src proto.Message) {
xxx_messageInfo_DynamicMsg.Merge(dst, src)
}
func (m *DynamicMsg) XXX_Size() int {
return xxx_messageInfo_DynamicMsg.Size(m)
}
func (m *DynamicMsg) XXX_DiscardUnknown() {
xxx_messageInfo_DynamicMsg.DiscardUnknown(m)
}
var xxx_messageInfo_DynamicMsg proto.InternalMessageInfo
func (m *DynamicMsg) GetDynamicType() string { func (m *DynamicMsg) GetDynamicType() string {
if m != nil { if m != nil {
...@@ -222,13 +318,35 @@ func (m *DynamicMsg) GetSliceDynamicField() []*ContextlessMsg { ...@@ -222,13 +318,35 @@ func (m *DynamicMsg) GetSliceDynamicField() []*ContextlessMsg {
// Because there is no context for the type embedded in the message, the opaque // Because there is no context for the type embedded in the message, the opaque
// type must be dynamically added at runtime // type must be dynamically added at runtime
type ContextlessMsg struct { type ContextlessMsg struct {
OpaqueField []byte `protobuf:"bytes,1,opt,name=opaque_field,json=opaqueField,proto3" json:"opaque_field,omitempty"` OpaqueField []byte `protobuf:"bytes,1,opt,name=opaque_field,json=opaqueField,proto3" json:"opaque_field,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ContextlessMsg) Reset() { *m = ContextlessMsg{} }
func (m *ContextlessMsg) String() string { return proto.CompactTextString(m) }
func (*ContextlessMsg) ProtoMessage() {}
func (*ContextlessMsg) Descriptor() ([]byte, []int) {
return fileDescriptor_sample_fde2d2951f3e63f3, []int{5}
}
func (m *ContextlessMsg) XXX_Unmarshal(b []byte) error {