Skip to content

Commit

Permalink
Capture variables in tests and add logging. (#942)
Browse files Browse the repository at this point in the history
  • Loading branch information
phbnf authored May 31, 2022
1 parent 5deb61e commit 3362d9e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fixchain/ratelimiter/limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var testlimits = []int{1, 10, 50, 100, 1000}
func TestRateLimiterSingleThreaded(t *testing.T) {
for i, limit := range testlimits {
t.Run(fmt.Sprintf("%d ops/s", limit), func(t *testing.T) {
i, limit := i, limit
t.Parallel()
l := NewLimiter(limit)

Expand All @@ -42,13 +43,15 @@ func TestRateLimiterSingleThreaded(t *testing.T) {
if qps > float64(limit)*1.01 {
t.Errorf("#%d: Too many operations per second. Expected ~%d, got %f", i, limit, qps)
}
log.Infof("#%d: Expected ~%d, got %f", i, limit, qps)
})
}
}

func TestRateLimiterGoroutines(t *testing.T) {
for i, limit := range testlimits {
t.Run(fmt.Sprintf("%d ops/s", limit), func(t *testing.T) {
i, limit := i, limit
t.Parallel()
l := NewLimiter(limit)

Expand All @@ -71,6 +74,7 @@ func TestRateLimiterGoroutines(t *testing.T) {
if qps > float64(limit)*1.01 {
t.Errorf("#%d: Too many operations per second. Expected ~%d, got %f", i, limit, qps)
}
log.Infof("#%d: Expected ~%d, got %f", i, limit, qps)
})
}
}

0 comments on commit 3362d9e

Please sign in to comment.