From f857fb7600f586ad9bfd037091420f77137c973f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 3 Jul 2015 12:53:11 +0300 Subject: [PATCH] eth/downloader: fix a rare test race on the OSX CI --- eth/downloader/downloader_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index c5fb00289..23549a9ba 100644 --- a/eth/downloader/downloader_test.go +++ b/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