eth: fix panic in randomDuration when min equals max (#33193)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

Fixes a potential panic in `randomDuration` when `min == max` by
handling the edge case explicitly.
This commit is contained in:
maradini77 2025-11-18 18:54:53 +01:00 committed by GitHub
parent 5e6f7374de
commit e0d81d1e99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -145,6 +145,9 @@ func randomDuration(min, max time.Duration) time.Duration {
if min > max {
panic("min duration must be less than or equal to max duration")
}
if min == max {
return min
}
return time.Duration(mrand.Int63n(int64(max-min)) + int64(min))
}