mirror of
https://github.com/PaperMC/Velocity.git
synced 2025-03-19 16:10:25 +08:00
Add ratelimit tests
This commit is contained in:
parent
d752edc92d
commit
6e4f90dfae
@ -12,7 +12,14 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
class RatelimiterTest {
|
||||
|
||||
@Test
|
||||
void attempt() {
|
||||
void attemptZero() {
|
||||
Ratelimiter noRatelimiter = new Ratelimiter(0);
|
||||
assertTrue(noRatelimiter.attempt(InetAddress.getLoopbackAddress()));
|
||||
assertTrue(noRatelimiter.attempt(InetAddress.getLoopbackAddress()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void attemptOne() {
|
||||
long base = System.nanoTime();
|
||||
AtomicLong extra = new AtomicLong();
|
||||
Ticker testTicker = new Ticker() {
|
||||
@ -27,4 +34,5 @@ class RatelimiterTest {
|
||||
extra.addAndGet(TimeUnit.SECONDS.toNanos(2));
|
||||
assertTrue(ratelimiter.attempt(InetAddress.getLoopbackAddress()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user