diff --git a/integration/gossip/gossip_test.go b/integration/gossip/gossip_test.go index 4df9865d4a0..6f97e1261c5 100644 --- a/integration/gossip/gossip_test.go +++ b/integration/gossip/gossip_test.go @@ -125,6 +125,14 @@ var _ = Describe("Gossip State Transfer and Membership", func() { basePeerForTransactions := peer0Org1 nwo.DeployChaincodeLegacy(network, channelName, orderer, chaincode, basePeerForTransactions) + By("verifying peer0Org1 discovers all the peers and the legacy chaincode before starting the tests") + Eventually(nwo.DiscoverPeers(network, peer0Org1, "User1", "testchannel"), network.EventuallyTimeout).Should(ConsistOf( + network.DiscoveredPeer(peer0Org1, "_lifecycle", "mycc"), + network.DiscoveredPeer(peer1Org1, "_lifecycle"), + network.DiscoveredPeer(peer0Org2, "_lifecycle"), + network.DiscoveredPeer(peer1Org2, "_lifecycle"), + )) + By("STATE TRANSFER TEST 1: newly joined peers should receive blocks from the peers that are already up") // Note, a better test would be to bring orderer down before joining the two peers. @@ -142,6 +150,14 @@ var _ = Describe("Gossip State Transfer and Membership", func() { basePeerForTransactions = peer1Org1 nwo.InstallChaincodeLegacy(network, chaincode, basePeerForTransactions) + By("verifying peer0Org1 discovers all the peers and the additional legacy chaincode installed on peer1Org1") + Eventually(nwo.DiscoverPeers(network, peer0Org1, "User1", "testchannel"), network.EventuallyTimeout).Should(ConsistOf( + network.DiscoveredPeer(peer0Org1, "_lifecycle", "mycc"), + network.DiscoveredPeer(peer1Org1, "_lifecycle", "mycc"), + network.DiscoveredPeer(peer0Org2, "_lifecycle"), + network.DiscoveredPeer(peer1Org2, "_lifecycle"), + )) + By("stopping peer0Org1 (currently elected leader in Org1) and peer1Org2 (static leader in Org2)") stopPeers(nwprocs, peer0Org1, peer1Org2) @@ -152,6 +168,15 @@ var _ = Describe("Gossip State Transfer and Membership", func() { // This effectively tests leader election as well, since the newly elected leader in Org1 (peer1Org1) will be the only peer // that receives blocks from orderer and will therefore serve as the provider of blocks to all other peers. sendTransactionsAndSyncUpPeers(nwprocs, orderer, basePeerForTransactions, channelName, peer0Org1, peer1Org2) + + By("verifying peer0Org1 can still discover all the peers and the legacy chaincode after it has been restarted") + Eventually(nwo.DiscoverPeers(network, peer0Org1, "User1", "testchannel"), network.EventuallyTimeout).Should(ConsistOf( + network.DiscoveredPeer(peer0Org1, "_lifecycle", "mycc"), + network.DiscoveredPeer(peer1Org1, "_lifecycle", "mycc"), + network.DiscoveredPeer(peer0Org2, "_lifecycle"), + network.DiscoveredPeer(peer1Org2, "_lifecycle"), + )) + }) When("gossip connection is lost and restored", func() { diff --git a/internal/peer/node/start.go b/internal/peer/node/start.go index dadd51222df..7f23e09f4b0 100644 --- a/internal/peer/node/start.go +++ b/internal/peer/node/start.go @@ -366,6 +366,10 @@ func serve(args []string) error { LegacyDeployedCCInfoProvider: &lscc.DeployedCCInfoProvider{}, } + // Configure CC package storage before ccInfoFSImpl.ListInstalledChaincodes() gets called + lsccInstallPath := filepath.Join(coreconfig.GetPath("peer.fileSystemPath"), "chaincodes") + ccprovider.SetChaincodesPath(lsccInstallPath) + ccInfoFSImpl := &ccprovider.CCInfoFSImpl{GetHasher: factory.GetDefault()} // legacyMetadataManager collects metadata information from the legacy @@ -464,10 +468,6 @@ func serve(args []string) error { peerInstance.GossipService = gossipService - // Configure CC package storage - lsccInstallPath := filepath.Join(coreconfig.GetPath("peer.fileSystemPath"), "chaincodes") - ccprovider.SetChaincodesPath(lsccInstallPath) - if err := lifecycleCache.InitializeLocalChaincodes(); err != nil { return errors.WithMessage(err, "could not initialize local chaincodes") }