Skip to content

Commit

Permalink
add fabric-protos-go-apiv2 and change github.com/golang/protobuf on g…
Browse files Browse the repository at this point in the history
…oogle.golang.org/protobuf

Signed-off-by: Fedor Partanskiy <fredprtnsk@gmail.com>
  • Loading branch information
pfi79 authored and denyeart committed Sep 12, 2024
1 parent cbee329 commit df5311a
Show file tree
Hide file tree
Showing 55 changed files with 849 additions and 531 deletions.
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#SPDX-License-Identifier: Apache-2.0
.#*
*~
*#
/bin
/build
/.build
*.cov
/docs/build/*
.DS_Store
.*-dummy
.gradle
.idea
*.iml
*.log
.project
/release
report.xml
results.xml
.settings
.*.sw*
tags
.tags
TESTS*.xml
.tox/
.vagrant/
.vscode
6 changes: 3 additions & 3 deletions configtx/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"errors"
"fmt"

"github.com/golang/protobuf/proto"
cb "github.com/hyperledger/fabric-protos-go/common"
pb "github.com/hyperledger/fabric-protos-go/peer"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
pb "github.com/hyperledger/fabric-protos-go-apiv2/peer"
"google.golang.org/protobuf/proto"
)

// Application is a copy of the orderer configuration with the addition of an anchor peers
Expand Down
6 changes: 3 additions & 3 deletions configtx/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"math/big"
"testing"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/configtx/internal/policydsl"
"github.com/hyperledger/fabric-config/protolator"
"github.com/hyperledger/fabric-config/protolator/protoext/peerext"
cb "github.com/hyperledger/fabric-protos-go/common"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/proto"
)

func TestNewApplicationGroup(t *testing.T) {
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestNewApplicationGroup(t *testing.T) {
expectedApplication := &cb.ConfigGroup{}
err = protolator.DeepUnmarshalJSON(bytes.NewBufferString(expectedApplicationGroup), expectedApplication)
gt.Expect(err).ToNot(HaveOccurred())
gt.Expect(applicationGroup).To(Equal(expectedApplication))
gt.Expect(proto.Equal(applicationGroup, expectedApplication)).To(BeTrue())
}

func TestNewApplicationGroupFailure(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions configtx/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"errors"
"fmt"

"github.com/golang/protobuf/proto"
cb "github.com/hyperledger/fabric-protos-go/common"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
"google.golang.org/protobuf/proto"
)

// capabilitiesValue returns the config definition for a set of capabilities.
Expand Down
2 changes: 1 addition & 1 deletion configtx/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"errors"
"fmt"

cb "github.com/hyperledger/fabric-protos-go/common"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
)

// ChannelGroup encapsulates the parts of the config that control channels.
Expand Down
2 changes: 1 addition & 1 deletion configtx/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/hyperledger/fabric-config/protolator"
"github.com/hyperledger/fabric-config/protolator/protoext/commonext"
cb "github.com/hyperledger/fabric-protos-go/common"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
. "github.com/onsi/gomega"
)

Expand Down
17 changes: 7 additions & 10 deletions configtx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ import (
"strconv"
"strings"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"
cb "github.com/hyperledger/fabric-protos-go/common"
mb "github.com/hyperledger/fabric-protos-go/msp"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
mb "github.com/hyperledger/fabric-protos-go-apiv2/msp"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
)

// Channel is a channel configuration.
Expand Down Expand Up @@ -535,11 +534,9 @@ func newEnvelope(
// channelHeader creates a ChannelHeader.
func channelHeader(headerType cb.HeaderType, version int32, channelID string, epoch uint64) *cb.ChannelHeader {
return &cb.ChannelHeader{
Type: int32(headerType),
Version: version,
Timestamp: &timestamp.Timestamp{
Seconds: ptypes.TimestampNow().GetSeconds(),
},
Type: int32(headerType),
Version: version,
Timestamp: timestamppb.Now(),
ChannelId: channelID,
Epoch: epoch,
}
Expand Down
17 changes: 8 additions & 9 deletions configtx/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import (
"testing"

"github.com/hyperledger/fabric-config/configtx/orderer"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/protolator"
cb "github.com/hyperledger/fabric-protos-go/common"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/proto"
)

func TestNewConfigTx(t *testing.T) {
Expand Down Expand Up @@ -233,8 +232,8 @@ func TestNewCreateChannelTx(t *testing.T) {
err = proto.Unmarshal(expectedPayload.Data, &expectedData)
gt.Expect(err).NotTo(HaveOccurred())

expectedConfigUpdate := cb.ConfigUpdate{}
err = proto.Unmarshal(expectedData.ConfigUpdate, &expectedConfigUpdate)
expectedConfigUpdate := &cb.ConfigUpdate{}
err = proto.Unmarshal(expectedData.ConfigUpdate, expectedConfigUpdate)
gt.Expect(err).NotTo(HaveOccurred())

actualPayload := cb.Payload{}
Expand All @@ -249,11 +248,11 @@ func TestNewCreateChannelTx(t *testing.T) {
err = proto.Unmarshal(actualPayload.Data, &actualData)
gt.Expect(err).NotTo(HaveOccurred())

actualConfigUpdate := cb.ConfigUpdate{}
err = proto.Unmarshal(actualData.ConfigUpdate, &actualConfigUpdate)
actualConfigUpdate := &cb.ConfigUpdate{}
err = proto.Unmarshal(actualData.ConfigUpdate, actualConfigUpdate)
gt.Expect(err).NotTo(HaveOccurred())

gt.Expect(actualConfigUpdate).To(Equal(expectedConfigUpdate))
gt.Expect(proto.Equal(actualConfigUpdate, expectedConfigUpdate)).To(BeTrue())

// setting timestamps to match in ConfigUpdate
actualTimestamp := actualHeader.Timestamp
Expand All @@ -272,7 +271,7 @@ func TestNewCreateChannelTx(t *testing.T) {
expectedEnvelope.Payload, err = proto.Marshal(&expectedPayload)
gt.Expect(err).NotTo(HaveOccurred())

gt.Expect(envelope).To(Equal(&expectedEnvelope))
gt.Expect(proto.Equal(envelope, &expectedEnvelope)).To(BeTrue())
}

func TestNewCreateChannelTxFailure(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions configtx/consortiums.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"errors"
"fmt"

"github.com/golang/protobuf/proto"
cb "github.com/hyperledger/fabric-protos-go/common"
mb "github.com/hyperledger/fabric-protos-go/msp"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
mb "github.com/hyperledger/fabric-protos-go-apiv2/msp"
"google.golang.org/protobuf/proto"
)

// Consortium is a group of non-orderer organizations used in channel transactions.
Expand Down
5 changes: 2 additions & 3 deletions configtx/consortiums_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ import (
"testing"

"github.com/hyperledger/fabric-config/configtx/orderer"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/protolator"
"github.com/hyperledger/fabric-config/protolator/protoext/commonext"
cb "github.com/hyperledger/fabric-protos-go/common"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/proto"
)

func TestNewConsortiumsGroup(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions configtx/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import (
"testing"
"time"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/configtx"
"github.com/hyperledger/fabric-config/configtx/membership"
"github.com/hyperledger/fabric-config/configtx/orderer"
cb "github.com/hyperledger/fabric-protos-go/common"
mb "github.com/hyperledger/fabric-protos-go/msp"
ob "github.com/hyperledger/fabric-protos-go/orderer"
pb "github.com/hyperledger/fabric-protos-go/peer"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
mb "github.com/hyperledger/fabric-protos-go-apiv2/msp"
ob "github.com/hyperledger/fabric-protos-go-apiv2/orderer"
pb "github.com/hyperledger/fabric-protos-go-apiv2/peer"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/proto"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions configtx/internal/policydsl/policyparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"strings"

"github.com/Knetic/govaluate"
"github.com/golang/protobuf/proto"
cb "github.com/hyperledger/fabric-protos-go/common"
mb "github.com/hyperledger/fabric-protos-go/msp"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
mb "github.com/hyperledger/fabric-protos-go-apiv2/msp"
"google.golang.org/protobuf/proto"
)

// Gate values
Expand Down
6 changes: 3 additions & 3 deletions configtx/internal/policydsl/policyparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ package policydsl_test
import (
"testing"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/configtx/internal/policydsl"
cb "github.com/hyperledger/fabric-protos-go/common"
mb "github.com/hyperledger/fabric-protos-go/msp"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
mb "github.com/hyperledger/fabric-protos-go-apiv2/msp"
"google.golang.org/protobuf/proto"

. "github.com/onsi/gomega"
)
Expand Down
6 changes: 3 additions & 3 deletions configtx/msp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
"reflect"
"time"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/configtx/membership"
cb "github.com/hyperledger/fabric-protos-go/common"
mb "github.com/hyperledger/fabric-protos-go/msp"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
mb "github.com/hyperledger/fabric-protos-go-apiv2/msp"
"google.golang.org/protobuf/proto"
)

// MSP is the configuration information for a Fabric MSP.
Expand Down
10 changes: 5 additions & 5 deletions configtx/msp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (
"testing"
"time"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/configtx/membership"
"github.com/hyperledger/fabric-config/configtx/orderer"
"github.com/hyperledger/fabric-config/protolator"
cb "github.com/hyperledger/fabric-protos-go/common"
mb "github.com/hyperledger/fabric-protos-go/msp"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
mb "github.com/hyperledger/fabric-protos-go-apiv2/msp"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/proto"
)

func TestMSPConfigurationFailures(t *testing.T) {
Expand Down Expand Up @@ -275,7 +275,7 @@ func TestMSPToProto(t *testing.T) {

fabricMSPConfigProto, err := msp.toProto()
gt.Expect(err).NotTo(HaveOccurred())
gt.Expect(fabricMSPConfigProto).To(Equal(expectedFabricMSPConfigProto))
gt.Expect(proto.Equal(fabricMSPConfigProto, expectedFabricMSPConfigProto)).To(BeTrue())
}

func TestMSPToProtoNoNodeOUs(t *testing.T) {
Expand Down Expand Up @@ -328,7 +328,7 @@ func TestMSPToProtoNoNodeOUs(t *testing.T) {

fabricMSPConfigProto, err := msp.toProto()
gt.Expect(err).NotTo(HaveOccurred())
gt.Expect(fabricMSPConfigProto).To(Equal(expectedFabricMSPConfigProto))
gt.Expect(proto.Equal(fabricMSPConfigProto, expectedFabricMSPConfigProto)).To(BeTrue())
}

func TestParseCertificateFromBytesFailure(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions configtx/orderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
"reflect"
"time"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/configtx/orderer"
cb "github.com/hyperledger/fabric-protos-go/common"
ob "github.com/hyperledger/fabric-protos-go/orderer"
eb "github.com/hyperledger/fabric-protos-go/orderer/etcdraft"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
ob "github.com/hyperledger/fabric-protos-go-apiv2/orderer"
eb "github.com/hyperledger/fabric-protos-go-apiv2/orderer/etcdraft"
"google.golang.org/protobuf/proto"
)

const (
Expand Down
14 changes: 7 additions & 7 deletions configtx/orderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
"testing"
"time"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/configtx/orderer"
"github.com/hyperledger/fabric-config/protolator"
"github.com/hyperledger/fabric-config/protolator/protoext/ordererext"
cb "github.com/hyperledger/fabric-protos-go/common"
ob "github.com/hyperledger/fabric-protos-go/orderer"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
ob "github.com/hyperledger/fabric-protos-go-apiv2/orderer"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/proto"
)

func TestNewOrdererGroup(t *testing.T) {
Expand Down Expand Up @@ -3755,14 +3755,14 @@ func TestRemoveOrdererPolicyFailures(t *testing.T) {

tests := []struct {
testName string
ordererGrpMod func(cb.ConfigGroup) *cb.ConfigGroup
ordererGrpMod func(*cb.ConfigGroup) *cb.ConfigGroup
policyName string
expectedErr string
}{
{
testName: "when removing blockvalidation policy",
ordererGrpMod: func(og cb.ConfigGroup) *cb.ConfigGroup {
return &og
ordererGrpMod: func(og *cb.ConfigGroup) *cb.ConfigGroup {
return proto.Clone(og).(*cb.ConfigGroup)
},
policyName: BlockValidationPolicyKey,
expectedErr: "BlockValidation policy must be defined",
Expand All @@ -3774,7 +3774,7 @@ func TestRemoveOrdererPolicyFailures(t *testing.T) {
t.Run(tt.testName, func(t *testing.T) {
gt := NewGomegaWithT(t)

ordererGroup := tt.ordererGrpMod(*ordererGroup)
ordererGroup := tt.ordererGrpMod(ordererGroup)
if ordererGroup == nil {
delete(config.ChannelGroup.Groups, OrdererGroupKey)
} else {
Expand Down
8 changes: 4 additions & 4 deletions configtx/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ package configtx
import (
"fmt"

"github.com/golang/protobuf/proto"
cb "github.com/hyperledger/fabric-protos-go/common"
mb "github.com/hyperledger/fabric-protos-go/msp"
pb "github.com/hyperledger/fabric-protos-go/peer"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
mb "github.com/hyperledger/fabric-protos-go-apiv2/msp"
pb "github.com/hyperledger/fabric-protos-go-apiv2/peer"
"google.golang.org/protobuf/proto"
)

// newOrgConfigGroup returns an config group for an organization.
Expand Down
6 changes: 3 additions & 3 deletions configtx/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"strconv"
"strings"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/configtx/internal/policydsl"
cb "github.com/hyperledger/fabric-protos-go/common"
mb "github.com/hyperledger/fabric-protos-go/msp"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
mb "github.com/hyperledger/fabric-protos-go-apiv2/msp"
"google.golang.org/protobuf/proto"
)

// getPolicies returns a map of Policy from given map of ConfigPolicy in organization config group.
Expand Down
4 changes: 2 additions & 2 deletions configtx/policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ package configtx
import (
"testing"

"github.com/golang/protobuf/proto"
cb "github.com/hyperledger/fabric-protos-go/common"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/proto"
)

func TestPolicies(t *testing.T) {
Expand Down
Loading

0 comments on commit df5311a

Please sign in to comment.