Skip to content

Commit 4c1840f

Browse files
authored
fix basic checks (#5490)
Signed-off-by: Fedor Partanskiy <fredprtnsk@gmail.com>
1 parent 9c01421 commit 4c1840f

1 file changed

Lines changed: 121 additions & 120 deletions

File tree

integration/e2e/e2e_test.go

Lines changed: 121 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -230,138 +230,139 @@ var _ = Describe("EndToEnd", func() {
230230
})
231231
})
232232

233-
DescribeTableSubtree("basic etcdraft network with docker chaincode builds", func(ccenvVersion string) {
234-
BeforeEach(func() {
235-
network = nwo.New(nwo.BasicEtcdRaft(), testDir, client, StartPort(), components)
236-
network.CCEnvVersion = ccenvVersion
237-
network.MetricsProvider = "prometheus"
238-
network.GenerateConfigTree()
239-
network.Bootstrap()
240-
241-
// Start all the fabric processes
242-
ordererRunner, ordererProcess, peerProcess = network.StartSingleOrdererNetwork("orderer")
243-
})
244-
245-
It("builds and executes transactions with docker chaincode", func() {
246-
chaincodePath, err := filepath.Abs("../chaincode/module")
247-
Expect(err).NotTo(HaveOccurred())
248-
249-
// use these two variants of the same chaincode to ensure we test
250-
// the golang docker build for both module and gopath chaincode
251-
chaincode := nwo.Chaincode{
252-
Name: "mycc",
253-
Version: "0.0",
254-
Path: chaincodePath,
255-
Lang: "golang",
256-
PackageFile: filepath.Join(testDir, "modulecc.tar.gz"),
257-
Ctor: `{"Args":["init","a","100","b","200"]}`,
258-
SignaturePolicy: `AND ('Org1MSP.member','Org2MSP.member')`,
259-
Sequence: "1",
260-
InitRequired: true,
261-
Label: "my_module_chaincode",
262-
}
263-
264-
gopathChaincode := nwo.Chaincode{
265-
Name: "mycc",
266-
Version: "0.0",
267-
Path: "github.com/hyperledger/fabric/integration/chaincode/simple/cmd",
268-
Lang: "golang",
269-
PackageFile: filepath.Join(testDir, "simplecc.tar.gz"),
270-
Ctor: `{"Args":["init","a","100","b","200"]}`,
271-
SignaturePolicy: `AND ('Org1MSP.member','Org2MSP.member')`,
272-
Sequence: "1",
273-
InitRequired: true,
274-
Label: "my_simple_chaincode",
275-
}
276-
277-
orderer := network.Orderer("orderer")
278-
279-
By("setting up the channel")
280-
nwo.JoinOrdererJoinPeersAppChannel(network, "testchannel", orderer, ordererRunner)
281-
282-
cl := nwo.List(network, orderer)
283-
nwo.ChannelListMatcher(cl, []string{"testchannel"})
284-
285-
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_5", orderer, network.Peer("Org1", "peer0"), network.Peer("Org2", "peer0"))
286-
287-
// package, install, and approve by org1 - module chaincode
288-
packageInstallApproveChaincode(network, "testchannel", orderer, chaincode, network.Peer("Org1", "peer0"))
289-
290-
// package, install, and approve by org2 - gopath chaincode, same logic
291-
packageInstallApproveChaincode(network, "testchannel", orderer, gopathChaincode, network.Peer("Org2", "peer0"))
233+
DescribeTableSubtree(
234+
"basic etcdraft network with docker chaincode builds", func(ccenvVersion string) {
235+
BeforeEach(func() {
236+
network = nwo.New(nwo.BasicEtcdRaft(), testDir, client, StartPort(), components)
237+
network.CCEnvVersion = ccenvVersion
238+
network.MetricsProvider = "prometheus"
239+
network.GenerateConfigTree()
240+
network.Bootstrap()
241+
242+
// Start all the fabric processes
243+
ordererRunner, ordererProcess, peerProcess = network.StartSingleOrdererNetwork("orderer")
244+
})
292245

293-
testPeers := network.PeersWithChannel("testchannel")
294-
nwo.CheckCommitReadinessUntilReady(network, "testchannel", chaincode, network.PeerOrgs(), testPeers...)
295-
nwo.CommitChaincode(network, "testchannel", orderer, chaincode, testPeers[0], testPeers...)
296-
nwo.InitChaincode(network, "testchannel", orderer, chaincode, testPeers...)
246+
It("builds and executes transactions with docker chaincode", func() {
247+
chaincodePath, err := filepath.Abs("../chaincode/module")
248+
Expect(err).NotTo(HaveOccurred())
297249

298-
By("listing the containers after committing the chaincode definition")
299-
initialContainerFilter := make(dcli.Filters).Add(
300-
"name",
301-
chaincodeContainerNameFilter(network, chaincode),
302-
chaincodeContainerNameFilter(network, gopathChaincode),
303-
)
304-
containers, err := client.ContainerList(context.Background(), dcli.ContainerListOptions{
305-
Filters: initialContainerFilter,
306-
})
307-
Expect(err).NotTo(HaveOccurred())
308-
Expect(containers.Items).To(HaveLen(2))
250+
// use these two variants of the same chaincode to ensure we test
251+
// the golang docker build for both module and gopath chaincode
252+
chaincode := nwo.Chaincode{
253+
Name: "mycc",
254+
Version: "0.0",
255+
Path: chaincodePath,
256+
Lang: "golang",
257+
PackageFile: filepath.Join(testDir, "modulecc.tar.gz"),
258+
Ctor: `{"Args":["init","a","100","b","200"]}`,
259+
SignaturePolicy: `AND ('Org1MSP.member','Org2MSP.member')`,
260+
Sequence: "1",
261+
InitRequired: true,
262+
Label: "my_module_chaincode",
263+
}
264+
265+
gopathChaincode := nwo.Chaincode{
266+
Name: "mycc",
267+
Version: "0.0",
268+
Path: "github.com/hyperledger/fabric/integration/chaincode/simple/cmd",
269+
Lang: "golang",
270+
PackageFile: filepath.Join(testDir, "simplecc.tar.gz"),
271+
Ctor: `{"Args":["init","a","100","b","200"]}`,
272+
SignaturePolicy: `AND ('Org1MSP.member','Org2MSP.member')`,
273+
Sequence: "1",
274+
InitRequired: true,
275+
Label: "my_simple_chaincode",
276+
}
277+
278+
orderer := network.Orderer("orderer")
279+
280+
By("setting up the channel")
281+
nwo.JoinOrdererJoinPeersAppChannel(network, "testchannel", orderer, ordererRunner)
282+
283+
cl := nwo.List(network, orderer)
284+
nwo.ChannelListMatcher(cl, []string{"testchannel"})
285+
286+
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_5", orderer, network.Peer("Org1", "peer0"), network.Peer("Org2", "peer0"))
287+
288+
// package, install, and approve by org1 - module chaincode
289+
packageInstallApproveChaincode(network, "testchannel", orderer, chaincode, network.Peer("Org1", "peer0"))
290+
291+
// package, install, and approve by org2 - gopath chaincode, same logic
292+
packageInstallApproveChaincode(network, "testchannel", orderer, gopathChaincode, network.Peer("Org2", "peer0"))
293+
294+
testPeers := network.PeersWithChannel("testchannel")
295+
nwo.CheckCommitReadinessUntilReady(network, "testchannel", chaincode, network.PeerOrgs(), testPeers...)
296+
nwo.CommitChaincode(network, "testchannel", orderer, chaincode, testPeers[0], testPeers...)
297+
nwo.InitChaincode(network, "testchannel", orderer, chaincode, testPeers...)
298+
299+
By("listing the containers after committing the chaincode definition")
300+
initialContainerFilter := make(dcli.Filters).Add(
301+
"name",
302+
chaincodeContainerNameFilter(network, chaincode),
303+
chaincodeContainerNameFilter(network, gopathChaincode),
304+
)
305+
containers, err := client.ContainerList(context.Background(), dcli.ContainerListOptions{
306+
Filters: initialContainerFilter,
307+
})
308+
Expect(err).NotTo(HaveOccurred())
309+
Expect(containers.Items).To(HaveLen(2))
309310

310-
RunQueryInvokeQuery(network, orderer, network.Peer("Org1", "peer0"), "testchannel")
311+
RunQueryInvokeQuery(network, orderer, network.Peer("Org1", "peer0"), "testchannel")
311312

312-
By("evaluating the operations endpoint and prometheus metrics")
313-
CheckPeerOperationEndpoints(network, network.Peer("Org2", "peer0"))
314-
CheckOrdererOperationEndpoints(network, orderer)
313+
By("evaluating the operations endpoint and prometheus metrics")
314+
CheckPeerOperationEndpoints(network, network.Peer("Org2", "peer0"))
315+
CheckOrdererOperationEndpoints(network, orderer)
315316

316-
// upgrade chaincode to v2.0 with different label
317-
chaincode.Version = "1.0"
318-
chaincode.Sequence = "2"
319-
chaincode.Label = "my_module_chaincode_updated"
320-
gopathChaincode.Version = "1.0"
321-
gopathChaincode.Sequence = "2"
322-
gopathChaincode.Label = "my_simple_chaincode_updated"
317+
// upgrade chaincode to v2.0 with different label
318+
chaincode.Version = "1.0"
319+
chaincode.Sequence = "2"
320+
chaincode.Label = "my_module_chaincode_updated"
321+
gopathChaincode.Version = "1.0"
322+
gopathChaincode.Sequence = "2"
323+
gopathChaincode.Label = "my_simple_chaincode_updated"
323324

324-
// package, install, and approve by org1 - module chaincode
325-
packageInstallApproveChaincode(network, "testchannel", orderer, chaincode, network.Peer("Org1", "peer0"))
325+
// package, install, and approve by org1 - module chaincode
326+
packageInstallApproveChaincode(network, "testchannel", orderer, chaincode, network.Peer("Org1", "peer0"))
326327

327-
// package, install, and approve by org2 - gopath chaincode, same logic
328-
packageInstallApproveChaincode(network, "testchannel", orderer, gopathChaincode, network.Peer("Org2", "peer0"))
328+
// package, install, and approve by org2 - gopath chaincode, same logic
329+
packageInstallApproveChaincode(network, "testchannel", orderer, gopathChaincode, network.Peer("Org2", "peer0"))
329330

330-
nwo.CheckCommitReadinessUntilReady(network, "testchannel", chaincode, network.PeerOrgs(), testPeers...)
331-
nwo.CommitChaincode(network, "testchannel", orderer, chaincode, testPeers[0], testPeers...)
332-
nwo.InitChaincode(network, "testchannel", orderer, chaincode, testPeers...)
331+
nwo.CheckCommitReadinessUntilReady(network, "testchannel", chaincode, network.PeerOrgs(), testPeers...)
332+
nwo.CommitChaincode(network, "testchannel", orderer, chaincode, testPeers[0], testPeers...)
333+
nwo.InitChaincode(network, "testchannel", orderer, chaincode, testPeers...)
333334

334-
By("listing the containers after updating the chaincode definition")
335-
// expect the containers for the previous package id to be stopped
336-
containers, err = client.ContainerList(context.Background(), dcli.ContainerListOptions{
337-
Filters: initialContainerFilter,
338-
})
339-
Expect(err).NotTo(HaveOccurred())
340-
Expect(containers.Items).To(HaveLen(0))
341-
updatedContainerFilter := make(dcli.Filters).Add(
342-
"name",
343-
chaincodeContainerNameFilter(network, chaincode),
344-
chaincodeContainerNameFilter(network, gopathChaincode),
345-
)
346-
containers, err = client.ContainerList(context.Background(), dcli.ContainerListOptions{
347-
Filters: updatedContainerFilter,
348-
})
349-
Expect(err).NotTo(HaveOccurred())
350-
Expect(containers.Items).To(HaveLen(2))
335+
By("listing the containers after updating the chaincode definition")
336+
// expect the containers for the previous package id to be stopped
337+
containers, err = client.ContainerList(context.Background(), dcli.ContainerListOptions{
338+
Filters: initialContainerFilter,
339+
})
340+
Expect(err).NotTo(HaveOccurred())
341+
Expect(containers.Items).To(HaveLen(0))
342+
updatedContainerFilter := make(dcli.Filters).Add(
343+
"name",
344+
chaincodeContainerNameFilter(network, chaincode),
345+
chaincodeContainerNameFilter(network, gopathChaincode),
346+
)
347+
containers, err = client.ContainerList(context.Background(), dcli.ContainerListOptions{
348+
Filters: updatedContainerFilter,
349+
})
350+
Expect(err).NotTo(HaveOccurred())
351+
Expect(containers.Items).To(HaveLen(2))
351352

352-
RunQueryInvokeQuery(network, orderer, network.Peer("Org1", "peer0"), "testchannel")
353+
RunQueryInvokeQuery(network, orderer, network.Peer("Org1", "peer0"), "testchannel")
353354

354-
By("retrieving the local mspid of the peer via simple chaincode")
355-
sess, err := network.PeerUserSession(network.Peer("Org2", "peer0"), "User1", commands.ChaincodeQuery{
356-
ChannelID: "testchannel",
357-
Name: "mycc",
358-
Ctor: `{"Args":["mspid"]}`,
355+
By("retrieving the local mspid of the peer via simple chaincode")
356+
sess, err := network.PeerUserSession(network.Peer("Org2", "peer0"), "User1", commands.ChaincodeQuery{
357+
ChannelID: "testchannel",
358+
Name: "mycc",
359+
Ctor: `{"Args":["mspid"]}`,
360+
})
361+
Expect(err).NotTo(HaveOccurred())
362+
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(0))
363+
Expect(sess).To(gbytes.Say("Org2MSP"))
359364
})
360-
Expect(err).NotTo(HaveOccurred())
361-
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(0))
362-
Expect(sess).To(gbytes.Say("Org2MSP"))
363-
})
364-
},
365+
},
365366
Entry("current ccenv", "$(PROJECT_VERSION)"),
366367
Entry("old ccenv 3.1.3 with go 1.25.2", "3.1.3"),
367368
)

0 commit comments

Comments
 (0)