From 88f19f948cb32d1293930d6dd27f74025b45ac0d Mon Sep 17 00:00:00 2001 From: Matthew Sykes Date: Fri, 22 May 2020 12:45:27 -0400 Subject: [PATCH] Add error checks to integration/{raft,sbe} Signed-off-by: Matthew Sykes --- integration/raft/cft_test.go | 5 +++-- integration/raft/config_test.go | 12 ++++++++---- integration/sbe/sbe_test.go | 7 +++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/integration/raft/cft_test.go b/integration/raft/cft_test.go index 6da92609385..3fb7111d1d4 100644 --- a/integration/raft/cft_test.go +++ b/integration/raft/cft_test.go @@ -535,7 +535,7 @@ var _ = Describe("EndToEnd Crash Fault Tolerance", func() { Expect(denv).NotTo(BeNil()) block, err := nwo.Deliver(network, orderer, denv) - Expect(denv).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(block).To(BeNil()) Eventually(runner.Err(), time.Minute, time.Second).Should(gbytes.Say("client identity expired")) @@ -581,7 +581,8 @@ func findLeader(ordererRunners []*ginkgomon.Runner) int { Eventually(runner.Err(), time.Minute, time.Second).Should(gbytes.Say("Raft leader changed: [0-9] -> ")) idBuff := make([]byte, 1) - runner.Err().Read(idBuff) + _, err := runner.Err().Read(idBuff) + Expect(err).NotTo(HaveOccurred()) newLeader, err := strconv.ParseInt(string(idBuff), 10, 32) Expect(err).To(BeNil()) diff --git a/integration/raft/config_test.go b/integration/raft/config_test.go index 2645186a01d..dd7dc7ef641 100644 --- a/integration/raft/config_test.go +++ b/integration/raft/config_test.go @@ -152,7 +152,8 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() { genesisBlock := pgen.GenesisBlockForChannel(network.SystemChannel.Name) data, err := proto.Marshal(genesisBlock) Expect(err).NotTo(HaveOccurred()) - ioutil.WriteFile(network.OutputBlockPath(network.SystemChannel.Name), data, 0644) + err = ioutil.WriteFile(network.OutputBlockPath(network.SystemChannel.Name), data, 0644) + Expect(err).NotTo(HaveOccurred()) By("Starting orderer with malformed genesis block") ordererRunner := network.OrdererGroupRunner() @@ -194,7 +195,8 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() { Expect(err).NotTo(HaveOccurred()) data, err = proto.Marshal(configtx) Expect(err).NotTo(HaveOccurred()) - ioutil.WriteFile(network.CreateChannelTxPath(channel), data, 0644) + err = ioutil.WriteFile(network.CreateChannelTxPath(channel), data, 0644) + Expect(err).NotTo(HaveOccurred()) By("Submitting malformed channel creation config tx to orderer") org1Peer0 := network.Peer("Org1", "peer0") @@ -1412,10 +1414,12 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() { ordererOrg := updatedConfig.ChannelGroup.Groups["Orderer"].Groups["OrdererOrg"] mspConfig := &msp.MSPConfig{} - proto.Unmarshal(ordererOrg.Values["MSP"].Value, mspConfig) + err := proto.Unmarshal(ordererOrg.Values["MSP"].Value, mspConfig) + Expect(err).NotTo(HaveOccurred()) fabMSPConfig := &msp.FabricMSPConfig{} - proto.Unmarshal(mspConfig.Config, fabMSPConfig) + err = proto.Unmarshal(mspConfig.Config, fabMSPConfig) + Expect(err).NotTo(HaveOccurred()) fabMSPConfig.Name = "OrdererMSP2" diff --git a/integration/sbe/sbe_test.go b/integration/sbe/sbe_test.go index 40c97aeb4f8..56130154784 100644 --- a/integration/sbe/sbe_test.go +++ b/integration/sbe/sbe_test.go @@ -51,7 +51,8 @@ var _ = Describe("SBE_E2E", func() { CollectionsConfig: "testdata/collection_config.json", } - tempDir, err = ioutil.TempDir("", "nwo") + tempDir, err = ioutil.TempDir("", "sbe") + Expect(err).NotTo(HaveOccurred()) }) AfterEach(func() { @@ -62,6 +63,7 @@ var _ = Describe("SBE_E2E", func() { if network != nil { network.Cleanup() } + os.RemoveAll(tempDir) os.RemoveAll(testDir) }) @@ -443,7 +445,8 @@ func getLedgerHeight(n *nwo.Network, peer *nwo.Peer, channelName string) int { channelInfoStr := strings.TrimPrefix(string(sess.Buffer().Contents()[:]), "Blockchain info:") var channelInfo = common.BlockchainInfo{} - json.Unmarshal([]byte(channelInfoStr), &channelInfo) + err = json.Unmarshal([]byte(channelInfoStr), &channelInfo) + Expect(err).NotTo(HaveOccurred()) return int(channelInfo.Height) }