瀏覽代碼

eth/downloader: fix throttling test to be less timing dependent

Péter Szilágyi 10 年之前
父節點
當前提交
4b2dd44711
共有 1 個文件被更改,包括 7 次插入3 次删除
  1. 7 3
      eth/downloader/downloader_test.go

+ 7 - 3
eth/downloader/downloader_test.go

@@ -273,9 +273,13 @@ func TestThrottling(t *testing.T) {
 	}()
 	// Iteratively take some blocks, always checking the retrieval count
 	for total := 0; total < targetBlocks; {
-		// Sleep a bit for sync to complete
-		time.Sleep(500 * time.Millisecond)
-
+		// Wait a bit for sync to complete
+		for start := time.Now(); time.Since(start) < 3*time.Second; {
+			time.Sleep(25 * time.Millisecond)
+			if len(tester.downloader.queue.blockPool) == blockCacheLimit {
+				break
+			}
+		}
 		// Fetch the next batch of blocks
 		took := tester.downloader.TakeBlocks()
 		if len(took) != blockCacheLimit {