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 @@
"protoc-gen-go",
"protoc-gen-go/descriptor",
"protoc-gen-go/generator",
"protoc-gen-go/generator/internal/remap",
"protoc-gen-go/grpc",
"protoc-gen-go/plugin",
"ptypes",
......@@ -185,7 +186,8 @@
"ptypes/struct",
"ptypes/timestamp"
]
revision = "fec3b39b059c0f88fa6b20f5ed012b1aa203a8b4"
revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
version = "v1.1.0"
[[projects]]
branch = "master"
......@@ -635,6 +637,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "cfc117a7d01b8ba0859a4d444c9467aee912043423228f20bbff1c5642e59d2a"
inputs-digest = "c20fcba8a0db19d3c1436b5b2796d7acd03a73a7336da0bff52847b93fdbc962"
solver-name = "gps-cdcl"
solver-version = 1
......@@ -37,7 +37,7 @@ ignored = [
[[constraint]]
name = "github.com/golang/protobuf"
revision = "fec3b39b059c0f88fa6b20f5ed012b1aa203a8b4"
version = "1.1.0"
[[constraint]]
name = "github.com/gorilla/mux"
......
......@@ -10,6 +10,7 @@ import (
"io"
"time"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/hyperledger/fabric/common/deliver"
"github.com/hyperledger/fabric/common/deliver/mock"
......@@ -190,7 +191,7 @@ var _ = Describe("Deliver", func() {
Expect(fakeInspector.InspectCallCount()).To(Equal(1))
ctx, header := fakeInspector.InspectArgsForCall(0)
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() {
......@@ -230,7 +231,7 @@ var _ = Describe("Deliver", func() {
Expect(fakePolicyChecker.CheckPolicyCallCount()).To(BeNumerically(">=", 1))
e, cid := fakePolicyChecker.CheckPolicyArgsForCall(0)
Expect(e).To(Equal(envelope))
Expect(proto.Equal(e, envelope)).To(BeTrue())
Expect(cid).To(Equal("chain-id"))
})
......@@ -240,7 +241,7 @@ var _ = Describe("Deliver", func() {
Expect(fakeBlockReader.IteratorCallCount()).To(Equal(1))
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() {
......
......@@ -28,6 +28,8 @@ import (
"reflect"
"runtime"
"testing"
"github.com/golang/protobuf/proto"
)
// AssertNil varifies that the value is nil
......@@ -63,6 +65,14 @@ func AssertEquals(t testing.TB, actual interface{}, expected interface{}) {
actual = convertJSONToMap(actual)
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) {
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) {
v := reflect.Indirect(reflect.ValueOf(msp.MSPPrincipal{}))
// Ensure msp.MSPPrincipal has only 2 fields.
// 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) {
......
......@@ -39,13 +39,20 @@ var (
Data: &cb.BlockData{
Data: [][]byte{
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"),
}),
},
},
}
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) {
......@@ -82,7 +89,7 @@ func TestProtolatorEncode(t *testing.T) {
err := proto.Unmarshal(rec.Body.Bytes(), outputMsg)
assert.NoError(t, err)
assert.Equal(t, testProto, outputMsg)
assert.True(t, proto.Equal(testProto, outputMsg))
}
func TestProtolatorDecodeNonExistantProto(t *testing.T) {
......
......@@ -8,6 +8,7 @@ package protolator_test
import (
"bytes"
"os"
"testing"
"github.com/hyperledger/fabric/common/tools/configtxgen/configtxgentest"
......@@ -73,3 +74,21 @@ func TestGenesisBlock(t *testing.T) {
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 {
}
func (pf *plainField) PopulateFrom(source interface{}) error {
if source == nil {
return nil
}
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)
}
......@@ -94,6 +98,11 @@ func (pf *plainField) PopulateTo() (interface{}, error) {
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)
}
if pf.value.Type().Kind() == reflect.Ptr && pf.value.IsNil() {
return nil, nil
}
value, err := pf.populateTo(pf.value)
if err != nil {
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 {
// protoToJSON is a simple shortcut wrapper around the proto JSON marshaler
func protoToJSON(msg proto.Message) ([]byte, error) {
if reflect.ValueOf(msg).IsNil() {
panic("We're nil here")
}
var b bytes.Buffer
m := jsonpb.Marshaler{
EnumsAsInts: false,
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: sample.proto
/*
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
package testprotos // import "github.com/hyperledger/fabric/common/tools/protolator/testprotos"
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
......@@ -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,
// and slice are handled by the protolator tool
type SimpleMsg struct {
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"`
SliceField []string `protobuf:"bytes,3,rep,name=slice_field,json=sliceField" json:"slice_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"`
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) String() string { return proto.CompactTextString(m) }
func (*SimpleMsg) ProtoMessage() {}
func (*SimpleMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
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_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 {
if m != nil {
......@@ -68,15 +76,37 @@ func (m *SimpleMsg) GetSliceField() []string {
// NestedMsg is designed to test the nested message component
type NestedMsg struct {
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"`
SliceNestedField []*SimpleMsg `protobuf:"bytes,3,rep,name=slice_nested_field,json=sliceNestedField" json:"slice_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"`
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) String() string { return proto.CompactTextString(m) }
func (*NestedMsg) ProtoMessage() {}
func (*NestedMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *NestedMsg) Reset() { *m = NestedMsg{} }
func (m *NestedMsg) String() string { return proto.CompactTextString(m) }
func (*NestedMsg) ProtoMessage() {}
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 {
if m != nil {
......@@ -102,15 +132,37 @@ func (m *NestedMsg) GetSliceNestedField() []*SimpleMsg {
// StaticallyOpaqueMsg is designed to test the statically opaque message component
// All fields are statically marshaled to the NestedMsg type
type StaticallyOpaqueMsg struct {
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"`
SliceOpaqueField [][]byte `protobuf:"bytes,3,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_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"`
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{} }
func (m *StaticallyOpaqueMsg) String() string { return proto.CompactTextString(m) }
func (*StaticallyOpaqueMsg) ProtoMessage() {}
func (*StaticallyOpaqueMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
var xxx_messageInfo_StaticallyOpaqueMsg proto.InternalMessageInfo
func (m *StaticallyOpaqueMsg) GetPlainOpaqueField() []byte {
if m != nil {
......@@ -136,16 +188,38 @@ func (m *StaticallyOpaqueMsg) GetSliceOpaqueField() [][]byte {
// VariablyOpaqueMsg is designed to test the staticaly opaque message component
// The opaque type is determined by opaque_type
type VariablyOpaqueMsg struct {
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"`
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"`
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"`
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"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *VariablyOpaqueMsg) Reset() { *m = VariablyOpaqueMsg{} }
func (m *VariablyOpaqueMsg) String() string { return proto.CompactTextString(m) }
func (*VariablyOpaqueMsg) ProtoMessage() {}
func (*VariablyOpaqueMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *VariablyOpaqueMsg) Reset() { *m = VariablyOpaqueMsg{} }
func (m *VariablyOpaqueMsg) String() string { return proto.CompactTextString(m) }
func (*VariablyOpaqueMsg) ProtoMessage() {}
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 {
if m != nil {
......@@ -179,16 +253,38 @@ func (m *VariablyOpaqueMsg) GetSliceOpaqueField() [][]byte {
// The dynamic wrapper applied to ContextlessMsg is determined by
// dynamic_type
type DynamicMsg struct {
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"`
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"`
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"`
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"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DynamicMsg) Reset() { *m = DynamicMsg{} }
func (m *DynamicMsg) String() string { return proto.CompactTextString(m) }
func (*DynamicMsg) ProtoMessage() {}
func (*DynamicMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *DynamicMsg) Reset() { *m = DynamicMsg{} }
func (m *DynamicMsg) String() string { return proto.CompactTextString(m) }
func (*DynamicMsg) ProtoMessage() {}
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 {
if m != nil {
......@@ -222,13 +318,35 @@ func (m *DynamicMsg) GetSliceDynamicField() []*ContextlessMsg {
// Because there is no context for the type embedded in the message, the opaque
// type must be dynamically added at runtime
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 {
return xxx_messageInfo_ContextlessMsg.Unmarshal(m, b)
}
func (m *ContextlessMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ContextlessMsg.Marshal(b, m, deterministic)
}
func (dst *ContextlessMsg) XXX_Merge(src proto.Message) {
xxx_messageInfo_ContextlessMsg.Merge(dst, src)
}
func (m *ContextlessMsg) XXX_Size() int {
return xxx_messageInfo_ContextlessMsg.Size(m)
}
func (m *ContextlessMsg) XXX_DiscardUnknown() {
xxx_messageInfo_ContextlessMsg.DiscardUnknown(m)
}
func (m *ContextlessMsg) Reset() { *m = ContextlessMsg{} }
func (m *ContextlessMsg) String() string { return proto.CompactTextString(m) }
func (*ContextlessMsg) ProtoMessage() {}
func (*ContextlessMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
var xxx_messageInfo_ContextlessMsg proto.InternalMessageInfo
func (m *ContextlessMsg) GetOpaqueField() []byte {
if m != nil {
......@@ -239,16 +357,21 @@ func (m *ContextlessMsg) GetOpaqueField() []byte {
func init() {
proto.RegisterType((*SimpleMsg)(nil), "testprotos.SimpleMsg")
proto.RegisterMapType((map[string]string)(nil), "testprotos.SimpleMsg.MapFieldEntry")
proto.RegisterType((*NestedMsg)(nil), "testprotos.NestedMsg")
proto.RegisterMapType((map[string]*SimpleMsg)(nil), "testprotos.NestedMsg.MapNestedFieldEntry")
proto.RegisterType((*StaticallyOpaqueMsg)(nil), "testprotos.StaticallyOpaqueMsg")
proto.RegisterMapType((map[string][]byte)(nil), "testprotos.StaticallyOpaqueMsg.MapOpaqueFieldEntry")
proto.RegisterType((*VariablyOpaqueMsg)(nil), "testprotos.VariablyOpaqueMsg")
proto.RegisterMapType((map[string][]byte)(nil), "testprotos.VariablyOpaqueMsg.MapOpaqueFieldEntry")
proto.RegisterType((*DynamicMsg)(nil), "testprotos.DynamicMsg")
proto.RegisterMapType((map[string]*ContextlessMsg)(nil), "testprotos.DynamicMsg.MapDynamicFieldEntry")
proto.RegisterType((*ContextlessMsg)(nil), "testprotos.ContextlessMsg")
}
func init() { proto.RegisterFile("sample.proto", fileDescriptor0) }
func init() { proto.RegisterFile("sample.proto", fileDescriptor_sample_fde2d2951f3e63f3) }
var fileDescriptor0 = []byte{
var fileDescriptor_sample_fde2d2951f3e63f3 = []byte{
// 577 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x41, 0x6f, 0xd3, 0x30,
0x14, 0xc7, 0xd5, 0x64, 0x20, 0xfa, 0x12, 0x46, 0x9b, 0x0e, 0x69, 0xca, 0x65, 0x65, 0x5c, 0x86,
......
......@@ -357,7 +357,7 @@ var _ = Describe("Handler", func() {
msg := fakeChatStream.SendArgsForCall(0)
Expect(msg.Type).To(Equal(pb.ChaincodeMessage_ERROR))
Expect(msg.Txid).To(Equal("tx-id"))
Expect(string(msg.Payload)).To(HavePrefix("INVOKE_CHAINCODE failed: transaction ID: tx-id: unmarshal failed: proto: peer.ChaincodeSpec: "))
Expect(string(msg.Payload)).To(HavePrefix("INVOKE_CHAINCODE failed: transaction ID: tx-id: unmarshal failed: proto: "))
})
})
})
......@@ -420,7 +420,7 @@ var _ = Describe("Handler", func() {
It("returns an error", func() {
_, err := handler.HandlePutState(incomingMessage, txContext)
Expect(err).To(MatchError("unmarshal failed: proto: peer.PutState: wiretype end group for non-group"))
Expect(err).To(MatchError("unmarshal failed: proto: can't skip unknown wire type 4"))
})
})
......@@ -517,7 +517,7 @@ var _ = Describe("Handler", func() {
It("returns an error", func() {
_, err := handler.HandleDelState(incomingMessage, txContext)
Expect(err).To(MatchError("unmarshal failed: proto: peer.DelState: wiretype end group for non-group"))
Expect(err).To(MatchError("unmarshal failed: proto: can't skip unknown wire type 4"))
})
})
......@@ -611,7 +611,7 @@ var _ = Describe("Handler", func() {
It("returns an error", func() {
_, err := handler.HandleGetState(incomingMessage, txContext)
Expect(err).To(MatchError("unmarshal failed: proto: peer.GetState: wiretype end group for non-group"))
Expect(err).To(MatchError("unmarshal failed: proto: can't skip unknown wire type 4"))
})
})
......@@ -833,7 +833,7 @@ var _ = Describe("Handler", func() {
It("returns an error", func() {
_, err := handler.HandleGetStateByRange(incomingMessage, txContext)
Expect(err).To(MatchError("unmarshal failed: proto: peer.GetStateByRange: wiretype end group for non-group"))
Expect(err).To(MatchError("unmarshal failed: proto: can't skip unknown wire type 4"))
})
})
......@@ -943,7 +943,7 @@ var _ = Describe("Handler", func() {
It("returns an error", func() {
_, err := handler.HandleQueryStateNext(incomingMessage, txContext)
Expect(err).To(MatchError("unmarshal failed: proto: peer.QueryStateNext: wiretype end group for non-group"))
Expect(err).To(MatchError("unmarshal failed: proto: can't skip unknown wire type 4"))
})
})
......@@ -1050,7 +1050,7 @@ var _ = Describe("Handler", func() {
It("returns an error", func() {
_, err := handler.HandleQueryStateClose(incomingMessage, txContext)
Expect(err).To(MatchError("unmarshal failed: proto: peer.QueryStateClose: wiretype end group for non-group"))
Expect(err).To(MatchError("unmarshal failed: proto: can't skip unknown wire type 4"))
})
})
......@@ -1201,7 +1201,7 @@ var _ = Describe("Handler", func() {
It("returns an error", func() {
_, err := handler.HandleGetQueryResult(incomingMessage, txContext)
Expect(err).To(MatchError("unmarshal failed: proto: peer.GetQueryResult: wiretype end group for non-group"))
Expect(err).To(MatchError("unmarshal failed: proto: can't skip unknown wire type 4"))
})
})
......@@ -1295,7 +1295,7 @@ var _ = Describe("Handler", func() {
It("returns an erro