From f7b3a655f8d55de6260a9daf13c975cacefc2b89 Mon Sep 17 00:00:00 2001 From: Al Cutter Date: Wed, 5 Feb 2020 11:40:10 +0000 Subject: [PATCH] Fix still flaking ratelimiter_test (#646) --- fixchain/ratelimiter/limiter_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fixchain/ratelimiter/limiter_test.go b/fixchain/ratelimiter/limiter_test.go index a7a3d5ab458..7bf70a1a1a5 100644 --- a/fixchain/ratelimiter/limiter_test.go +++ b/fixchain/ratelimiter/limiter_test.go @@ -37,9 +37,9 @@ func TestRateLimiterSingleThreaded(t *testing.T) { for i := 0; i < numOps+1; i++ { l.Wait() } - ds := float64(time.Since(start) / time.Second) + ds := float64(time.Since(start)) / float64(time.Second) qps := float64(numOps) / ds - if qps > float64(limit) { + if qps > float64(limit)*1.01 { t.Errorf("#%d: Too many operations per second. Expected ~%d, got %f", i, limit, qps) } }) @@ -66,9 +66,9 @@ func TestRateLimiterGoroutines(t *testing.T) { }() } wg.Wait() - ds := float64(time.Since(start) / time.Second) + ds := float64(time.Since(start)) / float64(time.Second) qps := float64(numOps) / ds - if qps > float64(limit) { + if qps > float64(limit)*1.01 { t.Errorf("#%d: Too many operations per second. Expected ~%d, got %f", i, limit, qps) } })