From 37472011352a12f3424a55fc13e1a897962401f2 Mon Sep 17 00:00:00 2001 From: Artem Barger Date: Sun, 22 Oct 2023 16:34:13 +0300 Subject: [PATCH] Removing nwo.DeployChaincodeLegacy() This commit removes the DeployChaincodeLegacy function from the integration tests suite to address #3983 as part of eliminating the legacy chaincode lifecycle. Due to the changes in size, the work will be split into several PRs. This is the first one in a row. Signed-off-by: Artem Barger --- integration/devmode/devmode_test.go | 49 ---- integration/discovery/discovery_test.go | 318 +++--------------------- integration/e2e/acl_test.go | 244 +++++++----------- integration/gossip/gossip_test.go | 53 ++-- 4 files changed, 160 insertions(+), 504 deletions(-) diff --git a/integration/devmode/devmode_test.go b/integration/devmode/devmode_test.go index ac860c901ab..8d82c944a6d 100644 --- a/integration/devmode/devmode_test.go +++ b/integration/devmode/devmode_test.go @@ -34,7 +34,6 @@ var _ = Describe("Devmode", func() { ordererRunner *ginkgomon.Runner ordererProcess, peerProcess ifrit.Process chaincode nwo.Chaincode - legacyChaincode nwo.Chaincode chaincodeRunner *ginkgomon.Runner chaincodeProcess ifrit.Process channelName string @@ -83,54 +82,6 @@ var _ = Describe("Devmode", func() { os.RemoveAll(testDir) }) - It("executes chaincode in dev mode using legacy lifecycle", func() { - legacyChaincode = nwo.Chaincode{ - Name: "mycc", - Version: "0.0", - Path: "github.com/hyperledger/fabric/integration/chaincode/simple/cmd", - Ctor: `{"Args":["init","a","100","b","200"]}`, - Policy: `OR ('Org1MSP.member')`, - } - - org1peer0 := network.Peer("Org1", "peer0") - orderer := network.Orderer("orderer") - - By("setting up the channel") - channelparticipation.JoinOrdererJoinPeersAppChannel(network, "testchannel", orderer, ordererRunner) - - By("building chaincode") - chaincodeExecutePath := components.Build(legacyChaincode.Path) - - By("running the chaincode") - legacyChaincodeID := legacyChaincode.Name + ":" + legacyChaincode.Version - peerChaincodeAddress := network.PeerAddress(org1peer0, nwo.ChaincodePort) - envs := []string{ - "CORE_PEER_TLS_ENABLED=false", - "CORE_CHAINCODE_ID_NAME=" + legacyChaincodeID, - "DEVMODE_ENABLED=true", - } - cmd := exec.Command(chaincodeExecutePath, "-peer.address", peerChaincodeAddress) - cmd.Env = append(cmd.Env, envs...) - chaincodeRunner = ginkgomon.New(ginkgomon.Config{ - Name: "chaincode", - Command: cmd, - StartCheckTimeout: 15 * time.Second, - StartCheck: "starting up in devmode...", - }) - chaincodeProcess = ifrit.Invoke(chaincodeRunner) - Eventually(chaincodeProcess.Ready(), network.EventuallyTimeout).Should(BeClosed()) - - By("installing the chaincode") - nwo.InstallChaincodeLegacy(network, legacyChaincode, org1peer0) - - By("instantiating the chaincode") - nwo.InstantiateChaincodeLegacy(network, channelName, orderer, legacyChaincode, org1peer0, org1peer0) - - By("querying and invoking the chaincode") - RunQueryInvokeQuery(network, orderer, org1peer0, channelName, 100) - Eventually(chaincodeRunner).Should(gbytes.Say("invoking in devmode")) - }) - It("executes chaincode in dev mode", func() { chaincode = nwo.Chaincode{ Name: "mycc", diff --git a/integration/discovery/discovery_test.go b/integration/discovery/discovery_test.go index e51319cd8e2..d64ade5e74e 100644 --- a/integration/discovery/discovery_test.go +++ b/integration/discovery/discovery_test.go @@ -106,14 +106,23 @@ var _ = Describe("DiscoveryService", func() { }) It("discovers network configuration even without anchor peers present", func() { chaincodeWhenNoAnchorPeers := nwo.Chaincode{ - Name: "noanchorpeersjustyet", - Version: "1.0", - Path: "github.com/hyperledger/fabric/integration/chaincode/simple/cmd", - Ctor: `{"Args":["init","a","100","b","200"]}`, - Policy: `OR ('Org1MSP.member')`, + Name: "mycc", + Version: "0.0", + Path: components.Build("github.com/hyperledger/fabric/integration/chaincode/simple/cmd"), + Lang: "binary", + PackageFile: filepath.Join(testDir, "simplecc.tar.gz"), + Ctor: `{"Args":["init","a","100","b","200"]}`, + SignaturePolicy: `OR ('Org1MSP.member')`, + Sequence: "1", + InitRequired: true, + Label: "my_prebuilt_chaincode", } + + By("enabling capabilities V2_5") + nwo.EnableCapabilities(network, "testchannel", "Application", "V2_5", orderer, org1Peer0, org2Peer0) + By("Deploying chaincode before anchor peers are defined in the channel") - nwo.DeployChaincodeLegacy(network, "testchannel", orderer, chaincodeWhenNoAnchorPeers, org1Peer0) + nwo.DeployChaincode(network, "testchannel", orderer, chaincodeWhenNoAnchorPeers, org1Peer0, org2Peer0) endorsersForChaincodeBeforeAnchorPeersExist := commands.Endorsers{ UserCert: network.PeerUserCert(org1Peer0, "User1"), @@ -294,6 +303,9 @@ var _ = Describe("DiscoveryService", func() { // discovering peers and endorsers // + By("enabling V2_0 application capabilities on the channel") + nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, org1Peer0, org2Peer0, org3Peer0) + By("discovering peers before deploying any user chaincodes") Eventually(nwo.DiscoverPeers(network, org1Peer0, "User1", "testchannel"), network.EventuallyTimeout).Should(ConsistOf( network.DiscoveredPeer(org1Peer0, "_lifecycle"), @@ -301,212 +313,8 @@ var _ = Describe("DiscoveryService", func() { network.DiscoveredPeer(org3Peer0, "_lifecycle"), )) - By("discovering endorsers when missing chaincode") - endorsers := commands.Endorsers{ - UserCert: network.PeerUserCert(org1Peer0, "User1"), - UserKey: network.PeerUserKey(org1Peer0, "User1"), - MSPID: network.Organization(org1Peer0.Organization).MSPID, - Server: network.PeerAddress(org1Peer0, nwo.ListenPort), - Channel: "testchannel", - Chaincode: "mycc", - } - sess, err := network.Discover(endorsers) - Expect(err).NotTo(HaveOccurred()) - Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(1)) - Expect(sess.Err).To(gbytes.Say(`failed constructing descriptor for chaincodes: ")) } // assertPeerMembershipUpdate stops and restart peersToRestart and verify peer membership