mock: increase tolerance for latency tests

These were exceeding their tolerances when run under the race detector on CI.
This commit is contained in:
Steven Allen 2019-03-06 12:01:08 -08:00
parent 5b643cde2d
commit 5c51323aa2
1 changed files with 13 additions and 13 deletions

View File

@ -489,36 +489,36 @@ func TestAdding(t *testing.T) {
func TestRateLimiting(t *testing.T) {
rl := NewRateLimiter(10)
if !within(rl.Limit(10), time.Duration(float32(time.Second)), time.Millisecond/10) {
t.Fail()
if !within(rl.Limit(10), time.Duration(float32(time.Second)), time.Millisecond) {
t.Fatal()
}
if !within(rl.Limit(10), time.Duration(float32(time.Second*2)), time.Millisecond) {
t.Fail()
t.Fatal()
}
if !within(rl.Limit(10), time.Duration(float32(time.Second*3)), time.Millisecond) {
t.Fail()
t.Fatal()
}
if within(rl.Limit(10), time.Duration(float32(time.Second*3)), time.Millisecond) {
t.Fail()
t.Fatal()
}
rl.UpdateBandwidth(50)
if !within(rl.Limit(75), time.Duration(float32(time.Second)*1.5), time.Millisecond/10) {
t.Fail()
if !within(rl.Limit(75), time.Duration(float32(time.Second)*1.5), time.Millisecond) {
t.Fatal()
}
if within(rl.Limit(75), time.Duration(float32(time.Second)*1.5), time.Millisecond/10) {
t.Fail()
if within(rl.Limit(75), time.Duration(float32(time.Second)*1.5), time.Millisecond) {
t.Fatal()
}
rl.UpdateBandwidth(100)
if !within(rl.Limit(1), time.Duration(time.Millisecond*10), time.Millisecond/10) {
t.Fail()
if !within(rl.Limit(1), time.Duration(time.Millisecond*10), time.Millisecond) {
t.Fatal()
}
if within(rl.Limit(1), time.Duration(time.Millisecond*10), time.Millisecond/10) {
t.Fail()
if within(rl.Limit(1), time.Duration(time.Millisecond*10), time.Millisecond) {
t.Fatal()
}
}