diff --git a/cmd/configtxgen/main.go b/cmd/configtxgen/main.go index 42dd2c47d72..28338ab2a6f 100644 --- a/cmd/configtxgen/main.go +++ b/cmd/configtxgen/main.go @@ -15,12 +15,12 @@ import ( "strings" "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/protolator" + "github.com/hyperledger/fabric-config/protolator/protoext/ordererext" cb "github.com/hyperledger/fabric-protos-go/common" "github.com/hyperledger/fabric/bccsp/factory" "github.com/hyperledger/fabric/common/channelconfig" "github.com/hyperledger/fabric/common/flogging" - "github.com/hyperledger/fabric/common/tools/protolator" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/ordererext" "github.com/hyperledger/fabric/internal/configtxgen/encoder" "github.com/hyperledger/fabric/internal/configtxgen/genesisconfig" "github.com/hyperledger/fabric/internal/configtxgen/metadata" diff --git a/cmd/configtxlator/main.go b/cmd/configtxlator/main.go index a9e7af9a5d1..5323edef2f9 100644 --- a/cmd/configtxlator/main.go +++ b/cmd/configtxlator/main.go @@ -15,6 +15,7 @@ import ( "reflect" "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/protolator" _ "github.com/hyperledger/fabric-protos-go/common" cb "github.com/hyperledger/fabric-protos-go/common" // Import these to register the proto types _ "github.com/hyperledger/fabric-protos-go/msp" @@ -22,7 +23,6 @@ import ( _ "github.com/hyperledger/fabric-protos-go/orderer/etcdraft" _ "github.com/hyperledger/fabric-protos-go/peer" "github.com/hyperledger/fabric/common/flogging" - "github.com/hyperledger/fabric/common/tools/protolator" "github.com/hyperledger/fabric/internal/configtxlator/metadata" "github.com/hyperledger/fabric/internal/configtxlator/rest" "github.com/hyperledger/fabric/internal/configtxlator/update" diff --git a/common/tools/protolator/dynamic_test.go b/common/tools/protolator/dynamic_test.go deleted file mode 100644 index f01588fd97d..00000000000 --- a/common/tools/protolator/dynamic_test.go +++ /dev/null @@ -1,123 +0,0 @@ -/* -Copyright IBM Corp. 2017 All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package protolator - -import ( - "bytes" - "testing" - - "github.com/hyperledger/fabric/common/tools/protolator/testprotos" - "github.com/hyperledger/fabric/protoutil" - "github.com/stretchr/testify/assert" -) - -func TestPlainDynamicMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff, variablyOpaqueFieldFactory{}} - - pfValue := "foo" - startMsg := &testprotos.DynamicMsg{ - DynamicType: "SimpleMsg", - PlainDynamicField: &testprotos.ContextlessMsg{ - OpaqueField: protoutil.MarshalOrPanic(&testprotos.SimpleMsg{ - PlainField: pfValue, - }), - }, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.DynamicMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.PlainDynamicField.OpaqueField), extractSimpleMsgPlainField(newMsg.PlainDynamicField.OpaqueField)) - - fieldFactories = []protoFieldFactory{tppff, variablyOpaqueFieldFactory{}, dynamicFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.PlainDynamicField.OpaqueField), extractSimpleMsgPlainField(newMsg.PlainDynamicField.OpaqueField)) -} - -func TestMapDynamicMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff, variablyOpaqueFieldFactory{}} - - pfValue := "foo" - mapKey := "bar" - startMsg := &testprotos.DynamicMsg{ - DynamicType: "SimpleMsg", - MapDynamicField: map[string]*testprotos.ContextlessMsg{ - mapKey: { - OpaqueField: protoutil.MarshalOrPanic(&testprotos.SimpleMsg{ - PlainField: pfValue, - }), - }, - }, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.DynamicMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.MapDynamicField[mapKey].OpaqueField), extractSimpleMsgPlainField(newMsg.MapDynamicField[mapKey].OpaqueField)) - - fieldFactories = []protoFieldFactory{tppff, variablyOpaqueFieldFactory{}, dynamicMapFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.MapDynamicField[mapKey].OpaqueField), extractSimpleMsgPlainField(newMsg.MapDynamicField[mapKey].OpaqueField)) -} - -func TestSliceDynamicMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff, variablyOpaqueFieldFactory{}} - - pfValue := "foo" - startMsg := &testprotos.DynamicMsg{ - DynamicType: "SimpleMsg", - SliceDynamicField: []*testprotos.ContextlessMsg{ - { - OpaqueField: protoutil.MarshalOrPanic(&testprotos.SimpleMsg{ - PlainField: pfValue, - }), - }, - }, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.DynamicMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.SliceDynamicField[0].OpaqueField), extractSimpleMsgPlainField(newMsg.SliceDynamicField[0].OpaqueField)) - - fieldFactories = []protoFieldFactory{tppff, variablyOpaqueFieldFactory{}, dynamicSliceFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.SliceDynamicField[0].OpaqueField), extractSimpleMsgPlainField(newMsg.SliceDynamicField[0].OpaqueField)) -} diff --git a/common/tools/protolator/integration/integration_test.go b/common/tools/protolator/integration/integration_test.go deleted file mode 100644 index c4a5cbe4d36..00000000000 --- a/common/tools/protolator/integration/integration_test.go +++ /dev/null @@ -1,259 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package integration - -import ( - "bytes" - "io/ioutil" - "os" - "testing" - - "github.com/golang/protobuf/proto" - cb "github.com/hyperledger/fabric-protos-go/common" - "github.com/hyperledger/fabric-protos-go/msp" - pb "github.com/hyperledger/fabric-protos-go/peer" - "github.com/hyperledger/fabric/common/tools/protolator" - "github.com/hyperledger/fabric/core/config/configtest" - "github.com/hyperledger/fabric/internal/configtxgen/encoder" - "github.com/hyperledger/fabric/internal/configtxgen/genesisconfig" - "github.com/hyperledger/fabric/protoutil" - . "github.com/onsi/gomega" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func bidirectionalMarshal(t *testing.T, doc proto.Message) { - var buffer bytes.Buffer - - assert.NoError(t, protolator.DeepMarshalJSON(&buffer, doc)) - - newRoot := proto.Clone(doc) - newRoot.Reset() - assert.NoError(t, protolator.DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newRoot)) - - // Note, we cannot do an equality check between newRoot and sampleDoc - // because of the nondeterministic nature of binary proto marshaling - // So instead we re-marshal to JSON which is a deterministic marshaling - // and compare equality there instead - - //t.Log(doc) - //t.Log(newRoot) - - var remarshaled bytes.Buffer - assert.NoError(t, protolator.DeepMarshalJSON(&remarshaled, newRoot)) - assert.Equal(t, buffer.String(), remarshaled.String()) - //t.Log(buffer.String()) - //t.Log(remarshaled.String()) -} - -func TestConfigUpdate(t *testing.T) { - cg, err := encoder.NewChannelGroup(genesisconfig.Load(genesisconfig.SampleSingleMSPSoloProfile, configtest.GetDevConfigDir())) - assert.NoError(t, err) - - bidirectionalMarshal(t, &cb.ConfigUpdateEnvelope{ - ConfigUpdate: protoutil.MarshalOrPanic(&cb.ConfigUpdate{ - ReadSet: cg, - WriteSet: cg, - }), - }) -} - -func TestIdemix(t *testing.T) { - bidirectionalMarshal(t, &msp.MSPConfig{ - Type: 1, - Config: protoutil.MarshalOrPanic(&msp.IdemixMSPConfig{ - Name: "fooo", - }), - }) -} - -func TestGenesisBlock(t *testing.T) { - p := encoder.New(genesisconfig.Load(genesisconfig.SampleSingleMSPSoloProfile, configtest.GetDevConfigDir())) - gb := p.GenesisBlockForChannel("foo") - - bidirectionalMarshal(t, gb) -} - -func TestEmitDefaultsBug(t *testing.T) { - block := &cb.Block{ - Header: &cb.BlockHeader{ - PreviousHash: []byte("foo"), - }, - Data: &cb.BlockData{ - Data: [][]byte{ - protoutil.MarshalOrPanic(&cb.Envelope{ - Payload: protoutil.MarshalOrPanic(&cb.Payload{ - Header: &cb.Header{ - ChannelHeader: protoutil.MarshalOrPanic(&cb.ChannelHeader{ - Type: int32(cb.HeaderType_CONFIG), - }), - }, - }), - Signature: []byte("bar"), - }), - }, - }, - } - - err := protolator.DeepMarshalJSON(os.Stdout, block) - assert.NoError(t, err) -} - -func TestProposalResponsePayload(t *testing.T) { - prp := &pb.ProposalResponsePayload{} - assert.NoError(t, protolator.DeepUnmarshalJSON(bytes.NewReader([]byte(`{ - "extension": { - "chaincode_id": { - "name": "test", - "path": "", - "version": "1.0" - }, - "events": { - "chaincode_id": "test" - }, - "response": { - "message": "", - "payload": null, - "status": 200 - }, - "results": { - "data_model": "KV", - "ns_rwset": [ - { - "collection_hashed_rwset": [], - "namespace": "lscc", - "rwset": { - "metadata_writes": [], - "range_queries_info": [], - "reads": [ - { - "key": "cc1", - "version": { - "block_num": "3", - "tx_num": "0" - } - }, - { - "key": "cc2", - "version": { - "block_num": "4", - "tx_num": "0" - } - } - ], - "writes": [] - } - }, - { - "collection_hashed_rwset": [], - "namespace": "cc1", - "rwset": { - "metadata_writes": [], - "range_queries_info": [], - "reads": [ - { - "key": "key1", - "version": { - "block_num": "8", - "tx_num": "0" - } - } - ], - "writes": [ - { - "is_delete": false, - "key": "key2" - } - ] - } - }, - { - "collection_hashed_rwset": [], - "namespace": "cc2", - "rwset": { - "metadata_writes": [], - "range_queries_info": [], - "reads": [ - { - "key": "key1", - "version": { - "block_num": "9", - "tx_num": "0" - } - }, - { - "key": "key2", - "version": { - "block_num": "10", - "tx_num": "0" - } - } - ], - "writes": [ - { - "is_delete": false, - "key": "key1" - }, - { - "is_delete": true, - "key": "key2" - } - ] - } - } - ] - } - } - }`)), prp)) - bidirectionalMarshal(t, prp) -} - -func TestChannelCreationPolicy(t *testing.T) { - cu := &cb.ConfigUpdate{ - WriteSet: &cb.ConfigGroup{ - Groups: map[string]*cb.ConfigGroup{ - "Consortiums": { - Groups: map[string]*cb.ConfigGroup{ - "SampleConsortium": { - Values: map[string]*cb.ConfigValue{ - "ChannelCreationPolicy": { - Version: 0, - }, - }, - }, - }, - }, - }, - }, - } - - bidirectionalMarshal(t, cu) -} - -func TestStaticMarshal(t *testing.T) { - // To generate artifacts: - // e.g. - // FABRICPATH=$GOPATH/src/github.com/hyperledger/fabric - // configtxgen -channelID test -outputBlock block.pb -profile SampleSingleMSPSolo -configPath FABRICPATH/sampleconfig - // configtxgen -configPath FABRICPATH/sampleconfig -inspectBlock block.pb > block.json - - blockBin, err := ioutil.ReadFile("testdata/block.pb") - require.NoError(t, err) - - block := &cb.Block{} - err = proto.Unmarshal(blockBin, block) - require.NoError(t, err) - - jsonBin, err := ioutil.ReadFile("testdata/block.json") - require.NoError(t, err) - - buf := &bytes.Buffer{} - require.NoError(t, protolator.DeepMarshalJSON(buf, block)) - - gt := NewGomegaWithT(t) - gt.Expect(buf).To(MatchJSON(jsonBin)) -} diff --git a/common/tools/protolator/integration/testdata/block.json b/common/tools/protolator/integration/testdata/block.json deleted file mode 100644 index b6b27a2488d..00000000000 --- a/common/tools/protolator/integration/testdata/block.json +++ /dev/null @@ -1,591 +0,0 @@ -{ - "data": { - "data": [ - { - "payload": { - "data": { - "config": { - "channel_group": { - "groups": { - "Consortiums": { - "groups": { - "SampleConsortium": { - "groups": { - "SampleOrg": { - "groups": {}, - "mod_policy": "Admins", - "policies": { - "Admins": { - "mod_policy": "Admins", - "policy": { - "type": 1, - "value": { - "identities": [ - { - "principal": { - "msp_identifier": "SampleOrg", - "role": "ADMIN" - }, - "principal_classification": "ROLE" - } - ], - "rule": { - "n_out_of": { - "n": 1, - "rules": [ - { - "signed_by": 0 - } - ] - } - }, - "version": 0 - } - }, - "version": "0" - }, - "Endorsement": { - "mod_policy": "Admins", - "policy": { - "type": 1, - "value": { - "identities": [ - { - "principal": { - "msp_identifier": "SampleOrg", - "role": "MEMBER" - }, - "principal_classification": "ROLE" - } - ], - "rule": { - "n_out_of": { - "n": 1, - "rules": [ - { - "signed_by": 0 - } - ] - } - }, - "version": 0 - } - }, - "version": "0" - }, - "Readers": { - "mod_policy": "Admins", - "policy": { - "type": 1, - "value": { - "identities": [ - { - "principal": { - "msp_identifier": "SampleOrg", - "role": "MEMBER" - }, - "principal_classification": "ROLE" - } - ], - "rule": { - "n_out_of": { - "n": 1, - "rules": [ - { - "signed_by": 0 - } - ] - } - }, - "version": 0 - } - }, - "version": "0" - }, - "Writers": { - "mod_policy": "Admins", - "policy": { - "type": 1, - "value": { - "identities": [ - { - "principal": { - "msp_identifier": "SampleOrg", - "role": "MEMBER" - }, - "principal_classification": "ROLE" - } - ], - "rule": { - "n_out_of": { - "n": 1, - "rules": [ - { - "signed_by": 0 - } - ] - } - }, - "version": 0 - } - }, - "version": "0" - } - }, - "values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Q2d6SllsVzdudlp4UDdiNnRiZXUzdDhtcmhNWFFzOTU2bUQ0K0JvS3VOSQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==" - ], - "crypto_config": { - "identity_identifier_hash_function": "SHA256", - "signature_hash_family": "SHA2" - }, - "fabric_node_ous": null, - "intermediate_certs": [], - "name": "SampleOrg", - "organizational_unit_identifiers": [ - { - "certificate": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNZakNDQWdpZ0F3SUJBZ0lSQUwxZkVBbno1enA0bW9KOE1kU2IvbFl3Q2dZSUtvWkl6ajBFQXdJd2dZRXgKQ3pBSkJnTlZCQVlUQWxWVE1STXdFUVlEVlFRSUV3cERZV3hwWm05eWJtbGhNUll3RkFZRFZRUUhFdzFUWVc0ZwpSbkpoYm1OcGMyTnZNUmt3RndZRFZRUUtFeEJ2Y21jeExtVjRZVzF3YkdVdVkyOXRNUXd3Q2dZRFZRUUxFd05EClQxQXhIREFhQmdOVkJBTVRFMk5oTG05eVp6RXVaWGhoYlhCc1pTNWpiMjB3SGhjTk1UY3hNVEV5TVRNME1URXgKV2hjTk1qY3hNVEV3TVRNME1URXhXakNCZ1RFTE1Ba0dBMVVFQmhNQ1ZWTXhFekFSQmdOVkJBZ1RDa05oYkdsbQpiM0p1YVdFeEZqQVVCZ05WQkFjVERWTmhiaUJHY21GdVkybHpZMjh4R1RBWEJnTlZCQW9URUc5eVp6RXVaWGhoCmJYQnNaUzVqYjIweEREQUtCZ05WQkFzVEEwTlBVREVjTUJvR0ExVUVBeE1UWTJFdWIzSm5NUzVsZUdGdGNHeGwKTG1OdmJUQlpNQk1HQnlxR1NNNDlBZ0VHQ0NxR1NNNDlBd0VIQTBJQUJHcnNRNm9KcGs2aERXZjYzSFUzT1NOZApib3U5S053L1ZJZWUxSW5nUERJNFlKVTdPK1hhL1hMSnV3bkZ2N0JwUjhZdGwzZituakM4aS9SWlAyL3N2TytqClh6QmRNQTRHQTFVZER3RUIv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UVBeE1FVDNKbk1qQlpNQk1HQnlxR1NNNDlBZ0VHQ0NxR1NNNDlBd0VIQTBJQUJEWXkrcXpTCkovOENNZmhwQkZoVWhoeis3dXA0K2x3akJXRFNTMDFrb3N6Tmg4Y2FtSFRBOHZTNFpzTitEWjJEUnNTbVJaZ3MKdEcyb29nTExJZGg2WjFDalF6QkJNQTRHQTFVZER3RUIvd1FFQXdJQnBqQVBCZ05WSFNVRUNEQUdCZ1JWSFNVQQpNQThHQTFVZEV3RUIvd1FGTUFNQkFmOHdEUVlEVlIwT0JBWUVCQUVDQXdRd0NnWUlLb1pJemowRUF3SURTQUF3ClJRSWdXbk1tSDB5eEFqdWIzcWZ6eFFpb0hLUTgrV3ZVakFYbTBlaklkOVErckRJQ0lRRHIzMFVDUGorU1h6T2IKQ3U0cHNNTUJmTHVqS29pQk5kTEUxS0VwdDhsTjFnPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=" - ] - }, - "type": 0 - }, - "version": "0" - } - }, - "version": "0" - } - }, - "mod_policy": "/Channel/Orderer/Admins", - "policies": {}, - "values": { - "ChannelCreationPolicy": { - "mod_policy": "/Channel/Orderer/Admins", - "value": { - "type": 3, - "value": { - "rule": "ANY", - "sub_policy": "Admins" - } - }, - "version": "0" - } - }, - "version": "0" - } - }, - "mod_policy": "/Channel/Orderer/Admins", - "policies": { - "Admins": { - "mod_policy": "/Channel/Orderer/Admins", - "policy": { - "type": 1, - "value": { - "identities": [], - "rule": { - "n_out_of": { - "n": 0, - "rules": [] - } - }, - "version": 0 - } - }, - "version": "0" - } - }, - "values": {}, - "version": "0" - }, - "Orderer": { - "groups": { - "SampleOrg": { - "groups": {}, - "mod_policy": "Admins", - "policies": { - "Admins": { - "mod_policy": "Admins", - "policy": { - "type": 1, - "value": { - "identities": [ - { - "principal": { - "msp_identifier": "SampleOrg", - "role": "ADMIN" - }, - "principal_classification": "ROLE" - } - ], - "rule": { - "n_out_of": { - "n": 1, - "rules": [ - { - "signed_by": 0 - } - ] - } - }, - "version": 0 - } - }, - "version": "0" - }, - "Endorsement": { - "mod_policy": "Admins", - "policy": { - "type": 1, - "value": { - "identities": [ - { - "principal": { - "msp_identifier": "SampleOrg", - "role": "MEMBER" - }, - "principal_classification": "ROLE" - } - ], - "rule": { - "n_out_of": { - "n": 1, - "rules": [ - { - "signed_by": 0 - } - ] - } - }, - "version": 0 - } - }, - "version": "0" - }, - "Readers": { - "mod_policy": "Admins", - "policy": { - "type": 1, - "value": { - "identities": [ - { - "principal": { - "msp_identifier": "SampleOrg", - "role": "MEMBER" - }, - "principal_classification": "ROLE" - } - ], - "rule": { - "n_out_of": { - "n": 1, - "rules": [ - { - "signed_by": 0 - } - ] - } - }, - "version": 0 - } - }, - "version": "0" - }, - "Writers": { - "mod_policy": "Admins", - "policy": { - "type": 1, - "value": { - "identities": [ - { - "principal": { - "msp_identifier": "SampleOrg", - "role": "MEMBER" - }, - "principal_classification": "ROLE" - } - ], - "rule": { - "n_out_of": { - "n": 1, - "rules": [ - { - "signed_by": 0 - } - ] - } - }, - "version": 0 - } - }, - "version": "0" - } - }, - "values": { - "Endpoints": { - "mod_policy": "Admins", - "value": { - "addresses": [ - "127.0.0.1:7050" - ] - }, - "version": "0" - }, - "MSP": { - "mod_policy": "Admins", - "value": { - "config": { - "admins": [ - "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNOakNDQWQyZ0F3SUJBZ0lSQU1uZjkvZG1WOVJ2Q0NWdzlwWlFVZlV3Q2dZSUtvWkl6ajBFQXdJd2dZRXgKQ3pBSkJnTlZCQVlUQWxWVE1STXdFUVlEVlFRSUV3cERZV3hwWm05eWJtbGhNUll3RkFZRFZRUUhFdzFUWVc0ZwpSbkpoYm1OcGMyTnZNUmt3RndZRFZRUUtFeEJ2Y21jeExtVjRZVzF3YkdVdVkyOXRNUXd3Q2dZRFZRUUxFd05EClQxQXhIREFhQmdOVkJBTVRFMk5oTG05eVp6RXVaWGhoYlhCc1pTNWpiMjB3SGhjTk1UY3hNVEV5TVRNME1URXgKV2hjTk1qY3hNVEV3TVRNME1URXhXakJwTVFzd0NRWURWUVFHRXdKVlV6RVRNQkVHQTFVRUNCTUtRMkZzYVdadgpjbTVwWVRFV01CUUdBMVVFQnhNTlUyRnVJRVp5WVc1amFYTmpiekVNTUFvR0ExVUVDeE1EUTA5UU1SOHdIUVlEClZRUURFeFp3WldWeU1DNXZjbWN4TG1WNFlXMXdiR1V1WTI5dE1Ga3dFd1lIS29aSXpqMENBUVlJS29aSXpqMEQKQVFjRFFnQUVaOFM0VjcxT0JKcHlNSVZaZHdZZEZYQWNrSXRycHZTckNmMEhRZzQwV1c5WFNvT09PNzZJK1VtZgpFa21UbElKWFA3L0F5UlJTUlUzOG9JOEl2dHU0TTZOTk1Fc3dEZ1lEVlIwUEFRSC9CQVFEQWdlQU1Bd0dBMVVkCkV3RUIvd1FDTUFBd0t3WURWUjBqQkNRd0lvQWdpbk9SSWhuUEVGWlVoWG02ZVdCa203SzdaYzhSNC96N0xXNEgKb3NzRGxDc3dDZ1lJS29aSXpqMEVBd0lEUndBd1JBSWdWaWtJVVp6Z2Z1RnNHTFFIV0pVVkpDVTdwRGFFVGthegpQekZnc0NpTHhVQUNJQ2d6SllsVzdudlp4UDdiNnRiZXUzdDhtcmhNWFFzOTU2bUQ0K0JvS3VOSQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==" - ], - "crypto_config": { - "identity_identifier_hash_function": "SHA256", - "signature_hash_family": "SHA2" - }, - "fabric_node_ous": null, - "intermediate_certs": [], - "name": "SampleOrg", - "organizational_unit_identifiers": [ - { - "certificate": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNZakNDQWdpZ0F3SUJBZ0lSQUwxZkVBbno1enA0bW9KOE1kU2IvbFl3Q2dZSUtvWkl6ajBFQXdJd2dZRXgKQ3pBSkJnTlZCQVlUQWxWVE1STXdFUVlEVlFRSUV3cERZV3hwWm05eWJtbGhN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lRRHIzMFVDUGorU1h6T2IKQ3U0cHNNTUJmTHVqS29pQk5kTEUxS0VwdDhsTjFnPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=" - ] - }, - "type": 0 - }, - "version": "0" - } - }, - "version": "0" - } - }, - "mod_policy": "Admins", - "policies": { - "Admins": { - "mod_policy": "Admins", - "policy": { - "type": 3, - "value": { - "rule": "MAJORITY", - "sub_policy": "Admins" - } - }, - "version": "0" - }, - "BlockValidation": { - "mod_policy": "Admins", - "policy": { - "type": 3, - "value": { - "rule": "ANY", - "sub_policy": "Writers" - } - }, - "version": "0" - }, - "Readers": { - "mod_policy": "Admins", - "policy": { - "type": 3, - "value": { - "rule": "ANY", - "sub_policy": "Readers" - } - }, - "version": "0" - }, - "Writers": { - "mod_policy": "Admins", - "policy": { - "type": 3, - "value": { - "rule": "ANY", - "sub_policy": "Writers" - } - }, - "version": "0" - } - }, - "values": { - "BatchSize": { - "mod_policy": "Admins", - "value": { - "absolute_max_bytes": 10485760, - "max_message_count": 500, - "preferred_max_bytes": 2097152 - }, - "version": "0" - }, - "BatchTimeout": { - "mod_policy": "Admins", - "value": { - "timeout": "2s" - }, - "version": "0" - }, - "Capabilities": { - "mod_policy": "Admins", - "value": { - "capabilities": { - "V1_1": {} - } - }, - "version": "0" - }, - "ChannelRestrictions": { - "mod_policy": "Admins", - "value": null, - "version": "0" - }, - "ConsensusType": { - "mod_policy": "Admins", - "value": { - "metadata": null, - "state": "STATE_NORMAL", - "type": "solo" - }, - "version": "0" - } - }, - "version": "0" - } - }, - "mod_policy": "Admins", - "policies": { - "Admins": { - "mod_policy": "Admins", - "policy": { - "type": 3, - "value": { - "rule": "MAJORITY", - "sub_policy": "Admins" - } - }, - "version": "0" - }, - "Readers": { - "mod_policy": "Admins", - "policy": { - "type": 3, - "value": { - "rule": "ANY", - "sub_policy": "Readers" - } - }, - "version": "0" - }, - "Writers": { - "mod_policy": "Admins", - "policy": { - "type": 3, - "value": { - "rule": "ANY", - "sub_policy": "Writers" - } - }, - "version": "0" - } - }, - "values": { - "BlockDataHashingStructure": { - "mod_policy": "Admins", - "value": { - "width": 4294967295 - }, - "version": "0" - }, - "Capabilities": { - "mod_policy": "Admins", - "value": { - "capabilities": { - "V2_0": {} - } - }, - "version": "0" - }, - "HashingAlgorithm": { - "mod_policy": "Admins", - "value": { - "name": "SHA256" - }, - "version": "0" - }, - "OrdererAddresses": { - "mod_policy": "/Channel/Orderer/Admins", - "value": { - "addresses": [ - "127.0.0.1:7050" - ] - }, - "version": "0" - } - }, - "version": "0" - }, - "sequence": "0" - }, - "last_update": null - }, - "header": { - "channel_header": { - "channel_id": "test", - "epoch": "0", - "extension": null, - "timestamp": "2019-04-21T19:35:42Z", - "tls_cert_hash": null, - "tx_id": "7c179b7100bb0c0b33dad5114f0294e2509e9be9fbfa0ac9d38b43703ea57138", - "type": 1, - "version": 1 - }, - "signature_header": { - "creator": null, - "nonce": "1gQF896QI8wgNZSwJ73vaPUcuOugIvB/" - } - } - }, - "signature": null - } - ] - }, - "header": { - "data_hash": "idkpZn9B0jX9nL0kASTuPnA1PJDeXToBquHOas7f3Kk=", - "number": "0", - "previous_hash": null - }, - "metadata": { - "metadata": [ - "", - "", - "", - "" - ] - } -} diff --git a/common/tools/protolator/integration/testdata/block.pb b/common/tools/protolator/integration/testdata/block.pb deleted file mode 100644 index f585ce22a46..00000000000 Binary files a/common/tools/protolator/integration/testdata/block.pb and /dev/null differ diff --git a/common/tools/protolator/json_test.go b/common/tools/protolator/json_test.go deleted file mode 100644 index 922aaada48e..00000000000 --- a/common/tools/protolator/json_test.go +++ /dev/null @@ -1,286 +0,0 @@ -/* -Copyright IBM Corp. 2017 All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package protolator - -import ( - "bytes" - "encoding/json" - "fmt" - "math" - "reflect" - "testing" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/common/tools/protolator/testprotos" - "github.com/stretchr/testify/assert" -) - -type testProtoPlainFieldFactory struct { - fromPrefix string - toPrefix string - fromError error - toError error -} - -func (tpff *testProtoPlainFieldFactory) Handles(msg proto.Message, fieldName string, fieldType reflect.Type, fieldValue reflect.Value) bool { - return fieldName == "plain_field" -} - -func (tpff *testProtoPlainFieldFactory) NewProtoField(msg proto.Message, fieldName string, fieldType reflect.Type, fieldValue reflect.Value) (protoField, error) { - return &plainField{ - baseField: baseField{ - msg: msg, - name: fieldName, - fType: reflect.TypeOf(""), - vType: fieldType, - value: fieldValue, - }, - populateFrom: func(source interface{}, destType reflect.Type) (reflect.Value, error) { - sourceAsString := source.(string) - return reflect.ValueOf(tpff.fromPrefix + sourceAsString), tpff.fromError - }, - populateTo: func(source reflect.Value) (interface{}, error) { - return tpff.toPrefix + source.Interface().(string), tpff.toError - }, - }, nil -} - -func TestSimpleMsgPlainField(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff} - - pfValue := "foo" - startMsg := &testprotos.SimpleMsg{ - PlainField: pfValue, - MapField: map[string]string{"1": "2"}, - SliceField: []string{"a", "b"}, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - - newMsg := &testprotos.SimpleMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - - assert.Equal(t, startMsg.MapField, newMsg.MapField) - assert.Equal(t, startMsg.SliceField, newMsg.SliceField) - assert.Equal(t, fromPrefix+toPrefix+startMsg.PlainField, newMsg.PlainField) - - tppff.fromError = fmt.Errorf("Failing from intentionally") - assert.Error(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - - tppff.toError = fmt.Errorf("Failing to intentionally") - assert.Error(t, DeepMarshalJSON(&buffer, startMsg)) -} - -type testProtoMapFieldFactory struct { - fromPrefix string - toPrefix string - fromError error - toError error -} - -func (tpff *testProtoMapFieldFactory) Handles(msg proto.Message, fieldName string, fieldType reflect.Type, fieldValue reflect.Value) bool { - return fieldName == "map_field" -} - -func (tpff *testProtoMapFieldFactory) NewProtoField(msg proto.Message, fieldName string, fieldType reflect.Type, fieldValue reflect.Value) (protoField, error) { - return &mapField{ - baseField: baseField{ - msg: msg, - name: fieldName, - fType: reflect.TypeOf(""), - vType: fieldType, - value: fieldValue, - }, - populateFrom: func(key string, source interface{}, destType reflect.Type) (reflect.Value, error) { - sourceAsString := source.(string) - return reflect.ValueOf(tpff.fromPrefix + key + sourceAsString), tpff.fromError - }, - populateTo: func(key string, source reflect.Value) (interface{}, error) { - return tpff.toPrefix + key + source.Interface().(string), tpff.toError - }, - }, nil -} - -func TestSimpleMsgMapField(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tpmff := &testProtoMapFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - fieldFactories = []protoFieldFactory{tpmff} - - key := "foo" - value := "bar" - startMsg := &testprotos.SimpleMsg{ - PlainField: "1", - MapField: map[string]string{key: value}, - SliceField: []string{"a", "b"}, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - - newMsg := &testprotos.SimpleMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - - assert.Equal(t, startMsg.PlainField, newMsg.PlainField) - assert.Equal(t, startMsg.SliceField, newMsg.SliceField) - assert.Equal(t, fromPrefix+key+toPrefix+key+startMsg.MapField[key], newMsg.MapField[key]) - - tpmff.fromError = fmt.Errorf("Failing from intentionally") - assert.Error(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - - tpmff.toError = fmt.Errorf("Failing to intentionally") - assert.Error(t, DeepMarshalJSON(&buffer, startMsg)) -} - -type testProtoSliceFieldFactory struct { - fromPrefix string - toPrefix string - fromError error - toError error -} - -func (tpff *testProtoSliceFieldFactory) Handles(msg proto.Message, fieldName string, fieldType reflect.Type, fieldValue reflect.Value) bool { - return fieldName == "slice_field" -} - -func (tpff *testProtoSliceFieldFactory) NewProtoField(msg proto.Message, fieldName string, fieldType reflect.Type, fieldValue reflect.Value) (protoField, error) { - return &sliceField{ - baseField: baseField{ - msg: msg, - name: fieldName, - fType: reflect.TypeOf(""), - vType: fieldType, - value: fieldValue, - }, - populateFrom: func(index int, source interface{}, destType reflect.Type) (reflect.Value, error) { - sourceAsString := source.(string) - return reflect.ValueOf(tpff.fromPrefix + fmt.Sprintf("%d", index) + sourceAsString), tpff.fromError - }, - populateTo: func(index int, source reflect.Value) (interface{}, error) { - return tpff.toPrefix + fmt.Sprintf("%d", index) + source.Interface().(string), tpff.toError - }, - }, nil -} - -func TestSimpleMsgSliceField(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tpsff := &testProtoSliceFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - fieldFactories = []protoFieldFactory{tpsff} - - value := "foo" - startMsg := &testprotos.SimpleMsg{ - PlainField: "1", - MapField: map[string]string{"a": "b"}, - SliceField: []string{value}, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - - newMsg := &testprotos.SimpleMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - - assert.Equal(t, startMsg.PlainField, newMsg.PlainField) - assert.Equal(t, startMsg.MapField, newMsg.MapField) - assert.Equal(t, fromPrefix+"0"+toPrefix+"0"+startMsg.SliceField[0], newMsg.SliceField[0]) - - tpsff.fromError = fmt.Errorf("Failing from intentionally") - assert.Error(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - - tpsff.toError = fmt.Errorf("Failing to intentionally") - assert.Error(t, DeepMarshalJSON(&buffer, startMsg)) -} - -type testProtoFailFactory struct{} - -func (tpff testProtoFailFactory) Handles(msg proto.Message, fieldName string, fieldType reflect.Type, fieldValue reflect.Value) bool { - return true -} - -func (tpff testProtoFailFactory) NewProtoField(msg proto.Message, fieldName string, fieldType reflect.Type, fieldValue reflect.Value) (protoField, error) { - return nil, fmt.Errorf("Intentionally failing") -} - -func TestFailFactory(t *testing.T) { - fieldFactories = []protoFieldFactory{&testProtoFailFactory{}} - - var buffer bytes.Buffer - assert.Error(t, DeepMarshalJSON(&buffer, &testprotos.SimpleMsg{})) -} - -func TestJSONUnmarshalMaxUint32(t *testing.T) { - fieldName := "numField" - jsonString := fmt.Sprintf("{\"%s\":%d}", fieldName, math.MaxUint32) - m, err := jsonToMap([]byte(jsonString)) - assert.NoError(t, err) - assert.IsType(t, json.Number(""), m[fieldName]) -} - -func TestMostlyDeterministicMarshal(t *testing.T) { - multiKeyMap := &testprotos.SimpleMsg{ - MapField: map[string]string{ - "a": "b", - "c": "d", - "e": "f", - "g": "h", - "i": "j", - "k": "l", - "m": "n", - "o": "p", - "q": "r", - "s": "t", - "u": "v", - "w": "x", - "y": "z", - }, - } - - result, err := MostlyDeterministicMarshal(multiKeyMap) - assert.NoError(t, err) - assert.NotNil(t, result) - - // Golang map marshaling is non-deterministic by default, by marshaling - // the same message with an embedded map multiple times, we should - // detect a mismatch if the default behavior persists. Even with 3 map - // elements, there is usually a mismatch within 2-3 iterations, so 13 - // entries and 10 iterations seems like a reasonable check. - for i := 0; i < 10; i++ { - newResult, err := MostlyDeterministicMarshal(multiKeyMap) - assert.NoError(t, err) - assert.Equal(t, result, newResult) - } - - unmarshaled := &testprotos.SimpleMsg{} - err = proto.Unmarshal(result, unmarshaled) - assert.NoError(t, err) - assert.True(t, proto.Equal(unmarshaled, multiKeyMap)) -} diff --git a/common/tools/protolator/nested_test.go b/common/tools/protolator/nested_test.go deleted file mode 100644 index 5c5180bc9b4..00000000000 --- a/common/tools/protolator/nested_test.go +++ /dev/null @@ -1,123 +0,0 @@ -/* -Copyright IBM Corp. 2017 All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package protolator - -import ( - "bytes" - "testing" - - "github.com/hyperledger/fabric/common/tools/protolator/testprotos" - "github.com/stretchr/testify/assert" -) - -func TestPlainNestedMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff} - - pfValue := "foo" - startMsg := &testprotos.NestedMsg{ - PlainNestedField: &testprotos.SimpleMsg{ - PlainField: pfValue, - }, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.NestedMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+startMsg.PlainNestedField.PlainField, newMsg.PlainNestedField.PlainField) - - fieldFactories = []protoFieldFactory{tppff, nestedFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+startMsg.PlainNestedField.PlainField, newMsg.PlainNestedField.PlainField) -} - -func TestMapNestedMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff} - - pfValue := "foo" - mapKey := "bar" - startMsg := &testprotos.NestedMsg{ - MapNestedField: map[string]*testprotos.SimpleMsg{ - mapKey: { - PlainField: pfValue, - }, - }, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.NestedMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+startMsg.MapNestedField[mapKey].PlainField, newMsg.MapNestedField[mapKey].PlainField) - - fieldFactories = []protoFieldFactory{tppff, nestedMapFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+startMsg.MapNestedField[mapKey].PlainField, newMsg.MapNestedField[mapKey].PlainField) -} - -func TestSliceNestedMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff} - - pfValue := "foo" - startMsg := &testprotos.NestedMsg{ - SliceNestedField: []*testprotos.SimpleMsg{ - { - PlainField: pfValue, - }, - }, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.NestedMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+startMsg.SliceNestedField[0].PlainField, newMsg.SliceNestedField[0].PlainField) - - fieldFactories = []protoFieldFactory{tppff, nestedSliceFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+startMsg.SliceNestedField[0].PlainField, newMsg.SliceNestedField[0].PlainField) -} diff --git a/common/tools/protolator/protoext/commonext/common_test.go b/common/tools/protolator/protoext/commonext/common_test.go deleted file mode 100644 index 0ab0c7a9349..00000000000 --- a/common/tools/protolator/protoext/commonext/common_test.go +++ /dev/null @@ -1,121 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package commonext - -import ( - "testing" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/common" - "github.com/stretchr/testify/assert" -) - -func TestCommonProtolator(t *testing.T) { - // Envelope - env := &Envelope{Envelope: &common.Envelope{}} - assert.Equal(t, []string{"payload"}, env.StaticallyOpaqueFields()) - msg, err := env.StaticallyOpaqueFieldProto("badproto") - assert.Nil(t, msg) - assert.Error(t, err) - msg, err = env.StaticallyOpaqueFieldProto("payload") - assert.NoError(t, err) - assert.Equal(t, &common.Payload{}, msg) - - // Payload - payload := &Payload{Payload: &common.Payload{}} - assert.Equal(t, []string{"data"}, payload.VariablyOpaqueFields()) - msg, err = payload.VariablyOpaqueFieldProto("badproto") - assert.Nil(t, msg) - assert.Error(t, err) - msg, err = payload.VariablyOpaqueFieldProto("data") - assert.Nil(t, msg) - assert.Error(t, err) - - payload = &Payload{ - Payload: &common.Payload{ - Header: &common.Header{ - ChannelHeader: []byte("badbytes"), - }, - }, - } - msg, err = payload.VariablyOpaqueFieldProto("data") - assert.Nil(t, msg) - assert.Error(t, err) - - ch := &common.ChannelHeader{ - Type: int32(common.HeaderType_CONFIG), - } - chbytes, _ := proto.Marshal(ch) - payload = &Payload{ - Payload: &common.Payload{ - Header: &common.Header{ - ChannelHeader: chbytes, - }, - }, - } - msg, err = payload.VariablyOpaqueFieldProto("data") - assert.Equal(t, &common.ConfigEnvelope{}, msg) - assert.NoError(t, err) - - ch = &common.ChannelHeader{ - Type: int32(common.HeaderType_CONFIG_UPDATE), - } - chbytes, _ = proto.Marshal(ch) - payload = &Payload{ - Payload: &common.Payload{ - Header: &common.Header{ - ChannelHeader: chbytes, - }, - }, - } - msg, err = payload.VariablyOpaqueFieldProto("data") - assert.Equal(t, &common.ConfigUpdateEnvelope{}, msg) - assert.NoError(t, err) - - ch = &common.ChannelHeader{ - Type: int32(common.HeaderType_CHAINCODE_PACKAGE), - } - chbytes, _ = proto.Marshal(ch) - payload = &Payload{ - Payload: &common.Payload{ - Header: &common.Header{ - ChannelHeader: chbytes, - }, - }, - } - msg, err = payload.VariablyOpaqueFieldProto("data") - assert.Nil(t, msg) - assert.Error(t, err) - - // Header - var header *Header - assert.Equal(t, []string{"channel_header", "signature_header"}, - header.StaticallyOpaqueFields()) - - msg, err = header.StaticallyOpaqueFieldProto("badproto") - assert.Nil(t, msg) - assert.Error(t, err) - - msg, err = header.StaticallyOpaqueFieldProto("channel_header") - assert.Equal(t, &common.ChannelHeader{}, msg) - assert.NoError(t, err) - - msg, err = header.StaticallyOpaqueFieldProto("signature_header") - assert.Equal(t, &common.SignatureHeader{}, msg) - assert.NoError(t, err) - - // BlockData - var bd *BlockData - assert.Equal(t, []string{"data"}, bd.StaticallyOpaqueSliceFields()) - - msg, err = bd.StaticallyOpaqueSliceFieldProto("badslice", 0) - assert.Nil(t, msg) - assert.Error(t, err) - msg, err = bd.StaticallyOpaqueSliceFieldProto("data", 0) - assert.Equal(t, &common.Envelope{}, msg) - assert.NoError(t, err) -} diff --git a/common/tools/protolator/protoext/commonext/commonext_test.go b/common/tools/protolator/protoext/commonext/commonext_test.go deleted file mode 100644 index 0769cc36433..00000000000 --- a/common/tools/protolator/protoext/commonext/commonext_test.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package commonext_test - -import ( - "github.com/hyperledger/fabric/common/tools/protolator" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/commonext" -) - -// ensure structs implement expected interfaces -var ( - _ protolator.StaticallyOpaqueFieldProto = &commonext.Envelope{} - _ protolator.DecoratedProto = &commonext.Envelope{} - _ protolator.VariablyOpaqueFieldProto = &commonext.Payload{} - _ protolator.DecoratedProto = &commonext.Payload{} - _ protolator.StaticallyOpaqueFieldProto = &commonext.Header{} - _ protolator.DecoratedProto = &commonext.Header{} - _ protolator.StaticallyOpaqueFieldProto = &commonext.SignatureHeader{} - _ protolator.DecoratedProto = &commonext.SignatureHeader{} - _ protolator.StaticallyOpaqueSliceFieldProto = &commonext.BlockData{} - _ protolator.DecoratedProto = &commonext.BlockData{} - - _ protolator.StaticallyOpaqueFieldProto = &commonext.ConfigUpdateEnvelope{} - _ protolator.DecoratedProto = &commonext.ConfigUpdateEnvelope{} - _ protolator.StaticallyOpaqueFieldProto = &commonext.ConfigSignature{} - _ protolator.DecoratedProto = &commonext.ConfigSignature{} - _ protolator.DynamicFieldProto = &commonext.Config{} - _ protolator.DecoratedProto = &commonext.Config{} - _ protolator.StaticallyOpaqueMapFieldProto = &commonext.ConfigUpdate{} - _ protolator.DecoratedProto = &commonext.ConfigUpdate{} - - _ protolator.DynamicMapFieldProto = &commonext.DynamicChannelGroup{} - _ protolator.DecoratedProto = &commonext.DynamicChannelGroup{} - _ protolator.StaticallyOpaqueFieldProto = &commonext.DynamicChannelConfigValue{} - _ protolator.DecoratedProto = &commonext.DynamicChannelConfigValue{} - _ protolator.DynamicMapFieldProto = &commonext.DynamicConsortiumsGroup{} - _ protolator.DecoratedProto = &commonext.DynamicConsortiumsGroup{} - _ protolator.DynamicMapFieldProto = &commonext.DynamicConsortiumGroup{} - _ protolator.DecoratedProto = &commonext.DynamicConsortiumGroup{} - _ protolator.VariablyOpaqueFieldProto = &commonext.DynamicConsortiumConfigValue{} - _ protolator.DecoratedProto = &commonext.DynamicConsortiumConfigValue{} - _ protolator.DynamicMapFieldProto = &commonext.DynamicConsortiumOrgGroup{} - _ protolator.DecoratedProto = &commonext.DynamicConsortiumOrgGroup{} - _ protolator.StaticallyOpaqueFieldProto = &commonext.DynamicConsortiumOrgConfigValue{} - _ protolator.DecoratedProto = &commonext.DynamicConsortiumOrgConfigValue{} -) diff --git a/common/tools/protolator/protoext/decorate_test.go b/common/tools/protolator/protoext/decorate_test.go deleted file mode 100644 index 2a4bcae74f8..00000000000 --- a/common/tools/protolator/protoext/decorate_test.go +++ /dev/null @@ -1,310 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package protoext - -import ( - "testing" - - "github.com/golang/protobuf/proto" - - "github.com/hyperledger/fabric-protos-go/common" - "github.com/hyperledger/fabric-protos-go/ledger/rwset" - "github.com/hyperledger/fabric-protos-go/msp" - "github.com/hyperledger/fabric-protos-go/orderer" - "github.com/hyperledger/fabric-protos-go/peer" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/commonext" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/ledger/rwsetext" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/mspext" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/ordererext" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/peerext" - - . "github.com/onsi/gomega" -) - -type GenericProtoMessage struct { - GenericField string -} - -func (g *GenericProtoMessage) Reset() { - panic("not implemented") -} - -func (g *GenericProtoMessage) String() string { - return "not implemented" -} - -func (g *GenericProtoMessage) ProtoMessage() { - panic("not implemented") -} - -func TestDecorate(t *testing.T) { - tests := []struct { - testSpec string - msg proto.Message - expectedReturn proto.Message - }{ - { - testSpec: "common.BlockData", - msg: &common.BlockData{ - Data: [][]byte{ - []byte("data-bytes"), - }}, - expectedReturn: &commonext.BlockData{ - BlockData: &common.BlockData{ - Data: [][]byte{ - []byte("data-bytes"), - }, - }, - }, - }, - { - testSpec: "common.Config", - msg: &common.Config{ - Sequence: 5, - }, - expectedReturn: &commonext.Config{ - Config: &common.Config{ - Sequence: 5, - }, - }, - }, - { - testSpec: "common.ConfigSignature", - msg: &common.ConfigSignature{ - SignatureHeader: []byte("signature-header-bytes"), - }, - expectedReturn: &commonext.ConfigSignature{ - ConfigSignature: &common.ConfigSignature{ - SignatureHeader: []byte("signature-header-bytes"), - }, - }, - }, - { - testSpec: "common.ConfigUpdate", - msg: &common.ConfigUpdate{ - ChannelId: "testchannel", - }, - expectedReturn: &commonext.ConfigUpdate{ - ConfigUpdate: &common.ConfigUpdate{ - ChannelId: "testchannel", - }, - }, - }, - { - testSpec: "common.ConfigUpdateEnvelope", - msg: &common.ConfigUpdateEnvelope{ - ConfigUpdate: []byte("config-update-bytes"), - }, - expectedReturn: &commonext.ConfigUpdateEnvelope{ - ConfigUpdateEnvelope: &common.ConfigUpdateEnvelope{ - ConfigUpdate: []byte("config-update-bytes"), - }, - }, - }, - { - testSpec: "common.Envelope", - msg: &common.Envelope{ - Payload: []byte("payload-bytes"), - }, - expectedReturn: &commonext.Envelope{ - Envelope: &common.Envelope{ - Payload: []byte("payload-bytes"), - }, - }, - }, - { - testSpec: "common.Header", - msg: &common.Header{ - ChannelHeader: []byte("channel-header-bytes"), - }, - expectedReturn: &commonext.Header{ - Header: &common.Header{ - ChannelHeader: []byte("channel-header-bytes"), - }, - }, - }, - { - testSpec: "common.ChannelHeader", - msg: &common.ChannelHeader{ - Type: 5, - }, - expectedReturn: &commonext.ChannelHeader{ - ChannelHeader: &common.ChannelHeader{ - Type: 5, - }, - }, - }, - { - testSpec: "common.SignatureHeader", - msg: &common.SignatureHeader{ - Creator: []byte("creator-bytes"), - }, - expectedReturn: &commonext.SignatureHeader{ - SignatureHeader: &common.SignatureHeader{ - Creator: []byte("creator-bytes"), - }, - }, - }, - { - testSpec: "common.Payload", - msg: &common.Payload{ - Header: &common.Header{ChannelHeader: []byte("channel-header-bytes")}, - }, - expectedReturn: &commonext.Payload{ - Payload: &common.Payload{ - Header: &common.Header{ChannelHeader: []byte("channel-header-bytes")}, - }, - }, - }, - { - testSpec: "common.Policy", - msg: &common.Policy{ - Type: 5, - }, - expectedReturn: &commonext.Policy{ - Policy: &common.Policy{ - Type: 5, - }, - }, - }, - { - testSpec: "msp.MSPConfig", - msg: &msp.MSPConfig{ - Type: 5, - }, - expectedReturn: &mspext.MSPConfig{ - MSPConfig: &msp.MSPConfig{ - Type: 5, - }, - }, - }, - { - testSpec: "msp.MSPPrincipal", - msg: &msp.MSPPrincipal{ - Principal: []byte("principal-bytes"), - }, - expectedReturn: &mspext.MSPPrincipal{ - MSPPrincipal: &msp.MSPPrincipal{ - Principal: []byte("principal-bytes"), - }, - }, - }, - { - testSpec: "orderer.ConsensusType", - msg: &orderer.ConsensusType{ - Type: "etcdraft", - }, - expectedReturn: &ordererext.ConsensusType{ - ConsensusType: &orderer.ConsensusType{ - Type: "etcdraft", - }, - }, - }, - { - testSpec: "peer.ChaincodeAction", - msg: &peer.ChaincodeAction{ - Results: []byte("results-bytes"), - }, - expectedReturn: &peerext.ChaincodeAction{ - ChaincodeAction: &peer.ChaincodeAction{ - Results: []byte("results-bytes"), - }, - }, - }, - { - testSpec: "peer.ChaincodeActionPayload", - msg: &peer.ChaincodeActionPayload{ - ChaincodeProposalPayload: []byte("chaincode-proposal-payload-bytes"), - }, - expectedReturn: &peerext.ChaincodeActionPayload{ - ChaincodeActionPayload: &peer.ChaincodeActionPayload{ - ChaincodeProposalPayload: []byte("chaincode-proposal-payload-bytes"), - }, - }, - }, - { - testSpec: "peer.ChaincodeEndorsedAction", - msg: &peer.ChaincodeEndorsedAction{ - ProposalResponsePayload: []byte("proposal-response-payload-bytes"), - }, - expectedReturn: &peerext.ChaincodeEndorsedAction{ - ChaincodeEndorsedAction: &peer.ChaincodeEndorsedAction{ - ProposalResponsePayload: []byte("proposal-response-payload-bytes"), - }, - }, - }, - { - testSpec: "peer.ChaincodeProposalPayload", - msg: &peer.ChaincodeProposalPayload{ - Input: []byte("input-bytes"), - }, - expectedReturn: &peerext.ChaincodeProposalPayload{ - ChaincodeProposalPayload: &peer.ChaincodeProposalPayload{ - Input: []byte("input-bytes"), - }, - }, - }, - { - testSpec: "peer.ProposalResponsePayload", - msg: &peer.ProposalResponsePayload{ - ProposalHash: []byte("proposal-hash-bytes"), - }, - expectedReturn: &peerext.ProposalResponsePayload{ - ProposalResponsePayload: &peer.ProposalResponsePayload{ - ProposalHash: []byte("proposal-hash-bytes"), - }, - }, - }, - { - testSpec: "peer.TransactionAction", - msg: &peer.TransactionAction{ - Header: []byte("header-bytes"), - }, - expectedReturn: &peerext.TransactionAction{ - TransactionAction: &peer.TransactionAction{ - Header: []byte("header-bytes"), - }, - }, - }, - { - testSpec: "rwset.TxReadWriteSet", - msg: &rwset.TxReadWriteSet{ - NsRwset: []*rwset.NsReadWriteSet{ - { - Namespace: "namespace", - }, - }, - }, - expectedReturn: &rwsetext.TxReadWriteSet{ - TxReadWriteSet: &rwset.TxReadWriteSet{ - NsRwset: []*rwset.NsReadWriteSet{ - { - Namespace: "namespace", - }, - }, - }, - }, - }, - { - testSpec: "default", - msg: &GenericProtoMessage{ - GenericField: "test", - }, - expectedReturn: &GenericProtoMessage{ - GenericField: "test", - }, - }, - } - - for _, tt := range tests { - t.Run(tt.testSpec, func(t *testing.T) { - gt := NewGomegaWithT(t) - decoratedMsg := Decorate(tt.msg) - gt.Expect(proto.Equal(decoratedMsg, tt.expectedReturn)).To(BeTrue()) - }) - } -} diff --git a/common/tools/protolator/protoext/ledger/rwsetext/rwsetext_test.go b/common/tools/protolator/protoext/ledger/rwsetext/rwsetext_test.go deleted file mode 100644 index 3fcdf6ddd9e..00000000000 --- a/common/tools/protolator/protoext/ledger/rwsetext/rwsetext_test.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package rwsetext_test - -import ( - "github.com/hyperledger/fabric/common/tools/protolator" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/ledger/rwsetext" -) - -// ensure structs implement expected interfaces -var ( - _ protolator.DynamicSliceFieldProto = &rwsetext.TxReadWriteSet{} - _ protolator.DecoratedProto = &rwsetext.TxReadWriteSet{} - _ protolator.StaticallyOpaqueFieldProto = &rwsetext.DynamicNsReadWriteSet{} - _ protolator.DecoratedProto = &rwsetext.DynamicNsReadWriteSet{} - _ protolator.StaticallyOpaqueFieldProto = &rwsetext.DynamicCollectionHashedReadWriteSet{} - _ protolator.DecoratedProto = &rwsetext.DynamicCollectionHashedReadWriteSet{} -) diff --git a/common/tools/protolator/protoext/mspext/mspext_test.go b/common/tools/protolator/protoext/mspext/mspext_test.go deleted file mode 100644 index dfa3fd8ee4e..00000000000 --- a/common/tools/protolator/protoext/mspext/mspext_test.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package mspext_test - -import ( - "github.com/hyperledger/fabric/common/tools/protolator" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/mspext" -) - -// ensure structs implement expected interfaces -var ( - _ protolator.VariablyOpaqueFieldProto = &mspext.MSPConfig{} - _ protolator.DecoratedProto = &mspext.MSPConfig{} - - _ protolator.VariablyOpaqueFieldProto = &mspext.MSPPrincipal{} - _ protolator.DecoratedProto = &mspext.MSPPrincipal{} -) diff --git a/common/tools/protolator/protoext/ordererext/ordererext_test.go b/common/tools/protolator/protoext/ordererext/ordererext_test.go deleted file mode 100644 index 404bb2a3ac9..00000000000 --- a/common/tools/protolator/protoext/ordererext/ordererext_test.go +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package ordererext_test - -import ( - "github.com/hyperledger/fabric/common/tools/protolator" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/ordererext" -) - -// ensure structs implement expected interfaces -var ( - _ protolator.DynamicMapFieldProto = &ordererext.DynamicOrdererGroup{} - _ protolator.DecoratedProto = &ordererext.DynamicOrdererGroup{} - _ protolator.VariablyOpaqueFieldProto = &ordererext.ConsensusType{} - _ protolator.DecoratedProto = &ordererext.ConsensusType{} - _ protolator.DynamicMapFieldProto = &ordererext.DynamicOrdererOrgGroup{} - _ protolator.DecoratedProto = &ordererext.DynamicOrdererOrgGroup{} - _ protolator.StaticallyOpaqueFieldProto = &ordererext.DynamicOrdererConfigValue{} - _ protolator.DecoratedProto = &ordererext.DynamicOrdererConfigValue{} - _ protolator.StaticallyOpaqueFieldProto = &ordererext.DynamicOrdererOrgConfigValue{} - _ protolator.DecoratedProto = &ordererext.DynamicOrdererOrgConfigValue{} -) diff --git a/common/tools/protolator/protoext/peerext/peerext_test.go b/common/tools/protolator/protoext/peerext/peerext_test.go deleted file mode 100644 index 5737a8356e1..00000000000 --- a/common/tools/protolator/protoext/peerext/peerext_test.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package peerext_test - -import ( - "github.com/hyperledger/fabric/common/tools/protolator" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/peerext" -) - -// ensure structs implement expected interfaces -var ( - _ protolator.DynamicMapFieldProto = &peerext.DynamicApplicationGroup{} - _ protolator.DecoratedProto = &peerext.DynamicApplicationGroup{} - _ protolator.DynamicMapFieldProto = &peerext.DynamicApplicationOrgGroup{} - _ protolator.DecoratedProto = &peerext.DynamicApplicationOrgGroup{} - _ protolator.StaticallyOpaqueFieldProto = &peerext.DynamicApplicationConfigValue{} - _ protolator.DecoratedProto = &peerext.DynamicApplicationConfigValue{} - _ protolator.StaticallyOpaqueFieldProto = &peerext.DynamicApplicationOrgConfigValue{} - _ protolator.DecoratedProto = &peerext.DynamicApplicationOrgConfigValue{} - - _ protolator.StaticallyOpaqueFieldProto = &peerext.ChaincodeProposalPayload{} - _ protolator.DecoratedProto = &peerext.ChaincodeProposalPayload{} - _ protolator.StaticallyOpaqueFieldProto = &peerext.ChaincodeAction{} - _ protolator.DecoratedProto = &peerext.ChaincodeAction{} - - _ protolator.StaticallyOpaqueFieldProto = &peerext.ProposalResponsePayload{} - _ protolator.DecoratedProto = &peerext.ProposalResponsePayload{} - - _ protolator.StaticallyOpaqueFieldProto = &peerext.TransactionAction{} - _ protolator.DecoratedProto = &peerext.TransactionAction{} - _ protolator.StaticallyOpaqueFieldProto = &peerext.ChaincodeActionPayload{} - _ protolator.DecoratedProto = &peerext.ChaincodeActionPayload{} - _ protolator.StaticallyOpaqueFieldProto = &peerext.ChaincodeEndorsedAction{} - _ protolator.DecoratedProto = &peerext.ChaincodeEndorsedAction{} -) diff --git a/common/tools/protolator/statically_opaque_test.go b/common/tools/protolator/statically_opaque_test.go deleted file mode 100644 index 7f1ed948804..00000000000 --- a/common/tools/protolator/statically_opaque_test.go +++ /dev/null @@ -1,147 +0,0 @@ -/* -Copyright IBM Corp. 2017 All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package protolator - -import ( - "bytes" - "testing" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/common/tools/protolator/testprotos" - "github.com/hyperledger/fabric/protoutil" - "github.com/stretchr/testify/assert" -) - -func extractSimpleMsgPlainField(source []byte) string { - result := &testprotos.SimpleMsg{} - err := proto.Unmarshal(source, result) - if err != nil { - panic(err) - } - return result.PlainField -} - -func TestPlainStaticallyOpaqueMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff} - - pfValue := "foo" - startMsg := &testprotos.StaticallyOpaqueMsg{ - PlainOpaqueField: protoutil.MarshalOrPanic(&testprotos.SimpleMsg{ - PlainField: pfValue, - }), - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.StaticallyOpaqueMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.PlainOpaqueField), extractSimpleMsgPlainField(newMsg.PlainOpaqueField)) - - fieldFactories = []protoFieldFactory{tppff, staticallyOpaqueFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.PlainOpaqueField), extractSimpleMsgPlainField(newMsg.PlainOpaqueField)) -} - -func TestMapStaticallyOpaqueMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff} - - pfValue := "foo" - mapKey := "bar" - startMsg := &testprotos.StaticallyOpaqueMsg{ - MapOpaqueField: map[string][]byte{ - mapKey: protoutil.MarshalOrPanic(&testprotos.SimpleMsg{ - PlainField: pfValue, - }), - }, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.StaticallyOpaqueMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.MapOpaqueField[mapKey]), extractSimpleMsgPlainField(newMsg.MapOpaqueField[mapKey])) - - fieldFactories = []protoFieldFactory{tppff, staticallyOpaqueMapFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.MapOpaqueField[mapKey]), extractSimpleMsgPlainField(newMsg.MapOpaqueField[mapKey])) -} - -func TestSliceStaticallyOpaqueMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff} - - pfValue := "foo" - startMsg := &testprotos.StaticallyOpaqueMsg{ - SliceOpaqueField: [][]byte{ - protoutil.MarshalOrPanic(&testprotos.SimpleMsg{ - PlainField: pfValue, - }), - }, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.StaticallyOpaqueMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.SliceOpaqueField[0]), extractSimpleMsgPlainField(newMsg.SliceOpaqueField[0])) - - fieldFactories = []protoFieldFactory{tppff, staticallyOpaqueSliceFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+extractSimpleMsgPlainField(startMsg.SliceOpaqueField[0]), extractSimpleMsgPlainField(newMsg.SliceOpaqueField[0])) -} - -func TestIgnoredNilFields(t *testing.T) { - _ = StaticallyOpaqueFieldProto(&testprotos.UnmarshalableDeepFields{}) - _ = StaticallyOpaqueMapFieldProto(&testprotos.UnmarshalableDeepFields{}) - _ = StaticallyOpaqueSliceFieldProto(&testprotos.UnmarshalableDeepFields{}) - - fieldFactories = []protoFieldFactory{ - staticallyOpaqueFieldFactory{}, - staticallyOpaqueMapFieldFactory{}, - staticallyOpaqueSliceFieldFactory{}, - } - - assert.Error(t, DeepMarshalJSON(&bytes.Buffer{}, &testprotos.UnmarshalableDeepFields{ - PlainOpaqueField: []byte("fake"), - })) - assert.Error(t, DeepMarshalJSON(&bytes.Buffer{}, &testprotos.UnmarshalableDeepFields{ - MapOpaqueField: map[string][]byte{"foo": []byte("bar")}, - })) - assert.Error(t, DeepMarshalJSON(&bytes.Buffer{}, &testprotos.UnmarshalableDeepFields{ - SliceOpaqueField: [][]byte{[]byte("bar")}, - })) - assert.NoError(t, DeepMarshalJSON(&bytes.Buffer{}, &testprotos.UnmarshalableDeepFields{})) -} diff --git a/common/tools/protolator/testprotos/sample.go b/common/tools/protolator/testprotos/sample.go deleted file mode 100644 index 8a4ec05da78..00000000000 --- a/common/tools/protolator/testprotos/sample.go +++ /dev/null @@ -1,203 +0,0 @@ -/* -Copyright IBM Corp. 2017 All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package testprotos - -import ( - "fmt" - - "github.com/golang/protobuf/proto" -) - -func (som *StaticallyOpaqueMsg) StaticallyOpaqueFields() []string { - return []string{"plain_opaque_field"} -} - -func (som *StaticallyOpaqueMsg) StaticallyOpaqueFieldProto(name string) (proto.Message, error) { - if name != som.StaticallyOpaqueFields()[0] { - return nil, fmt.Errorf("not a statically opaque field: %s", name) - } - - return &SimpleMsg{}, nil -} - -func (som *StaticallyOpaqueMsg) StaticallyOpaqueMapFields() []string { - return []string{"map_opaque_field"} -} - -func (som *StaticallyOpaqueMsg) StaticallyOpaqueMapFieldProto(name string, key string) (proto.Message, error) { - if name != som.StaticallyOpaqueMapFields()[0] { - return nil, fmt.Errorf("not a statically opaque field: %s", name) - } - - return &SimpleMsg{}, nil -} - -func (som *StaticallyOpaqueMsg) StaticallyOpaqueSliceFields() []string { - return []string{"slice_opaque_field"} -} - -func (som *StaticallyOpaqueMsg) StaticallyOpaqueSliceFieldProto(name string, index int) (proto.Message, error) { - if name != som.StaticallyOpaqueSliceFields()[0] { - return nil, fmt.Errorf("not a statically opaque field: %s", name) - } - - return &SimpleMsg{}, nil -} - -func typeSwitch(typeName string) (proto.Message, error) { - switch typeName { - case "SimpleMsg": - return &SimpleMsg{}, nil - case "NestedMsg": - return &NestedMsg{}, nil - case "StaticallyOpaqueMsg": - return &StaticallyOpaqueMsg{}, nil - case "VariablyOpaqueMsg": - return &VariablyOpaqueMsg{}, nil - default: - return nil, fmt.Errorf("unknown message type: %s", typeName) - } -} - -func (vom *VariablyOpaqueMsg) VariablyOpaqueFields() []string { - return []string{"plain_opaque_field"} -} - -func (vom *VariablyOpaqueMsg) VariablyOpaqueFieldProto(name string) (proto.Message, error) { - if name != vom.VariablyOpaqueFields()[0] { - return nil, fmt.Errorf("not a statically opaque field: %s", name) - } - - return typeSwitch(vom.OpaqueType) -} - -func (vom *VariablyOpaqueMsg) VariablyOpaqueMapFields() []string { - return []string{"map_opaque_field"} -} - -func (vom *VariablyOpaqueMsg) VariablyOpaqueMapFieldProto(name string, key string) (proto.Message, error) { - if name != vom.VariablyOpaqueMapFields()[0] { - return nil, fmt.Errorf("not a statically opaque field: %s", name) - } - - return typeSwitch(vom.OpaqueType) -} - -func (vom *VariablyOpaqueMsg) VariablyOpaqueSliceFields() []string { - return []string{"slice_opaque_field"} -} - -func (vom *VariablyOpaqueMsg) VariablyOpaqueSliceFieldProto(name string, index int) (proto.Message, error) { - if name != vom.VariablyOpaqueSliceFields()[0] { - return nil, fmt.Errorf("not a statically opaque field: %s", name) - } - - return typeSwitch(vom.OpaqueType) -} - -func (cm *ContextlessMsg) VariablyOpaqueFields() []string { - return []string{"opaque_field"} -} - -type DynamicMessageWrapper struct { - *ContextlessMsg - typeName string -} - -func (dmw *DynamicMessageWrapper) VariablyOpaqueFieldProto(name string) (proto.Message, error) { - if name != dmw.ContextlessMsg.VariablyOpaqueFields()[0] { - return nil, fmt.Errorf("not a statically opaque field: %s", name) - } - - return typeSwitch(dmw.typeName) -} - -func (dmw *DynamicMessageWrapper) Underlying() proto.Message { - return dmw.ContextlessMsg -} - -func wrapContextless(underlying proto.Message, typeName string) (*DynamicMessageWrapper, error) { - cm, ok := underlying.(*ContextlessMsg) - if !ok { - return nil, fmt.Errorf("unknown dynamic message to wrap (%T) requires *ContextlessMsg", underlying) - } - - return &DynamicMessageWrapper{ - ContextlessMsg: cm, - typeName: typeName, - }, nil -} - -func (vom *DynamicMsg) DynamicFields() []string { - return []string{"plain_dynamic_field"} -} - -func (vom *DynamicMsg) DynamicFieldProto(name string, underlying proto.Message) (proto.Message, error) { - if name != vom.DynamicFields()[0] { - return nil, fmt.Errorf("not a dynamic field: %s", name) - } - - return wrapContextless(underlying, vom.DynamicType) -} - -func (vom *DynamicMsg) DynamicMapFields() []string { - return []string{"map_dynamic_field"} -} - -func (vom *DynamicMsg) DynamicMapFieldProto(name string, key string, underlying proto.Message) (proto.Message, error) { - if name != vom.DynamicMapFields()[0] { - return nil, fmt.Errorf("not a dynamic map field: %s", name) - } - - return wrapContextless(underlying, vom.DynamicType) -} - -func (vom *DynamicMsg) DynamicSliceFields() []string { - return []string{"slice_dynamic_field"} -} - -func (vom *DynamicMsg) DynamicSliceFieldProto(name string, index int, underlying proto.Message) (proto.Message, error) { - if name != vom.DynamicSliceFields()[0] { - return nil, fmt.Errorf("not a dynamic slice field: %s", name) - } - - return wrapContextless(underlying, vom.DynamicType) -} - -func (udf *UnmarshalableDeepFields) StaticallyOpaqueFields() []string { - return []string{"plain_opaque_field"} -} - -func (udf *UnmarshalableDeepFields) StaticallyOpaqueFieldProto(name string) (proto.Message, error) { - return nil, fmt.Errorf("intentional error") -} - -func (udf *UnmarshalableDeepFields) StaticallyOpaqueMapFields() []string { - return []string{"map_opaque_field"} -} - -func (udf *UnmarshalableDeepFields) StaticallyOpaqueMapFieldProto(name, key string) (proto.Message, error) { - return nil, fmt.Errorf("intentional error") -} - -func (udf *UnmarshalableDeepFields) StaticallyOpaqueSliceFields() []string { - return []string{"slice_opaque_field"} -} - -func (udf *UnmarshalableDeepFields) StaticallyOpaqueSliceFieldProto(name string, index int) (proto.Message, error) { - return nil, fmt.Errorf("intentional error") -} diff --git a/common/tools/protolator/testprotos/sample.pb.go b/common/tools/protolator/testprotos/sample.pb.go deleted file mode 100644 index 476107e817c..00000000000 --- a/common/tools/protolator/testprotos/sample.pb.go +++ /dev/null @@ -1,482 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: sample.proto - -package testprotos - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// 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 - -// 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,proto3" json:"plain_field,omitempty"` - MapField map[string]string `protobuf:"bytes,2,rep,name=map_field,json=mapField,proto3" json:"map_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SliceField []string `protobuf:"bytes,3,rep,name=slice_field,json=sliceField,proto3" 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 fileDescriptor_2141552de9bf11d0, []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 (m *SimpleMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_SimpleMsg.Merge(m, 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 { - return m.PlainField - } - return "" -} - -func (m *SimpleMsg) GetMapField() map[string]string { - if m != nil { - return m.MapField - } - return nil -} - -func (m *SimpleMsg) GetSliceField() []string { - if m != nil { - return m.SliceField - } - return nil -} - -// NestedMsg is designed to test the nested message component -type NestedMsg struct { - PlainNestedField *SimpleMsg `protobuf:"bytes,1,opt,name=plain_nested_field,json=plainNestedField,proto3" json:"plain_nested_field,omitempty"` - MapNestedField map[string]*SimpleMsg `protobuf:"bytes,2,rep,name=map_nested_field,json=mapNestedField,proto3" json:"map_nested_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SliceNestedField []*SimpleMsg `protobuf:"bytes,3,rep,name=slice_nested_field,json=sliceNestedField,proto3" 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 fileDescriptor_2141552de9bf11d0, []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 (m *NestedMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_NestedMsg.Merge(m, 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 { - return m.PlainNestedField - } - return nil -} - -func (m *NestedMsg) GetMapNestedField() map[string]*SimpleMsg { - if m != nil { - return m.MapNestedField - } - return nil -} - -func (m *NestedMsg) GetSliceNestedField() []*SimpleMsg { - if m != nil { - return m.SliceNestedField - } - return nil -} - -// 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,proto3" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" 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_2141552de9bf11d0, []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 (m *StaticallyOpaqueMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_StaticallyOpaqueMsg.Merge(m, src) -} -func (m *StaticallyOpaqueMsg) XXX_Size() int { - return xxx_messageInfo_StaticallyOpaqueMsg.Size(m) -} -func (m *StaticallyOpaqueMsg) XXX_DiscardUnknown() { - xxx_messageInfo_StaticallyOpaqueMsg.DiscardUnknown(m) -} - -var xxx_messageInfo_StaticallyOpaqueMsg proto.InternalMessageInfo - -func (m *StaticallyOpaqueMsg) GetPlainOpaqueField() []byte { - if m != nil { - return m.PlainOpaqueField - } - return nil -} - -func (m *StaticallyOpaqueMsg) GetMapOpaqueField() map[string][]byte { - if m != nil { - return m.MapOpaqueField - } - return nil -} - -func (m *StaticallyOpaqueMsg) GetSliceOpaqueField() [][]byte { - if m != nil { - return m.SliceOpaqueField - } - return nil -} - -// 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,proto3" 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,proto3" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" 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 fileDescriptor_2141552de9bf11d0, []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 (m *VariablyOpaqueMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_VariablyOpaqueMsg.Merge(m, 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 { - return m.OpaqueType - } - return "" -} - -func (m *VariablyOpaqueMsg) GetPlainOpaqueField() []byte { - if m != nil { - return m.PlainOpaqueField - } - return nil -} - -func (m *VariablyOpaqueMsg) GetMapOpaqueField() map[string][]byte { - if m != nil { - return m.MapOpaqueField - } - return nil -} - -func (m *VariablyOpaqueMsg) GetSliceOpaqueField() [][]byte { - if m != nil { - return m.SliceOpaqueField - } - return nil -} - -// DynamicMsg is designed to test the dynamic message component -// 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,proto3" json:"dynamic_type,omitempty"` - PlainDynamicField *ContextlessMsg `protobuf:"bytes,2,opt,name=plain_dynamic_field,json=plainDynamicField,proto3" json:"plain_dynamic_field,omitempty"` - MapDynamicField map[string]*ContextlessMsg `protobuf:"bytes,3,rep,name=map_dynamic_field,json=mapDynamicField,proto3" json:"map_dynamic_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SliceDynamicField []*ContextlessMsg `protobuf:"bytes,4,rep,name=slice_dynamic_field,json=sliceDynamicField,proto3" 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 fileDescriptor_2141552de9bf11d0, []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 (m *DynamicMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_DynamicMsg.Merge(m, 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 { - return m.DynamicType - } - return "" -} - -func (m *DynamicMsg) GetPlainDynamicField() *ContextlessMsg { - if m != nil { - return m.PlainDynamicField - } - return nil -} - -func (m *DynamicMsg) GetMapDynamicField() map[string]*ContextlessMsg { - if m != nil { - return m.MapDynamicField - } - return nil -} - -func (m *DynamicMsg) GetSliceDynamicField() []*ContextlessMsg { - if m != nil { - return m.SliceDynamicField - } - return nil -} - -// ContextlessMsg is designed to carry a message of completely arbitrary type -// 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"` - 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_2141552de9bf11d0, []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 (m *ContextlessMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_ContextlessMsg.Merge(m, src) -} -func (m *ContextlessMsg) XXX_Size() int { - return xxx_messageInfo_ContextlessMsg.Size(m) -} -func (m *ContextlessMsg) XXX_DiscardUnknown() { - xxx_messageInfo_ContextlessMsg.DiscardUnknown(m) -} - -var xxx_messageInfo_ContextlessMsg proto.InternalMessageInfo - -func (m *ContextlessMsg) GetOpaqueField() []byte { - if m != nil { - return m.OpaqueField - } - return nil -} - -// UnmarshalableDeepFields contains fields which are defined to be opaque, but will -// return an error if they are asked to be deserialized. -type UnmarshalableDeepFields 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,proto3" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" 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 *UnmarshalableDeepFields) Reset() { *m = UnmarshalableDeepFields{} } -func (m *UnmarshalableDeepFields) String() string { return proto.CompactTextString(m) } -func (*UnmarshalableDeepFields) ProtoMessage() {} -func (*UnmarshalableDeepFields) Descriptor() ([]byte, []int) { - return fileDescriptor_2141552de9bf11d0, []int{6} -} - -func (m *UnmarshalableDeepFields) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UnmarshalableDeepFields.Unmarshal(m, b) -} -func (m *UnmarshalableDeepFields) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UnmarshalableDeepFields.Marshal(b, m, deterministic) -} -func (m *UnmarshalableDeepFields) XXX_Merge(src proto.Message) { - xxx_messageInfo_UnmarshalableDeepFields.Merge(m, src) -} -func (m *UnmarshalableDeepFields) XXX_Size() int { - return xxx_messageInfo_UnmarshalableDeepFields.Size(m) -} -func (m *UnmarshalableDeepFields) XXX_DiscardUnknown() { - xxx_messageInfo_UnmarshalableDeepFields.DiscardUnknown(m) -} - -var xxx_messageInfo_UnmarshalableDeepFields proto.InternalMessageInfo - -func (m *UnmarshalableDeepFields) GetPlainOpaqueField() []byte { - if m != nil { - return m.PlainOpaqueField - } - return nil -} - -func (m *UnmarshalableDeepFields) GetMapOpaqueField() map[string][]byte { - if m != nil { - return m.MapOpaqueField - } - return nil -} - -func (m *UnmarshalableDeepFields) GetSliceOpaqueField() [][]byte { - if m != nil { - return m.SliceOpaqueField - } - return nil -} - -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") - proto.RegisterType((*UnmarshalableDeepFields)(nil), "testprotos.UnmarshalableDeepFields") - proto.RegisterMapType((map[string][]byte)(nil), "testprotos.UnmarshalableDeepFields.MapOpaqueFieldEntry") -} - -func init() { proto.RegisterFile("sample.proto", fileDescriptor_2141552de9bf11d0) } - -var fileDescriptor_2141552de9bf11d0 = []byte{ - // 617 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x94, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0x86, 0x15, 0xbb, 0x20, 0x72, 0x1c, 0x4a, 0xe2, 0x14, 0x51, 0x65, 0xd3, 0x10, 0x36, 0x45, - 0xad, 0x62, 0x48, 0x16, 0x20, 0xd8, 0x94, 0xb6, 0xb0, 0x40, 0x2a, 0x48, 0x09, 0x37, 0x81, 0x00, - 0x4d, 0x9c, 0x69, 0x62, 0x31, 0xbe, 0xe0, 0x99, 0x20, 0xbc, 0xe3, 0x1d, 0x58, 0xf2, 0x12, 0x3c, - 0x04, 0x4b, 0x1e, 0x0a, 0xcd, 0x25, 0xcd, 0x19, 0x6a, 0x17, 0x21, 0x84, 0xd4, 0x55, 0xe2, 0xe3, - 0x39, 0xff, 0xf9, 0xff, 0xcf, 0x33, 0x03, 0x0d, 0x4e, 0xe2, 0x8c, 0xd1, 0x7e, 0x96, 0xa7, 0x22, - 0xf5, 0x41, 0x50, 0x2e, 0xd4, 0x5f, 0xde, 0xfb, 0x59, 0x83, 0xfa, 0x38, 0x92, 0x2f, 0x8f, 0xf8, - 0xcc, 0xdf, 0x02, 0x2f, 0x63, 0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xaf, 0x29, 0xe9, 0x33, 0x4d, 0xaa, 0x36, 0xac, 0xd5, 0x79, 0x07, 0x1b, 0x65, 0x43, - 0x4b, 0x30, 0xdf, 0xb2, 0x8f, 0xf1, 0x59, 0x73, 0xd0, 0x27, 0x18, 0xc2, 0xba, 0xfd, 0x52, 0x7e, - 0x85, 0x92, 0xf3, 0x6b, 0x76, 0xb1, 0x72, 0xd0, 0xfb, 0xe6, 0xc0, 0xb5, 0xe7, 0x49, 0x4c, 0x72, - 0x3e, 0x27, 0x8c, 0x4c, 0x18, 0x3d, 0xa4, 0x54, 0xdf, 0xc9, 0xfc, 0x2f, 0x2f, 0x01, 0x52, 0x79, - 0x09, 0xdc, 0xc1, 0xfe, 0x2b, 0x86, 0x9d, 0xcb, 0x8b, 0x60, 0x7f, 0xff, 0xf5, 0xde, 0x2c, 0x12, - 0xf3, 0xc5, 0xa4, 0x1f, 0xa6, 0x71, 0x30, 0x2f, 0x32, 0x9a, 0x33, 0x3a, 0x9d, 0xd1, 0x3c, 0x38, - 0x26, 0x93, 0x3c, 0x0a, 0x83, 0x30, 0x8d, 0xe3, 0x34, 0x09, 0x44, 0x9a, 0x32, 0x1e, 0xa8, 0x84, - 0x8c, 0x88, 0x34, 0x0f, 0x56, 0x81, 0x27, 0x17, 0xd5, 0xef, 0xf0, 0x57, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xbc, 0xe8, 0xa5, 0x47, 0x9b, 0x07, 0x00, 0x00, -} diff --git a/common/tools/protolator/testprotos/sample.proto b/common/tools/protolator/testprotos/sample.proto deleted file mode 100644 index 6bd12d8ace5..00000000000 --- a/common/tools/protolator/testprotos/sample.proto +++ /dev/null @@ -1,78 +0,0 @@ -/* -Copyright IBM Corp. 2017 All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -syntax = "proto3"; - -option go_package = "github.com/hyperledger/fabric/common/tools/protolator/testprotos"; - -package testprotos; - -// SimpleMsg is designed to test that all three types of message fields, plain, map, -// and slice are handled by the protolator tool -message SimpleMsg { - string plain_field = 1; - map map_field = 2; - repeated string slice_field = 3; -} - -// NestedMsg is designed to test the nested message component -message NestedMsg { - SimpleMsg plain_nested_field = 1; - map map_nested_field = 2; - repeated SimpleMsg slice_nested_field = 3; -} - -// StaticallyOpaqueMsg is designed to test the statically opaque message component -// All fields are statically marshaled to the NestedMsg type -message StaticallyOpaqueMsg { - bytes plain_opaque_field = 1; - map map_opaque_field = 2; - repeated bytes slice_opaque_field = 3; -} - -// VariablyOpaqueMsg is designed to test the staticaly opaque message component -// The opaque type is determined by opaque_type -message VariablyOpaqueMsg { - string opaque_type = 1; - bytes plain_opaque_field = 2; - map map_opaque_field = 3; - repeated bytes slice_opaque_field = 4; -} - -// DynamicMsg is designed to test the dynamic message component -// The dynamic wrapper applied to ContextlessMsg is determined by -// dynamic_type -message DynamicMsg { - string dynamic_type = 1; - ContextlessMsg plain_dynamic_field = 2; - map map_dynamic_field = 3; - repeated ContextlessMsg slice_dynamic_field = 4; -} - -// ContextlessMsg is designed to carry a message of completely arbitrary type -// Because there is no context for the type embedded in the message, the opaque -// type must be dynamically added at runtime -message ContextlessMsg { - bytes opaque_field = 1; -} - -// UnmarshalableDeepFields contains fields which are defined to be opaque, but will -// return an error if they are asked to be deserialized. -message UnmarshalableDeepFields { - bytes plain_opaque_field = 1; - map map_opaque_field = 2; - repeated bytes slice_opaque_field = 3; -} diff --git a/common/tools/protolator/variably_opaque_test.go b/common/tools/protolator/variably_opaque_test.go deleted file mode 100644 index d16844e12c0..00000000000 --- a/common/tools/protolator/variably_opaque_test.go +++ /dev/null @@ -1,133 +0,0 @@ -/* -Copyright IBM Corp. 2017 All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package protolator - -import ( - "bytes" - "testing" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/common/tools/protolator/testprotos" - "github.com/hyperledger/fabric/protoutil" - "github.com/stretchr/testify/assert" -) - -func extractNestedMsgPlainField(source []byte) string { - result := &testprotos.NestedMsg{} - err := proto.Unmarshal(source, result) - if err != nil { - panic(err) - } - return result.PlainNestedField.PlainField -} - -func TestPlainVariablyOpaqueMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff} - - pfValue := "foo" - startMsg := &testprotos.VariablyOpaqueMsg{ - OpaqueType: "NestedMsg", - PlainOpaqueField: protoutil.MarshalOrPanic(&testprotos.NestedMsg{ - PlainNestedField: &testprotos.SimpleMsg{ - PlainField: pfValue, - }, - }), - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.VariablyOpaqueMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+extractNestedMsgPlainField(startMsg.PlainOpaqueField), extractNestedMsgPlainField(newMsg.PlainOpaqueField)) - - fieldFactories = []protoFieldFactory{tppff, nestedFieldFactory{}, variablyOpaqueFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+extractNestedMsgPlainField(startMsg.PlainOpaqueField), extractNestedMsgPlainField(newMsg.PlainOpaqueField)) -} - -func TestMapVariablyOpaqueMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff} - - pfValue := "foo" - mapKey := "bar" - startMsg := &testprotos.VariablyOpaqueMsg{ - OpaqueType: "NestedMsg", - MapOpaqueField: map[string][]byte{ - mapKey: protoutil.MarshalOrPanic(&testprotos.NestedMsg{ - PlainNestedField: &testprotos.SimpleMsg{ - PlainField: pfValue, - }, - }), - }, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.VariablyOpaqueMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+extractNestedMsgPlainField(startMsg.MapOpaqueField[mapKey]), extractNestedMsgPlainField(newMsg.MapOpaqueField[mapKey])) - - fieldFactories = []protoFieldFactory{tppff, nestedFieldFactory{}, variablyOpaqueMapFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+extractNestedMsgPlainField(startMsg.MapOpaqueField[mapKey]), extractNestedMsgPlainField(newMsg.MapOpaqueField[mapKey])) -} - -func TestSliceVariablyOpaqueMsg(t *testing.T) { - fromPrefix := "from" - toPrefix := "to" - tppff := &testProtoPlainFieldFactory{ - fromPrefix: fromPrefix, - toPrefix: toPrefix, - } - - fieldFactories = []protoFieldFactory{tppff} - - pfValue := "foo" - startMsg := &testprotos.VariablyOpaqueMsg{ - OpaqueType: "NestedMsg", - SliceOpaqueField: [][]byte{ - protoutil.MarshalOrPanic(&testprotos.NestedMsg{ - PlainNestedField: &testprotos.SimpleMsg{ - PlainField: pfValue, - }, - }), - }, - } - - var buffer bytes.Buffer - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - newMsg := &testprotos.VariablyOpaqueMsg{} - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.NotEqual(t, fromPrefix+toPrefix+extractNestedMsgPlainField(startMsg.SliceOpaqueField[0]), extractNestedMsgPlainField(newMsg.SliceOpaqueField[0])) - - fieldFactories = []protoFieldFactory{tppff, nestedFieldFactory{}, variablyOpaqueSliceFieldFactory{}} - - buffer.Reset() - assert.NoError(t, DeepMarshalJSON(&buffer, startMsg)) - assert.NoError(t, DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newMsg)) - assert.Equal(t, fromPrefix+toPrefix+extractNestedMsgPlainField(startMsg.SliceOpaqueField[0]), extractNestedMsgPlainField(newMsg.SliceOpaqueField[0])) -} diff --git a/go.mod b/go.mod index 2d84d14443b..1d652b3abe7 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hyperledger/fabric-amcl v0.0.0-20200128223036-d1aa2665426a github.com/hyperledger/fabric-chaincode-go v0.0.0-20200128192331-2d899240a7ed - github.com/hyperledger/fabric-config v0.0.0-20200514142724-e1bf69d9f3fe + github.com/hyperledger/fabric-config v0.0.1 github.com/hyperledger/fabric-lib-go v1.0.0 github.com/hyperledger/fabric-protos-go v0.0.0-20200506201313-25f6564b9ac4 github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect diff --git a/go.sum b/go.sum index df66bfc4ead..19a5bf4b948 100644 --- a/go.sum +++ b/go.sum @@ -134,8 +134,8 @@ github.com/hyperledger/fabric-amcl v0.0.0-20200128223036-d1aa2665426a h1:HgdNn3U github.com/hyperledger/fabric-amcl v0.0.0-20200128223036-d1aa2665426a/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE= github.com/hyperledger/fabric-chaincode-go v0.0.0-20200128192331-2d899240a7ed h1:VNnrD/ilIUO9DDHQP/uioYSy1309rYy0Z1jf3GLNRIc= github.com/hyperledger/fabric-chaincode-go v0.0.0-20200128192331-2d899240a7ed/go.mod h1:N7H3sA7Tx4k/YzFq7U0EPdqJtqvM4Kild0JoCc7C0Dc= -github.com/hyperledger/fabric-config v0.0.0-20200514142724-e1bf69d9f3fe h1:Sr+vFM+P3dvuOL+BEo4ggmiFdvdKIcz3RGL41HEpAxQ= -github.com/hyperledger/fabric-config v0.0.0-20200514142724-e1bf69d9f3fe/go.mod h1:aeDZ0moG/qKvwLjddcqYr8+58/oNaJy3HE0tI01546c= +github.com/hyperledger/fabric-config v0.0.1 h1:UcGYqw38UkbIzZRRvuiaAMW6yjg54ymFpiPvsFG9XuI= +github.com/hyperledger/fabric-config v0.0.1/go.mod h1:aeDZ0moG/qKvwLjddcqYr8+58/oNaJy3HE0tI01546c= github.com/hyperledger/fabric-lib-go v1.0.0 h1:UL1w7c9LvHZUSkIvHTDGklxFv2kTeva1QI2emOVc324= github.com/hyperledger/fabric-lib-go v1.0.0/go.mod h1:H362nMlunurmHwkYqR5uHL2UDWbQdbfz74n8kbCFsqc= github.com/hyperledger/fabric-protos-go v0.0.0-20190919234611-2a87503ac7c9/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0= diff --git a/integration/lifecycle/lifecycle_test.go b/integration/lifecycle/lifecycle_test.go index a488f398a6b..0d5bb4c6dd9 100644 --- a/integration/lifecycle/lifecycle_test.go +++ b/integration/lifecycle/lifecycle_test.go @@ -15,9 +15,9 @@ import ( docker "github.com/fsouza/go-dockerclient" "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/protolator" + "github.com/hyperledger/fabric-config/protolator/protoext/ordererext" "github.com/hyperledger/fabric-protos-go/common" - "github.com/hyperledger/fabric/common/tools/protolator" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/ordererext" "github.com/hyperledger/fabric/integration/nwo" "github.com/hyperledger/fabric/integration/nwo/commands" "github.com/hyperledger/fabric/integration/nwo/fabricconfig" diff --git a/internal/configtxlator/rest/protolator_handlers.go b/internal/configtxlator/rest/protolator_handlers.go index a9e4369509d..745d3b7f601 100644 --- a/internal/configtxlator/rest/protolator_handlers.go +++ b/internal/configtxlator/rest/protolator_handlers.go @@ -15,7 +15,7 @@ import ( "github.com/golang/protobuf/proto" "github.com/gorilla/mux" - "github.com/hyperledger/fabric/common/tools/protolator" + "github.com/hyperledger/fabric-config/protolator" ) func getMsgType(r *http.Request) (proto.Message, error) { diff --git a/orderer/common/cluster/util.go b/orderer/common/cluster/util.go index e55f2ef878f..e15d222cc81 100644 --- a/orderer/common/cluster/util.go +++ b/orderer/common/cluster/util.go @@ -18,13 +18,13 @@ import ( "sync/atomic" "time" + "github.com/hyperledger/fabric-config/protolator" "github.com/hyperledger/fabric-protos-go/common" "github.com/hyperledger/fabric/bccsp" "github.com/hyperledger/fabric/common/channelconfig" "github.com/hyperledger/fabric/common/configtx" "github.com/hyperledger/fabric/common/flogging" "github.com/hyperledger/fabric/common/policies" - "github.com/hyperledger/fabric/common/tools/protolator" "github.com/hyperledger/fabric/common/util" "github.com/hyperledger/fabric/internal/pkg/comm" "github.com/hyperledger/fabric/protoutil" diff --git a/orderer/common/server/main.go b/orderer/common/server/main.go index 33e735fe1d4..8209f473ffd 100644 --- a/orderer/common/server/main.go +++ b/orderer/common/server/main.go @@ -10,7 +10,6 @@ import ( "bytes" "context" "fmt" - "github.com/hyperledger/fabric/orderer/common/channelparticipation" "io/ioutil" "net" "net/http" @@ -21,7 +20,10 @@ import ( "syscall" "time" + "github.com/hyperledger/fabric/orderer/common/channelparticipation" + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/protolator" "github.com/hyperledger/fabric-lib-go/healthz" cb "github.com/hyperledger/fabric-protos-go/common" ab "github.com/hyperledger/fabric-protos-go/orderer" @@ -36,7 +38,6 @@ import ( "github.com/hyperledger/fabric/common/ledger/blockledger" "github.com/hyperledger/fabric/common/metrics" "github.com/hyperledger/fabric/common/metrics/disabled" - "github.com/hyperledger/fabric/common/tools/protolator" "github.com/hyperledger/fabric/core/operations" "github.com/hyperledger/fabric/internal/pkg/comm" "github.com/hyperledger/fabric/internal/pkg/identity" diff --git a/orderer/sample_clients/deliver_stdout/client.go b/orderer/sample_clients/deliver_stdout/client.go index 07ba241c80c..e21a22c0c2c 100644 --- a/orderer/sample_clients/deliver_stdout/client.go +++ b/orderer/sample_clients/deliver_stdout/client.go @@ -10,10 +10,10 @@ import ( "math" "os" + "github.com/hyperledger/fabric-config/protolator" cb "github.com/hyperledger/fabric-protos-go/common" ab "github.com/hyperledger/fabric-protos-go/orderer" "github.com/hyperledger/fabric/bccsp/factory" - "github.com/hyperledger/fabric/common/tools/protolator" "github.com/hyperledger/fabric/internal/pkg/identity" mspmgmt "github.com/hyperledger/fabric/msp/mgmt" "github.com/hyperledger/fabric/orderer/common/localconfig" diff --git a/common/tools/protolator/api.go b/vendor/github.com/hyperledger/fabric-config/protolator/api.go similarity index 100% rename from common/tools/protolator/api.go rename to vendor/github.com/hyperledger/fabric-config/protolator/api.go diff --git a/common/tools/protolator/dynamic.go b/vendor/github.com/hyperledger/fabric-config/protolator/dynamic.go similarity index 100% rename from common/tools/protolator/dynamic.go rename to vendor/github.com/hyperledger/fabric-config/protolator/dynamic.go diff --git a/common/tools/protolator/json.go b/vendor/github.com/hyperledger/fabric-config/protolator/json.go similarity index 99% rename from common/tools/protolator/json.go rename to vendor/github.com/hyperledger/fabric-config/protolator/json.go index 1029ff64d37..e4b6d6173de 100644 --- a/common/tools/protolator/json.go +++ b/vendor/github.com/hyperledger/fabric-config/protolator/json.go @@ -16,7 +16,7 @@ import ( "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/common/tools/protolator/protoext" + "github.com/hyperledger/fabric-config/protolator/protoext" ) // MostlyDeterministicMarshal is _NOT_ the function you are looking for. diff --git a/common/tools/protolator/nested.go b/vendor/github.com/hyperledger/fabric-config/protolator/nested.go similarity index 100% rename from common/tools/protolator/nested.go rename to vendor/github.com/hyperledger/fabric-config/protolator/nested.go diff --git a/common/tools/protolator/protoext/commonext/common.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/commonext/common.go similarity index 100% rename from common/tools/protolator/protoext/commonext/common.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/commonext/common.go diff --git a/common/tools/protolator/protoext/commonext/configtx.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/commonext/configtx.go similarity index 100% rename from common/tools/protolator/protoext/commonext/configtx.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/commonext/configtx.go diff --git a/common/tools/protolator/protoext/commonext/configuration.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/commonext/configuration.go similarity index 96% rename from common/tools/protolator/protoext/commonext/configuration.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/commonext/configuration.go index eecbcc4c8fb..f11f86086df 100644 --- a/common/tools/protolator/protoext/commonext/configuration.go +++ b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/commonext/configuration.go @@ -10,12 +10,10 @@ import ( "fmt" "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/protolator/protoext/ordererext" + "github.com/hyperledger/fabric-config/protolator/protoext/peerext" "github.com/hyperledger/fabric-protos-go/common" "github.com/hyperledger/fabric-protos-go/msp" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/ordererext" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/peerext" - - "github.com/pkg/errors" ) type DynamicChannelGroup struct { @@ -46,7 +44,7 @@ func (dcg *DynamicChannelGroup) DynamicMapFieldProto(name string, key string, ba case "Application": return &peerext.DynamicApplicationGroup{ConfigGroup: cg}, nil default: - return nil, errors.Errorf("unknown channel group sub-group '%s'", key) + return nil, fmt.Errorf("unknown channel group sub-group '%s'", key) } case "values": cv, ok := base.(*common.ConfigValue) diff --git a/common/tools/protolator/protoext/commonext/policies.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/commonext/policies.go similarity index 100% rename from common/tools/protolator/protoext/commonext/policies.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/commonext/policies.go diff --git a/common/tools/protolator/protoext/decorate.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/decorate.go similarity index 86% rename from common/tools/protolator/protoext/decorate.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/decorate.go index 31345e1373e..a59565beaba 100644 --- a/common/tools/protolator/protoext/decorate.go +++ b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/decorate.go @@ -8,16 +8,16 @@ package protoext import ( "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/protolator/protoext/commonext" + "github.com/hyperledger/fabric-config/protolator/protoext/ledger/rwsetext" + "github.com/hyperledger/fabric-config/protolator/protoext/mspext" + "github.com/hyperledger/fabric-config/protolator/protoext/ordererext" + "github.com/hyperledger/fabric-config/protolator/protoext/peerext" "github.com/hyperledger/fabric-protos-go/common" "github.com/hyperledger/fabric-protos-go/ledger/rwset" "github.com/hyperledger/fabric-protos-go/msp" "github.com/hyperledger/fabric-protos-go/orderer" "github.com/hyperledger/fabric-protos-go/peer" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/commonext" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/ledger/rwsetext" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/mspext" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/ordererext" - "github.com/hyperledger/fabric/common/tools/protolator/protoext/peerext" ) // Docorate will add additional capabilities to some protobuf messages that diff --git a/common/tools/protolator/protoext/ledger/rwsetext/rwset.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/ledger/rwsetext/rwset.go similarity index 100% rename from common/tools/protolator/protoext/ledger/rwsetext/rwset.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/ledger/rwsetext/rwset.go diff --git a/common/tools/protolator/protoext/mspext/msp_config.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/mspext/msp_config.go similarity index 100% rename from common/tools/protolator/protoext/mspext/msp_config.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/mspext/msp_config.go diff --git a/common/tools/protolator/protoext/mspext/msp_principal.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/mspext/msp_principal.go similarity index 100% rename from common/tools/protolator/protoext/mspext/msp_principal.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/mspext/msp_principal.go diff --git a/common/tools/protolator/protoext/ordererext/configuration.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/ordererext/configuration.go similarity index 100% rename from common/tools/protolator/protoext/ordererext/configuration.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/ordererext/configuration.go diff --git a/common/tools/protolator/protoext/peerext/configuration.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/peerext/configuration.go similarity index 100% rename from common/tools/protolator/protoext/peerext/configuration.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/peerext/configuration.go diff --git a/common/tools/protolator/protoext/peerext/proposal.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/peerext/proposal.go similarity index 100% rename from common/tools/protolator/protoext/peerext/proposal.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/peerext/proposal.go diff --git a/common/tools/protolator/protoext/peerext/proposal_response.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/peerext/proposal_response.go similarity index 100% rename from common/tools/protolator/protoext/peerext/proposal_response.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/peerext/proposal_response.go diff --git a/common/tools/protolator/protoext/peerext/transaction.go b/vendor/github.com/hyperledger/fabric-config/protolator/protoext/peerext/transaction.go similarity index 100% rename from common/tools/protolator/protoext/peerext/transaction.go rename to vendor/github.com/hyperledger/fabric-config/protolator/protoext/peerext/transaction.go diff --git a/common/tools/protolator/statically_opaque.go b/vendor/github.com/hyperledger/fabric-config/protolator/statically_opaque.go similarity index 100% rename from common/tools/protolator/statically_opaque.go rename to vendor/github.com/hyperledger/fabric-config/protolator/statically_opaque.go diff --git a/common/tools/protolator/variably_opaque.go b/vendor/github.com/hyperledger/fabric-config/protolator/variably_opaque.go similarity index 100% rename from common/tools/protolator/variably_opaque.go rename to vendor/github.com/hyperledger/fabric-config/protolator/variably_opaque.go diff --git a/vendor/modules.txt b/vendor/modules.txt index bab404c3d0e..e7d7942fe4b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -165,12 +165,19 @@ github.com/hyperledger/fabric-chaincode-go/pkg/statebased github.com/hyperledger/fabric-chaincode-go/shim github.com/hyperledger/fabric-chaincode-go/shim/internal github.com/hyperledger/fabric-chaincode-go/shimtest -# github.com/hyperledger/fabric-config v0.0.0-20200514142724-e1bf69d9f3fe +# github.com/hyperledger/fabric-config v0.0.1 ## explicit github.com/hyperledger/fabric-config/configtx github.com/hyperledger/fabric-config/configtx/internal/policydsl github.com/hyperledger/fabric-config/configtx/membership github.com/hyperledger/fabric-config/configtx/orderer +github.com/hyperledger/fabric-config/protolator +github.com/hyperledger/fabric-config/protolator/protoext +github.com/hyperledger/fabric-config/protolator/protoext/commonext +github.com/hyperledger/fabric-config/protolator/protoext/ledger/rwsetext +github.com/hyperledger/fabric-config/protolator/protoext/mspext +github.com/hyperledger/fabric-config/protolator/protoext/ordererext +github.com/hyperledger/fabric-config/protolator/protoext/peerext # github.com/hyperledger/fabric-lib-go v1.0.0 ## explicit github.com/hyperledger/fabric-lib-go/healthz