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 <[email protected]>
  • Loading branch information
pfi79 committed Aug 29, 2024
1 parent cbee329 commit cd0f161
Show file tree
Hide file tree
Showing 54 changed files with 825 additions and 529 deletions.
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
6 changes: 3 additions & 3 deletions configtx/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"io"
"math/big"

"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"
)

// SigningIdentity is an MSP Identity that can be used to sign configuration
Expand Down
4 changes: 2 additions & 2 deletions configtx/signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"testing"
"time"

"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 TestSign(t *testing.T) {
Expand Down
Loading

0 comments on commit cd0f161

Please sign in to comment.