Skip to content

Commit

Permalink
update fabric-proto-go dependency and tests (#56)
Browse files Browse the repository at this point in the history
Signed-off-by: May Rosenbaum <mayro1595@gmail.com>
  • Loading branch information
MayRosenbaum authored Jun 20, 2023
1 parent c29f04f commit 88e418e
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 56 deletions.
2 changes: 1 addition & 1 deletion ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trigger:

variables:
branch: $[ coalesce(variables['system.PullRequest.TargetBranch'], variables['build.SourceBranchName']) ]
GO_VERSION: 1.16.7
GO_VERSION: 1.20
PATH: $(Agent.BuildDirectory)/go/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin

pool:
Expand Down
1 change: 1 addition & 0 deletions ci/tools/tools.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build tools
// +build tools

// Copyright the Hyperledger Fabric contributors. All rights reserved.
Expand Down
15 changes: 8 additions & 7 deletions configtx/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func TestAppOrgRemoveAnchorPeerFailure(t *testing.T) {
orgName: "Org1",
anchorPeerToRemove: Address{Host: "host1", Port: 123},
configValues: map[string]*cb.ConfigValue{AnchorPeersKey: {Value: []byte("a little fire")}},
expectedErr: "failed unmarshaling anchor peer endpoints for application org Org1: proto: can't skip unknown wire type 6",
expectedErr: "failed unmarshaling anchor peer endpoints for application org Org1: proto",
},
}

Expand Down Expand Up @@ -547,7 +547,7 @@ func TestAppOrgRemoveAnchorPeerFailure(t *testing.T) {
c := New(config)

err = c.Application().Organization(tt.orgName).RemoveAnchorPeer(tt.anchorPeerToRemove)
gt.Expect(err).To(MatchError(tt.expectedErr))
gt.Expect(err.Error()).To(ContainSubstring(tt.expectedErr))
})
}
}
Expand Down Expand Up @@ -1083,7 +1083,8 @@ func TestApplicationACLsFailure(t *testing.T) {
c := New(config)

applicationACLs, err := c.Application().ACLs()
gt.Expect(err).To(MatchError("unmarshaling ACLs: unexpected EOF"))
gt.Expect(err.Error()).To(ContainSubstring("unmarshaling ACLs: proto:"))
gt.Expect(err.Error()).To(ContainSubstring("cannot parse invalid wire-format data"))
gt.Expect(applicationACLs).To(BeNil())
}

Expand Down Expand Up @@ -1354,7 +1355,7 @@ func TestAppOrgAddApplicationCapabilityFailures(t *testing.T) {
},
}
},
expectedErr: "retrieving application capabilities: unmarshaling capabilities: proto: can't skip unknown wire type 6",
expectedErr: "retrieving application capabilities: unmarshaling capabilities: proto",
},
}

Expand All @@ -1381,7 +1382,7 @@ func TestAppOrgAddApplicationCapabilityFailures(t *testing.T) {
c := New(config)

err = c.Application().AddCapability(tt.capability)
gt.Expect(err).To(MatchError(tt.expectedErr))
gt.Expect(err.Error()).To(ContainSubstring(tt.expectedErr))
})
}
}
Expand Down Expand Up @@ -1518,7 +1519,7 @@ func TestAppOrgRemoveApplicationCapabilityFailures(t *testing.T) {
},
}
},
expectedErr: "retrieving application capabilities: unmarshaling capabilities: proto: can't skip unknown wire type 6",
expectedErr: "retrieving application capabilities: unmarshaling capabilities: proto",
},
}

Expand All @@ -1545,7 +1546,7 @@ func TestAppOrgRemoveApplicationCapabilityFailures(t *testing.T) {
c := New(config)

err = c.Application().RemoveCapability(tt.capability)
gt.Expect(err).To(MatchError(tt.expectedErr))
gt.Expect(err.Error()).To(ContainSubstring(tt.expectedErr))
})
}
}
Expand Down
14 changes: 7 additions & 7 deletions configtx/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestSetChannelCapabilityFailures(t *testing.T) {
},
},
},
expectedErr: "retrieving channel capabilities: unmarshaling capabilities: proto: can't skip unknown wire type 6",
expectedErr: "retrieving channel capabilities: unmarshaling capabilities: proto",
},
}

Expand All @@ -124,7 +124,7 @@ func TestSetChannelCapabilityFailures(t *testing.T) {
c := New(tt.config)

err := c.Channel().AddCapability(tt.capability)
gt.Expect(err).To(MatchError(tt.expectedErr))
gt.Expect(err.Error()).To(ContainSubstring(tt.expectedErr))
})
}
}
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestRemoveChannelCapabilityFailures(t *testing.T) {
},
},
},
expectedErr: "retrieving channel capabilities: unmarshaling capabilities: proto: can't skip unknown wire type 6",
expectedErr: "retrieving channel capabilities: unmarshaling capabilities: proto",
},
}

Expand All @@ -225,7 +225,7 @@ func TestRemoveChannelCapabilityFailures(t *testing.T) {
c := New(tt.config)

err := c.Channel().RemoveCapability(tt.capability)
gt.Expect(err).To(MatchError(tt.expectedErr))
gt.Expect(err.Error()).To(ContainSubstring(tt.expectedErr))
})
}
}
Expand Down Expand Up @@ -490,7 +490,7 @@ func TestConfigurationFailures(t *testing.T) {
},
},
},
expectedErr: "unmarshaling Consortium: proto: can't skip unknown wire type 6",
expectedErr: "unmarshaling Consortium: proto:",
},
{
testName: "when retrieving existing orderer group",
Expand Down Expand Up @@ -575,7 +575,7 @@ func TestConfigurationFailures(t *testing.T) {
},
},
},
expectedErr: "retrieving channel capabilities: unmarshaling capabilities: proto: can't skip unknown wire type 6",
expectedErr: "retrieving channel capabilities: unmarshaling capabilities: proto",
},
}

Expand All @@ -589,7 +589,7 @@ func TestConfigurationFailures(t *testing.T) {
c := New(tt.config)

_, err := c.Channel().Configuration()
gt.Expect(err).To(MatchError(tt.expectedErr))
gt.Expect(err.Error()).To(ContainSubstring(tt.expectedErr))
})
}
}
4 changes: 2 additions & 2 deletions configtx/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ func TestNewEnvelopeFailures(t *testing.T) {
{
spec: "when the marshaled config update isn't a config update",
marshaledUpdate: []byte("not-a-config-update"),
expectedErr: "unmarshaling config update: proto: can't skip unknown wire type 6",
expectedErr: "unmarshaling config update: proto",
},
}

Expand All @@ -1925,7 +1925,7 @@ func TestNewEnvelopeFailures(t *testing.T) {
gt := NewGomegaWithT(t)

env, err := NewEnvelope(tc.marshaledUpdate)
gt.Expect(err).To(MatchError(tc.expectedErr))
gt.Expect(err.Error()).To(ContainSubstring(tc.expectedErr))
gt.Expect(env).To(BeNil())
})
}
Expand Down
12 changes: 6 additions & 6 deletions configtx/internal/policydsl/policyparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,17 @@ func newContext() *context {
// GATE(P[, P])
//
// where:
// - GATE is either "and" or "or"
// - P is either a principal or another nested call to GATE
// - GATE is either "and" or "or"
// - P is either a principal or another nested call to GATE
//
// A principal is defined as:
//
// ORG.ROLE
// # ORG.ROLE
//
// where:
// - ORG is a string (representing the MSP identifier)
// - ROLE takes the value of any of the RoleXXX constants representing
// the required role
// - ORG is a string (representing the MSP identifier)
// - ROLE takes the value of any of the RoleXXX constants representing
// the required role
func FromString(policy string) (*cb.SignaturePolicyEnvelope, error) {
// first we translate the and/or business into outof gates
intermediate, err := govaluate.NewEvaluableExpressionWithFunctions(
Expand Down
20 changes: 10 additions & 10 deletions configtx/msp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestMSPConfigurationFailures(t *testing.T) {
badCert := &x509.Certificate{}
msp.RootCerts = append(msp.RootCerts, badCert)
},
expectedErr: "parsing root certs: asn1: syntax error: sequence truncated",
expectedErr: "parsing root certs: x509: malformed certificate",
},
{
name: "Bad intermediate cert",
Expand All @@ -57,7 +57,7 @@ func TestMSPConfigurationFailures(t *testing.T) {
mspMod: func(msp *MSP) {
msp.IntermediateCerts = append(msp.IntermediateCerts, badCert)
},
expectedErr: "parsing intermediate certs: asn1: syntax error: sequence truncated",
expectedErr: "parsing intermediate certs: x509: malformed certificate",
},
{
name: "Bad admin cert",
Expand All @@ -66,7 +66,7 @@ func TestMSPConfigurationFailures(t *testing.T) {
mspMod: func(msp *MSP) {
msp.Admins = append(msp.Admins, badCert)
},
expectedErr: "parsing admin certs: asn1: syntax error: sequence truncated",
expectedErr: "parsing admin certs: x509: malformed certificate",
},
{
name: "Bad OU Identifier cert",
Expand All @@ -75,7 +75,7 @@ func TestMSPConfigurationFailures(t *testing.T) {
mspMod: func(msp *MSP) {
msp.OrganizationalUnitIdentifiers[0].Certificate = badCert
},
expectedErr: "parsing ou identifiers: asn1: syntax error: sequence truncated",
expectedErr: "parsing ou identifiers: x509: malformed certificate",
},
{
name: "Bad tls root cert",
Expand All @@ -84,7 +84,7 @@ func TestMSPConfigurationFailures(t *testing.T) {
mspMod: func(msp *MSP) {
msp.TLSRootCerts = append(msp.TLSRootCerts, badCert)
},
expectedErr: "parsing tls root certs: asn1: syntax error: sequence truncated",
expectedErr: "parsing tls root certs: x509: malformed certificate",
},
{
name: "Bad tls intermediate cert",
Expand All @@ -93,7 +93,7 @@ func TestMSPConfigurationFailures(t *testing.T) {
mspMod: func(msp *MSP) {
msp.TLSIntermediateCerts = append(msp.TLSIntermediateCerts, badCert)
},
expectedErr: "parsing tls intermediate certs: asn1: syntax error: sequence truncated",
expectedErr: "parsing tls intermediate certs: x509: malformed certificate",
},
{
name: "Bad Client OU Identifier cert",
Expand All @@ -102,7 +102,7 @@ func TestMSPConfigurationFailures(t *testing.T) {
mspMod: func(msp *MSP) {
msp.NodeOUs.ClientOUIdentifier.Certificate = badCert
},
expectedErr: "parsing client ou identifier cert: asn1: syntax error: sequence truncated",
expectedErr: "parsing client ou identifier cert: x509: malformed certificate",
},
{
name: "Bad Peer OU Identifier cert",
Expand All @@ -111,7 +111,7 @@ func TestMSPConfigurationFailures(t *testing.T) {
mspMod: func(msp *MSP) {
msp.NodeOUs.PeerOUIdentifier.Certificate = badCert
},
expectedErr: "parsing peer ou identifier cert: asn1: syntax error: sequence truncated",
expectedErr: "parsing peer ou identifier cert: x509: malformed certificate",
},
{
name: "Bad Admin OU Identifier cert",
Expand All @@ -120,7 +120,7 @@ func TestMSPConfigurationFailures(t *testing.T) {
mspMod: func(msp *MSP) {
msp.NodeOUs.AdminOUIdentifier.Certificate = badCert
},
expectedErr: "parsing admin ou identifier cert: asn1: syntax error: sequence truncated",
expectedErr: "parsing admin ou identifier cert: x509: malformed certificate",
},
{
name: "Bad Orderer OU Identifier cert",
Expand All @@ -129,7 +129,7 @@ func TestMSPConfigurationFailures(t *testing.T) {
mspMod: func(msp *MSP) {
msp.NodeOUs.OrdererOUIdentifier.Certificate = badCert
},
expectedErr: "parsing orderer ou identifier cert: asn1: syntax error: sequence truncated",
expectedErr: "parsing orderer ou identifier cert: x509: malformed certificate",
},
}

Expand Down
18 changes: 10 additions & 8 deletions configtx/orderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,8 @@ func TestRemoveOrdererEndpointFailure(t *testing.T) {
c := New(config)

err := c.Orderer().Organization("OrdererOrg").RemoveEndpoint(Address{Host: "127.0.0.1", Port: 8050})
gt.Expect(err).To(MatchError("failed unmarshaling endpoints for orderer org OrdererOrg: proto: can't skip unknown wire type 6"))
gt.Expect(err.Error()).To(ContainSubstring("failed unmarshaling endpoints for orderer org OrdererOrg: proto:"))
gt.Expect(err.Error()).To(ContainSubstring("cannot parse invalid wire-format data"))
}

func TestGetOrdererOrg(t *testing.T) {
Expand Down Expand Up @@ -2868,7 +2869,7 @@ func TestAddOrdererCapabilityFailures(t *testing.T) {
},
}
},
expectedErr: "retrieving orderer capabilities: unmarshaling capabilities: proto: can't skip unknown wire type 6",
expectedErr: "retrieving orderer capabilities: unmarshaling capabilities: proto",
},
}

Expand All @@ -2895,7 +2896,7 @@ func TestAddOrdererCapabilityFailures(t *testing.T) {
c := New(config)

err = c.Orderer().AddCapability(tt.capability)
gt.Expect(err).To(MatchError(tt.expectedErr))
gt.Expect(err.Error()).To(ContainSubstring(tt.expectedErr))
})
}
}
Expand Down Expand Up @@ -3172,7 +3173,7 @@ func TestRemoveOrdererCapabilityFailures(t *testing.T) {
},
}
},
expectedErr: "retrieving orderer capabilities: unmarshaling capabilities: proto: can't skip unknown wire type 6",
expectedErr: "retrieving orderer capabilities: unmarshaling capabilities: proto",
},
}

Expand All @@ -3199,7 +3200,7 @@ func TestRemoveOrdererCapabilityFailures(t *testing.T) {
c := New(config)

err = c.Orderer().RemoveCapability(tt.capability)
gt.Expect(err).To(MatchError(tt.expectedErr))
gt.Expect(err.Error()).To(ContainSubstring(tt.expectedErr))
})
}
}
Expand Down Expand Up @@ -4661,8 +4662,9 @@ func TestSetMaxMessageCountFailures(t *testing.T) {
}

c := New(config)

err = c.Orderer().BatchSize().SetMaxMessageCount(5)
gt.Expect(err).To(MatchError("unexpected EOF"))
gt.Expect(err.Error()).To(ContainSubstring("cannot parse invalid wire-format data"))
}

func TestSetAbsoluteMaxBytesFailures(t *testing.T) {
Expand All @@ -4685,7 +4687,7 @@ func TestSetAbsoluteMaxBytesFailures(t *testing.T) {

c := New(config)
err = c.Orderer().BatchSize().SetAbsoluteMaxBytes(5)
gt.Expect(err).To(MatchError("unexpected EOF"))
gt.Expect(err.Error()).To(ContainSubstring("cannot parse invalid wire-format data"))
}

func TestSetPreferredMaxBytesFailures(t *testing.T) {
Expand All @@ -4708,7 +4710,7 @@ func TestSetPreferredMaxBytesFailures(t *testing.T) {

c := New(config)
err = c.Orderer().BatchSize().SetPreferredMaxBytes(5)
gt.Expect(err).To(MatchError("unexpected EOF"))
gt.Expect(err.Error()).To(ContainSubstring("cannot parse invalid wire-format data"))
}

func TestSetBatchTimeout(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions configtx/signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ func TestToLowS(t *testing.T) {
},
},
} {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()

Expand Down
17 changes: 14 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
module github.com/hyperledger/fabric-config

go 1.14
go 1.20

require (
github.com/Knetic/govaluate v3.0.0+incompatible
github.com/golang/protobuf v1.3.3
github.com/hyperledger/fabric-protos-go v0.0.0-20200424173316-dd554ba3746e
github.com/golang/protobuf v1.5.2
github.com/hyperledger/fabric-protos-go v0.3.0
github.com/onsi/gomega v1.9.0
)

require (
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
)
Loading

0 comments on commit 88e418e

Please sign in to comment.