Skip to content

Commit

Permalink
Fix still flaking ratelimiter_test (google#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter authored and zorawar87 committed Mar 1, 2020
1 parent 18a3d8b commit 4faf9cf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fixchain/ratelimiter/limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
Expand All @@ -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)
}
})
Expand Down

0 comments on commit 4faf9cf

Please sign in to comment.