From a2a1131a8b1ffc400b87ad7f1b18f8b81559f8e2 Mon Sep 17 00:00:00 2001 From: Fabio Barone Date: Wed, 26 Sep 2018 17:23:14 -0500 Subject: [PATCH] swarm/network/stream: fixed loop logic in retrieval tests --- swarm/network/stream/snapshot_retrieval_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/swarm/network/stream/snapshot_retrieval_test.go b/swarm/network/stream/snapshot_retrieval_test.go index c6a187ec6a..82190b791b 100644 --- a/swarm/network/stream/snapshot_retrieval_test.go +++ b/swarm/network/stream/snapshot_retrieval_test.go @@ -205,6 +205,7 @@ func runFileRetrievalTest(nodeCount int) error { // or until the timeout is reached. allSuccess := false for !allSuccess { + allSuccess = true for _, id := range nodeIDs { //for each expected chunk, check if it is in the local store localSuccess := true @@ -225,11 +226,14 @@ func runFileRetrievalTest(nodeCount int) error { log.Debug(fmt.Sprintf("File with root hash %x successfully retrieved", hash)) } } - allSuccess = localSuccess + if !localSuccess { + allSuccess = false + break + } } } if !allSuccess { - return fmt.Errorf("Not all chunks succeeded!") + return fmt.Errorf("Not all retrievals succeeded!") } return nil }) @@ -301,6 +305,7 @@ func runRetrievalTest(chunkCount int, nodeCount int) error { // or until the timeout is reached. allSuccess := false for !allSuccess { + allSuccess = true for _, id := range nodeIDs { //for each expected chunk, check if it is in the local store localSuccess := true @@ -321,11 +326,14 @@ func runRetrievalTest(chunkCount int, nodeCount int) error { log.Debug(fmt.Sprintf("File with root hash %x successfully retrieved", hash)) } } - allSuccess = localSuccess + if !localSuccess { + allSuccess = false + break + } } } if !allSuccess { - return fmt.Errorf("Not all chunks succeeded!") + return fmt.Errorf("Not all retrievals succeeded!") } return nil })