forked from mtusi2026/mtusi2026lab6
23 lines
453 B
Go
23 lines
453 B
Go
package pipeline
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestRetryDelayBounds(t *testing.T) {
|
|
for attempt := 1; attempt <= 20; attempt++ {
|
|
bounded := attempt
|
|
if bounded > 6 {
|
|
bounded = 6
|
|
}
|
|
base := time.Second * time.Duration(1<<uint(bounded-1))
|
|
for i := 0; i < 100; i++ {
|
|
got := RetryDelay(attempt)
|
|
if got < base || got > base+base/2 {
|
|
t.Fatalf("attempt %d: delay %s outside [%s,%s]", attempt, got, base, base+base/2)
|
|
}
|
|
}
|
|
}
|
|
}
|