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 22, 2024
1 parent 71a6407 commit a86c531
Show file tree
Hide file tree
Showing 54 changed files with 816 additions and 518 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
6 changes: 3 additions & 3 deletions configtx/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"fmt"
"testing"

"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 @@ -270,7 +270,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
4 changes: 2 additions & 2 deletions configtx/consortiums_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
"math/big"
"testing"

"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 @@ -270,7 +270,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 @@ -323,7 +323,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
6 changes: 3 additions & 3 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
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
4 changes: 2 additions & 2 deletions configtx/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"bytes"
"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"
)

// Compute computes the difference between two *cb.Configs and returns the
Expand Down
6 changes: 4 additions & 2 deletions configtx/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ package configtx
import (
"testing"

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

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

Expand Down Expand Up @@ -147,7 +149,7 @@ func TestGroupPolicyModification(t *testing.T) {
Groups: map[string]*cb.ConfigGroup{},
}

gt.Expect(expectedWriteSet).To(Equal(cu.WriteSet), "Mismatched write set")
gt.Expect(proto.Equal(expectedWriteSet, cu.WriteSet)).To(BeTrue(), "Mismatched write set")
}

func TestGroupValueModification(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ go 1.20

require (
github.com/Knetic/govaluate v3.0.0+incompatible
github.com/golang/protobuf v1.5.3
github.com/hyperledger/fabric-protos-go v0.3.3
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.3
github.com/onsi/gomega v1.9.0
google.golang.org/protobuf v1.33.0
)

require (
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3 // indirect
google.golang.org/protobuf v1.32.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/grpc v1.57.0 // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
)
Loading

0 comments on commit a86c531

Please sign in to comment.