Skip to content

Commit 64562b7

Browse files
committed
Generalize EnableCapabilities function for int. tests
FAB-15524 #done Change-Id: Ib1465f633dd62f3f83acd4cd0ed2b58fafc487d6 Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent a1ec9aa commit 64562b7

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

integration/discovery/discovery_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ var _ = Describe("DiscoveryService", func() {
206206
// using _lifecycle
207207
//
208208

209-
By("enabling V2_0 capabilities on the channel")
210-
nwo.EnableV2_0Capabilities(network, "testchannel", orderer, org1Peer0, org2Peer0, org3Peer0)
209+
By("enabling V2_0 application capabilities on the channel")
210+
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, org1Peer0, org2Peer0, org3Peer0)
211211

212212
By("discovering endorsers when missing chaincode")
213213
endorsers = commands.Endorsers{
@@ -401,7 +401,8 @@ var _ = Describe("DiscoveryService", func() {
401401
//
402402
// using _lifecycle
403403
//
404-
nwo.EnableV2_0Capabilities(network, "testchannel", orderer, org1Peer0, org2Peer0, org3Peer0)
404+
By("enabling V2_0 application capabilities on the channel")
405+
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, org1Peer0, org2Peer0, org3Peer0)
405406

406407
By("deploying chaincode using _lifecycle")
407408
chaincode = nwo.Chaincode{

integration/e2e/acl_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ var _ = Describe("EndToEndACL", func() {
289289
nwo.InstallChaincodeNewLifecycle(network, chaincode, org1Peer0, org2Peer0)
290290

291291
//
292-
// when the V2_0 capabilities flag has not yet been enabled
292+
// when the V2_0 application capabilities flag has not yet been enabled
293293
//
294294
By("approving a chaincode definition on a channel without V2_0 capabilities enabled")
295295
sess, err = network.PeerAdminSession(org1Peer0, commands.ChaincodeApproveForMyOrgLifecycle{
@@ -327,9 +327,9 @@ var _ = Describe("EndToEndACL", func() {
327327
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit())
328328
Expect(sess.Err).To(gbytes.Say("Error: proposal failed with status: 500 - cannot use new lifecycle for channel 'testchannel' as it does not have the required capabilities enabled"))
329329

330-
// enable V2_0 Capabilities on the channel
331-
By("enabling V2_0 capabilities")
332-
nwo.EnableV2_0Capabilities(network, "testchannel", orderer, org1Peer0, org2Peer0)
330+
// enable V2_0 application capabilities on the channel
331+
By("enabling V2_0 application capabilities on the channel")
332+
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, org1Peer0, org2Peer0)
333333

334334
//
335335
// when the ACL policy for _lifecycle/ApproveChaincodeDefinitionForOrg is not satisfied

integration/nwo/deploy.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,25 +401,24 @@ func listInstantiated(n *Network, peer *Peer, channel string) func() *gbytes.Buf
401401
}
402402
}
403403

404-
// EnableV2_0Capabilities enables the V2_0 capabilities for a running network.
404+
// EnableCapabilities enables a specific capabilities flag for a running network.
405405
// It generates the config update using the first peer, signs the configuration
406406
// with the subsequent peers, and then submits the config update using the
407407
// first peer.
408-
func EnableV2_0Capabilities(network *Network, channel string, orderer *Orderer, peers ...*Peer) {
408+
func EnableCapabilities(network *Network, channel, capabilitiesGroup, capabilitiesVersion string, orderer *Orderer, peers ...*Peer) {
409409
if len(peers) == 0 {
410410
return
411411
}
412412

413413
config := GetConfig(network, peers[0], orderer, channel)
414414
updatedConfig := proto.Clone(config).(*common.Config)
415415

416-
// include the V2_0 capability in the config
417-
updatedConfig.ChannelGroup.Groups["Application"].Values["Capabilities"] = &common.ConfigValue{
416+
updatedConfig.ChannelGroup.Groups[capabilitiesGroup].Values["Capabilities"] = &common.ConfigValue{
418417
ModPolicy: "Admins",
419418
Value: protoutil.MarshalOrPanic(
420419
&common.Capabilities{
421420
Capabilities: map[string]*common.Capability{
422-
"V2_0": {},
421+
capabilitiesVersion: {},
423422
},
424423
},
425424
),

integration/nwo/network_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ var _ = Describe("Network", func() {
115115
network.UpdateChannelAnchors(orderer, "testchannel")
116116
network.VerifyMembership(network.PeersWithChannel("testchannel"), "testchannel")
117117

118-
nwo.EnableV2_0Capabilities(network, "testchannel", orderer, network.Peer("org1", "peer1"), network.Peer("org2", "peer1"))
118+
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, network.Peer("org1", "peer1"), network.Peer("org2", "peer1"))
119119
nwo.DeployChaincodeNewLifecycle(network, "testchannel", orderer, chaincode)
120120

121121
RunQueryInvokeQuery(network, orderer, peer, 100)
@@ -286,7 +286,7 @@ var _ = Describe("Network", func() {
286286
network.UpdateChannelAnchors(orderer, "testchannel")
287287
network.VerifyMembership(testPeers, "testchannel")
288288

289-
nwo.EnableV2_0Capabilities(network, "testchannel", orderer, network.Peer("org1", "peer1"), network.Peer("org2", "peer1"))
289+
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, network.Peer("org1", "peer1"), network.Peer("org2", "peer1"))
290290

291291
chaincode := nwo.Chaincode{
292292
Name: "mycc",

integration/pvtdata/pvtdata_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ var _ bool = Describe("PrivateData", func() {
654654
//
655655
// collection test using _lifecycle
656656
//
657-
By("enabling V2_0 capabilities on the channel")
658-
nwo.EnableV2_0Capabilities(network, "testchannel", orderer, peerAllThreeOrgs...)
657+
By("enabling V2_0 application capabilities on the channel")
658+
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, peerAllThreeOrgs...)
659659

660660
By("deploying chaincode on all peers using _lifecycle. All three orgs are members of 'collectionMarbles'")
661661
chaincode = nwo.Chaincode{

integration/sbe/sbe_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ var _ = Describe("SBE_E2E", func() {
121121

122122
By("updating the anchor peers")
123123
network.UpdateChannelAnchors(orderer, "testchannel")
124-
125-
By("enabling 2.0 capabilities")
126124
network.VerifyMembership(network.PeersWithChannel("testchannel"), "testchannel")
127-
nwo.EnableV2_0Capabilities(network, "testchannel", orderer, network.Peer("Org1", "peer0"), network.Peer("Org2", "peer0"))
125+
126+
By("enabling 2.0 application capabilities")
127+
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, network.Peer("Org1", "peer0"), network.Peer("Org2", "peer0"))
128128

129129
By("deploying the chaincode")
130130
nwo.DeployChaincodeNewLifecycle(network, "testchannel", orderer, chaincode)

0 commit comments

Comments
 (0)