Skip to content

Commit

Permalink
fix: use crypto/rand instead of math/rand on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luk3skyw4lker committed Jul 11, 2024
1 parent e1dc5dc commit e676a1b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions middleware/limiter/limiter_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package limiter

import (
"crypto/rand"
"io"
"math/rand"
"math/big"
"net/http/httptest"
"sync"
"testing"
Expand All @@ -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(),
Expand All @@ -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()
Expand Down

0 comments on commit e676a1b

Please sign in to comment.