diff --git a/middleware/limiter/limiter_test.go b/middleware/limiter/limiter_test.go index 2f2b2836f3..b73074ac83 100644 --- a/middleware/limiter/limiter_test.go +++ b/middleware/limiter/limiter_test.go @@ -1,8 +1,9 @@ package limiter import ( + "crypto/rand" "io" - "math/rand" + "math/big" "net/http/httptest" "sync" "testing" @@ -19,11 +20,13 @@ import ( func Test_Limiter_With_Max_Calculator(t *testing.T) { t.Parallel() app := fiber.New() - max := rand.Intn(10) + max, err := rand.Int(rand.Reader, big.NewInt(10)) + + require.NoError(t, err) app.Use(New(Config{ MaxCalculator: func(_ fiber.Ctx) int { - return max + return int(max.Int64()) }, Expiration: 2 * time.Second, Storage: memory.New(), @@ -35,7 +38,7 @@ func Test_Limiter_With_Max_Calculator(t *testing.T) { var wg sync.WaitGroup - for i := 0; i <= max-1; i++ { + for i := 0; i <= int(max.Int64())-1; i++ { wg.Add(1) go func(wg *sync.WaitGroup) { defer wg.Done()