From a1ec7745c7d5abb38aaa994b0c91c316d85cb3b6 Mon Sep 17 00:00:00 2001 From: Will Lahti Date: Mon, 21 Oct 2019 12:53:35 -0400 Subject: [PATCH] lifecycle int. helper should use endorser for query The RunQueryInvokeQuery helper function for lifecycle integration tests should use one of the peers that endorsed the chaincode invocation the second time it queries the chaincode. Otherwise, a flake is possible since other peers in the channel won't necessarily have committed the transaction to their ledgers yet. Also, for future debugging purposes, update the assertions to use WithOffset to make it clear which call to the helper function resulted in a failure. FAB-16878 #done Change-Id: Ie1019c65d33fce7bfa58d9787be6d1e6dfbcbe69 Signed-off-by: Will Lahti --- integration/lifecycle/interop_test.go | 116 +++++++++--------- integration/lifecycle/lifecycle_suite_test.go | 47 ++++--- integration/lifecycle/lifecycle_test.go | 14 ++- 3 files changed, 95 insertions(+), 82 deletions(-) diff --git a/integration/lifecycle/interop_test.go b/integration/lifecycle/interop_test.go index e9f8f7954df..6994ddafd3a 100644 --- a/integration/lifecycle/interop_test.go +++ b/integration/lifecycle/interop_test.go @@ -47,8 +47,12 @@ var _ = Describe("Release interoperability", func() { }) Describe("solo network", func() { - var network *nwo.Network - var process ifrit.Process + var ( + network *nwo.Network + process ifrit.Process + orderer *nwo.Orderer + endorsers []*nwo.Peer + ) BeforeEach(func() { network = nwo.New(nwo.MultiChannelBasicSolo(), testDir, client, StartPort(), components) @@ -61,6 +65,12 @@ var _ = Describe("Release interoperability", func() { networkRunner := network.NetworkGroupRunner() process = ifrit.Invoke(networkRunner) Eventually(process.Ready(), network.EventuallyTimeout).Should(BeClosed()) + + orderer = network.Orderer("orderer") + endorsers = []*nwo.Peer{ + network.Peer("Org1", "peer0"), + network.Peer("Org2", "peer1"), + } }) AfterEach(func() { @@ -72,9 +82,6 @@ var _ = Describe("Release interoperability", func() { It("deploys and executes chaincode (simple), upgrades the channel application capabilities to V2_0 and uses _lifecycle to update the endorsement policy", func() { By("deploying the chaincode using LSCC on a channel with V1_4 application capabilities") - orderer := network.Orderer("orderer") - peer := network.Peer("Org1", "peer1") - chaincode := nwo.Chaincode{ Name: "mycc", Version: "0.0", @@ -85,28 +92,28 @@ var _ = Describe("Release interoperability", func() { network.CreateAndJoinChannels(orderer) nwo.DeployChaincodeLegacy(network, "testchannel", orderer, chaincode) - RunQueryInvokeQuery(network, orderer, peer, "mycc", 100) + RunQueryInvokeQuery(network, orderer, "mycc", 100, endorsers...) By("enabling V2_0 application capabilities") - nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, network.Peer("Org1", "peer0"), network.Peer("Org2", "peer0")) + nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, endorsers...) By("ensuring that the chaincode is still operational after the upgrade") - RunQueryInvokeQuery(network, orderer, peer, "mycc", 90) + RunQueryInvokeQuery(network, orderer, "mycc", 90, endorsers...) By("restarting the network from persistence") RestartNetwork(&process, network) By("ensuring that the chaincode is still operational after the upgrade and restart") - RunQueryInvokeQuery(network, orderer, peer, "mycc", 80) + RunQueryInvokeQuery(network, orderer, "mycc", 80, endorsers...) By("attempting to invoke the chaincode without sufficient endorsements") - sess, err := network.PeerUserSession(peer, "User1", commands.ChaincodeInvoke{ + sess, err := network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeInvoke{ ChannelID: "testchannel", Orderer: network.OrdererAddress(orderer, nwo.ListenPort), Name: "mycc", Ctor: `{"Args":["invoke","a","b","10"]}`, PeerAddresses: []string{ - network.PeerAddress(network.Peer("Org1", "peer0"), nwo.ListenPort), + network.PeerAddress(endorsers[0], nwo.ListenPort), }, WaitForEvent: true, }) @@ -129,19 +136,17 @@ var _ = Describe("Release interoperability", func() { nwo.DeployChaincode(network, "testchannel", orderer, chaincode) By("querying/invoking/querying the chaincode with the new definition") - RunQueryInvokeQueryWithAddresses(network, orderer, peer, "mycc", 70, network.PeerAddress(network.Peer("Org1", "peer1"), nwo.ListenPort)) + RunQueryInvokeQuery(network, orderer, "mycc", 70, endorsers[0]) By("restarting the network from persistence") RestartNetwork(&process, network) By("querying/invoking/querying the chaincode with the new definition again") - RunQueryInvokeQueryWithAddresses(network, orderer, peer, "mycc", 60, network.PeerAddress(network.Peer("Org1", "peer1"), nwo.ListenPort)) + RunQueryInvokeQuery(network, orderer, "mycc", 60, endorsers[1]) }) Describe("Interoperability scenarios", func() { var ( - orderer *nwo.Orderer - peer *nwo.Peer userSigner msp.SigningIdentity serialisedUserSigner []byte endorserClient pb.EndorserClient @@ -150,16 +155,14 @@ var _ = Describe("Release interoperability", func() { ) BeforeEach(func() { - orderer = network.Orderer("orderer") - peer = network.Peer("Org1", "peer1") - userSigner, serialisedUserSigner = Signer(network.PeerUserMSPDir(peer, "User1")) + userSigner, serialisedUserSigner = Signer(network.PeerUserMSPDir(endorsers[0], "User1")) endorserClient = EndorserClient( - network.PeerAddress(peer, nwo.ListenPort), - filepath.Join(network.PeerLocalTLSDir(peer), "ca.crt"), + network.PeerAddress(endorsers[0], nwo.ListenPort), + filepath.Join(network.PeerLocalTLSDir(endorsers[0]), "ca.crt"), ) deliveryClient = DeliverClient( - network.PeerAddress(peer, nwo.ListenPort), - filepath.Join(network.PeerLocalTLSDir(peer), "ca.crt"), + network.PeerAddress(endorsers[0], nwo.ListenPort), + filepath.Join(network.PeerLocalTLSDir(endorsers[0]), "ca.crt"), ) ordererClient = OrdererClient( network.OrdererAddress(orderer, nwo.ListenPort), @@ -179,7 +182,7 @@ var _ = Describe("Release interoperability", func() { network.CreateAndJoinChannels(orderer) nwo.DeployChaincodeLegacy(network, "testchannel", orderer, chaincode) - RunQueryInvokeQuery(network, orderer, peer, "mycc", 100) + RunQueryInvokeQuery(network, orderer, "mycc", 100, endorsers...) By("invoking the chaincode with the legacy definition and keeping the transaction") signedProp, prop, txid := SignedProposal( @@ -220,7 +223,7 @@ var _ = Describe("Release interoperability", func() { nwo.DeployChaincode(network, "testchannel", orderer, chaincode) By("committing the old transaction, expecting to hit an MVCC conflict") - err = CommitTx(network, env, peer, deliveryClient, ordererClient, userSigner, txid) + err = CommitTx(network, env, endorsers[0], deliveryClient, ordererClient, userSigner, txid) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("transaction invalidated with status (MVCC_READ_CONFLICT)")) }) @@ -273,7 +276,7 @@ var _ = Describe("Release interoperability", func() { nwo.DeployChaincode(network, "testchannel", orderer, chaincode) By("committing the old transaction, expecting to hit an MVCC conflict") - err = CommitTx(network, env, peer, deliveryClient, ordererClient, userSigner, txid) + err = CommitTx(network, env, endorsers[0], deliveryClient, ordererClient, userSigner, txid) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("transaction invalidated with status (MVCC_READ_CONFLICT)")) }) @@ -360,11 +363,11 @@ var _ = Describe("Release interoperability", func() { Expect(env).NotTo(BeNil()) By("committing the transaction") - err = CommitTx(network, env, peer, deliveryClient, ordererClient, userSigner, txid) + err = CommitTx(network, env, endorsers[0], deliveryClient, ordererClient, userSigner, txid) Expect(err).NotTo(HaveOccurred()) By("querying the caller chaincode") - sess, err := network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err := network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "caller", Ctor: `{"Args":["QUERY"]}`, @@ -374,7 +377,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess).To(gbytes.Say("caller:bar")) By("querying the callee chaincode") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "callee", Ctor: `{"Args":["QUERY"]}`, @@ -390,7 +393,7 @@ var _ = Describe("Release interoperability", func() { nwo.DeployChaincode(network, "testchannel2", orderer, calleeDefNew) By("invoking the chaincode on callee on channel2") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeInvoke{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeInvoke{ ChannelID: "testchannel2", Orderer: network.OrdererAddress(orderer, nwo.ListenPort), Name: "callee", @@ -402,7 +405,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess.Err).To(gbytes.Say("Chaincode invoke successful. result: status:200")) By("querying the callee chaincode on channel2") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel2", Name: "callee", Ctor: `{"Args":["QUERY"]}`, @@ -412,7 +415,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess).To(gbytes.Say("callee:bar")) By("querying (QUERYCALLEE) the callee chaincode on channel2 from caller on channel") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "caller", Ctor: `{"Args":["QUERYCALLEE", "callee", "testchannel2"]}`, @@ -422,7 +425,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess).To(gbytes.Say("callee:bar")) By("querying (QUERYCALLEE) the callee chaincode from caller on non-existing channel and expecting the invocation to fail") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "caller", Ctor: `{"Args":["QUERYCALLEE", "callee", "nonExistingChannel2"]}`, @@ -466,11 +469,11 @@ var _ = Describe("Release interoperability", func() { Expect(env).NotTo(BeNil()) By("committing the transaction") - err = CommitTx(network, env, peer, deliveryClient, ordererClient, userSigner, txid) + err = CommitTx(network, env, endorsers[0], deliveryClient, ordererClient, userSigner, txid) Expect(err).NotTo(HaveOccurred()) By("querying the caller chaincode") - sess, err := network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err := network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "caller", Ctor: `{"Args":["QUERY"]}`, @@ -480,7 +483,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess).To(gbytes.Say("caller:bar")) By("querying the callee chaincode") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "callee", Ctor: `{"Args":["QUERY"]}`, @@ -516,12 +519,12 @@ var _ = Describe("Release interoperability", func() { nwo.DeployChaincode(network, "testchannel", orderer, callerDefNew) By("committing the transaction") - err = CommitTx(network, env, peer, deliveryClient, ordererClient, userSigner, txid) + err = CommitTx(network, env, endorsers[0], deliveryClient, ordererClient, userSigner, txid) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("transaction invalidated with status (MVCC_READ_CONFLICT)")) By("querying the caller chaincode") - sess, err := network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err := network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "caller", Ctor: `{"Args":["QUERY"]}`, @@ -531,7 +534,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess).To(gbytes.Say("caller:foo")) By("querying the callee chaincode") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "callee", Ctor: `{"Args":["QUERY"]}`, @@ -567,12 +570,12 @@ var _ = Describe("Release interoperability", func() { nwo.DeployChaincode(network, "testchannel", orderer, calleeDefNew) By("committing the transaction") - err = CommitTx(network, env, peer, deliveryClient, ordererClient, userSigner, txid) + err = CommitTx(network, env, endorsers[0], deliveryClient, ordererClient, userSigner, txid) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("transaction invalidated with status (MVCC_READ_CONFLICT)")) By("querying the caller chaincode") - sess, err := network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err := network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "caller", Ctor: `{"Args":["QUERY"]}`, @@ -582,7 +585,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess).To(gbytes.Say("caller:foo")) By("querying the callee chaincode") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "callee", Ctor: `{"Args":["QUERY"]}`, @@ -629,11 +632,11 @@ var _ = Describe("Release interoperability", func() { Expect(env).NotTo(BeNil()) By("committing the transaction") - err = CommitTx(network, env, peer, deliveryClient, ordererClient, userSigner, txid) + err = CommitTx(network, env, endorsers[0], deliveryClient, ordererClient, userSigner, txid) Expect(err).NotTo(HaveOccurred()) By("querying the caller chaincode") - sess, err := network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err := network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "caller", Ctor: `{"Args":["QUERY"]}`, @@ -643,7 +646,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess).To(gbytes.Say("caller:bar")) By("querying the callee chaincode") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "callee", Ctor: `{"Args":["QUERY"]}`, @@ -677,11 +680,11 @@ var _ = Describe("Release interoperability", func() { Expect(env).NotTo(BeNil()) By("committing the transaction") - err = CommitTx(network, env, peer, deliveryClient, ordererClient, userSigner, txid) + err = CommitTx(network, env, endorsers[0], deliveryClient, ordererClient, userSigner, txid) Expect(err).NotTo(HaveOccurred()) By("querying the caller chaincode") - sess, err := network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err := network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "caller", Ctor: `{"Args":["QUERY"]}`, @@ -691,7 +694,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess).To(gbytes.Say("caller:bar")) By("querying the callee chaincode") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "callee", Ctor: `{"Args":["QUERY"]}`, @@ -725,12 +728,12 @@ var _ = Describe("Release interoperability", func() { nwo.DeployChaincode(network, "testchannel", orderer, calleeDefNew) By("committing the transaction") - err = CommitTx(network, env, peer, deliveryClient, ordererClient, userSigner, txid) + err = CommitTx(network, env, endorsers[0], deliveryClient, ordererClient, userSigner, txid) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("transaction invalidated with status (MVCC_READ_CONFLICT)")) By("querying the caller chaincode") - sess, err := network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err := network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "caller", Ctor: `{"Args":["QUERY"]}`, @@ -740,7 +743,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess).To(gbytes.Say("caller:foo")) By("querying the callee chaincode") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "callee", Ctor: `{"Args":["QUERY"]}`, @@ -774,12 +777,12 @@ var _ = Describe("Release interoperability", func() { nwo.DeployChaincode(network, "testchannel", orderer, callerDefNew) By("committing the transaction") - err = CommitTx(network, env, peer, deliveryClient, ordererClient, userSigner, txid) + err = CommitTx(network, env, endorsers[0], deliveryClient, ordererClient, userSigner, txid) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("transaction invalidated with status (MVCC_READ_CONFLICT)")) By("querying the caller chaincode") - sess, err := network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err := network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "caller", Ctor: `{"Args":["QUERY"]}`, @@ -789,7 +792,7 @@ var _ = Describe("Release interoperability", func() { Expect(sess).To(gbytes.Say("caller:foo")) By("querying the callee chaincode") - sess, err = network.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err = network.PeerUserSession(endorsers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: "callee", Ctor: `{"Args":["QUERY"]}`, @@ -837,7 +840,10 @@ var _ = Describe("Release interoperability", func() { It("deploys and executes chaincode (simple)", func() { By("deploying the chaincode using LSCC on a channel with V1_4 application capabilities") orderer := network.Orderer("orderer") - peer := network.Peer("Org1", "peer1") + endorsers := []*nwo.Peer{ + network.Peer("Org1", "peer0"), + network.Peer("Org2", "peer1"), + } cwd, err := os.Getwd() Expect(err).NotTo(HaveOccurred()) @@ -859,7 +865,7 @@ var _ = Describe("Release interoperability", func() { network.CreateAndJoinChannels(orderer) nwo.DeployChaincodeLegacy(network, "testchannel", orderer, chaincode) - RunQueryInvokeQuery(network, orderer, peer, "mycc", 100) + RunQueryInvokeQuery(network, orderer, "mycc", 100, endorsers...) }) }) }) diff --git a/integration/lifecycle/lifecycle_suite_test.go b/integration/lifecycle/lifecycle_suite_test.go index 26740ba61cc..3c90a72809b 100644 --- a/integration/lifecycle/lifecycle_suite_test.go +++ b/integration/lifecycle/lifecycle_suite_test.go @@ -69,30 +69,28 @@ func StartPort() int { return integration.LifecyclePort.StartPortForNode() } -func RunQueryInvokeQuery(n *nwo.Network, orderer *nwo.Orderer, peer *nwo.Peer, chaincodeName string, initialQueryResult int) { - RunQueryInvokeQueryWithAddresses( - n, - orderer, - peer, - chaincodeName, - initialQueryResult, - n.PeerAddress(n.Peer("Org1", "peer0"), nwo.ListenPort), - n.PeerAddress(n.Peer("Org2", "peer1"), nwo.ListenPort), - ) -} +func RunQueryInvokeQuery(n *nwo.Network, orderer *nwo.Orderer, chaincodeName string, initialQueryResult int, peers ...*nwo.Peer) { + if len(peers) == 0 { + peers = n.PeersWithChannel("testchannel") + } + + addresses := make([]string, len(peers)) + for i, peer := range peers { + addresses[i] = n.PeerAddress(peer, nwo.ListenPort) + } -func RunQueryInvokeQueryWithAddresses(n *nwo.Network, orderer *nwo.Orderer, peer *nwo.Peer, chaincodeName string, initialQueryResult int, addresses ...string) { By("querying the chaincode") - sess, err := n.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + sess, err := n.PeerUserSession(peers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: chaincodeName, Ctor: `{"Args":["query","a"]}`, }) - Expect(err).NotTo(HaveOccurred()) - Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0)) - Expect(sess).To(gbytes.Say(fmt.Sprint(initialQueryResult))) + ExpectWithOffset(1, err).NotTo(HaveOccurred()) + EventuallyWithOffset(1, sess, n.EventuallyTimeout).Should(gexec.Exit(0)) + ExpectWithOffset(1, sess).To(gbytes.Say(fmt.Sprint(initialQueryResult))) - sess, err = n.PeerUserSession(peer, "User1", commands.ChaincodeInvoke{ + By("invoking the chaincode") + sess, err = n.PeerUserSession(peers[0], "User1", commands.ChaincodeInvoke{ ChannelID: "testchannel", Orderer: n.OrdererAddress(orderer, nwo.ListenPort), Name: chaincodeName, @@ -100,18 +98,19 @@ func RunQueryInvokeQueryWithAddresses(n *nwo.Network, orderer *nwo.Orderer, peer PeerAddresses: addresses, WaitForEvent: true, }) - Expect(err).NotTo(HaveOccurred()) - Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0)) - Expect(sess.Err).To(gbytes.Say("Chaincode invoke successful. result: status:200")) + ExpectWithOffset(1, err).NotTo(HaveOccurred()) + EventuallyWithOffset(1, sess, n.EventuallyTimeout).Should(gexec.Exit(0)) + ExpectWithOffset(1, sess.Err).To(gbytes.Say("Chaincode invoke successful. result: status:200")) - sess, err = n.PeerUserSession(peer, "User1", commands.ChaincodeQuery{ + By("querying the chaincode") + sess, err = n.PeerUserSession(peers[0], "User1", commands.ChaincodeQuery{ ChannelID: "testchannel", Name: chaincodeName, Ctor: `{"Args":["query","a"]}`, }) - Expect(err).NotTo(HaveOccurred()) - Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0)) - Expect(sess).To(gbytes.Say(fmt.Sprint(initialQueryResult - 10))) + ExpectWithOffset(1, err).NotTo(HaveOccurred()) + EventuallyWithOffset(1, sess, n.EventuallyTimeout).Should(gexec.Exit(0)) + ExpectWithOffset(1, sess).To(gbytes.Say(fmt.Sprint(initialQueryResult - 10))) } func RestartNetwork(process *ifrit.Process, network *nwo.Network) { diff --git a/integration/lifecycle/lifecycle_test.go b/integration/lifecycle/lifecycle_test.go index 53e13571e68..52ef6424027 100644 --- a/integration/lifecycle/lifecycle_test.go +++ b/integration/lifecycle/lifecycle_test.go @@ -146,7 +146,11 @@ var _ = Describe("Lifecycle", func() { nwo.InitChaincode(network, "testchannel", orderer, chaincode, testPeers...) By("ensuring the chaincode can be invoked and queried") - RunQueryInvokeQuery(network, orderer, org1peer1, "My_1st-Chaincode", 100) + endorsers := []*nwo.Peer{ + network.Peer("Org1", "peer0"), + network.Peer("Org2", "peer1"), + } + RunQueryInvokeQuery(network, orderer, "My_1st-Chaincode", 100, endorsers...) By("setting a bad package ID to temporarily disable endorsements on org1") savedPackageID := chaincode.PackageID @@ -191,7 +195,7 @@ var _ = Describe("Lifecycle", func() { nwo.CommitChaincode(network, "testchannel", orderer, chaincode, testPeers[0], testPeers...) By("ensuring the chaincode can still be invoked and queried") - RunQueryInvokeQuery(network, orderer, testPeers[0], "My_1st-Chaincode", 90) + RunQueryInvokeQuery(network, orderer, "My_1st-Chaincode", 90, endorsers...) By("deploying another chaincode using the same chaincode package") nwo.DeployChaincode(network, "testchannel", orderer, nwo.Chaincode{ @@ -309,7 +313,11 @@ var _ = Describe("Lifecycle", func() { nwo.EnsureChaincodeCommitted(network, "testchannel", chaincode.Name, chaincode.Version, chaincode.Sequence, []*nwo.Organization{network.Organization("Org1"), network.Organization("Org2"), network.Organization("Org3")}, org3peer0) By("ensuring chaincode can be invoked and queried by org3") - RunQueryInvokeQueryWithAddresses(network, orderer, org3peer0, "My_1st-Chaincode", 80, org3AndOrg1PeerAddresses...) + org3andOrg1Endorsers := []*nwo.Peer{ + network.Peer("Org3", "peer0"), + network.Peer("Org1", "peer1"), + } + RunQueryInvokeQuery(network, orderer, "My_1st-Chaincode", 80, org3andOrg1Endorsers...) By("deploying a chaincode without an endorsement policy specified") chaincode = nwo.Chaincode{