swarm/network/stream: fixed loop logic in retrieval tests

This commit is contained in:
Fabio Barone 2018-09-26 17:23:14 -05:00
parent 1b733c9553
commit a2a1131a8b

View file

@ -205,6 +205,7 @@ func runFileRetrievalTest(nodeCount int) error {
// or until the timeout is reached. // or until the timeout is reached.
allSuccess := false allSuccess := false
for !allSuccess { for !allSuccess {
allSuccess = true
for _, id := range nodeIDs { for _, id := range nodeIDs {
//for each expected chunk, check if it is in the local store //for each expected chunk, check if it is in the local store
localSuccess := true localSuccess := true
@ -225,11 +226,14 @@ func runFileRetrievalTest(nodeCount int) error {
log.Debug(fmt.Sprintf("File with root hash %x successfully retrieved", hash)) log.Debug(fmt.Sprintf("File with root hash %x successfully retrieved", hash))
} }
} }
allSuccess = localSuccess if !localSuccess {
allSuccess = false
break
}
} }
} }
if !allSuccess { if !allSuccess {
return fmt.Errorf("Not all chunks succeeded!") return fmt.Errorf("Not all retrievals succeeded!")
} }
return nil return nil
}) })
@ -301,6 +305,7 @@ func runRetrievalTest(chunkCount int, nodeCount int) error {
// or until the timeout is reached. // or until the timeout is reached.
allSuccess := false allSuccess := false
for !allSuccess { for !allSuccess {
allSuccess = true
for _, id := range nodeIDs { for _, id := range nodeIDs {
//for each expected chunk, check if it is in the local store //for each expected chunk, check if it is in the local store
localSuccess := true 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)) log.Debug(fmt.Sprintf("File with root hash %x successfully retrieved", hash))
} }
} }
allSuccess = localSuccess if !localSuccess {
allSuccess = false
break
}
} }
} }
if !allSuccess { if !allSuccess {
return fmt.Errorf("Not all chunks succeeded!") return fmt.Errorf("Not all retrievals succeeded!")
} }
return nil return nil
}) })