Sfoglia il codice sorgente

Merge pull request #1390 from karalabe/fix-downloader-test-race

eth/downloader: fix a rare test race on the OSX CI
Jeffrey Wilcke 10 anni fa
parent
commit
03129e7c93
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      eth/downloader/downloader_test.go

+ 7 - 1
eth/downloader/downloader_test.go

@@ -83,7 +83,13 @@ func newTester() *downloadTester {
 // sync starts synchronizing with a remote peer, blocking until it completes.
 func (dl *downloadTester) sync(id string) error {
 	err := dl.downloader.synchronise(id, dl.peerHashes[id][0])
-	for atomic.LoadInt32(&dl.downloader.processing) == 1 {
+	for {
+		// If the queue is empty and processing stopped, break
+		hashes, blocks := dl.downloader.queue.Size()
+		if hashes+blocks == 0 && atomic.LoadInt32(&dl.downloader.processing) == 0 {
+			break
+		}
+		// Otherwise sleep a bit and retry
 		time.Sleep(time.Millisecond)
 	}
 	return err