Skip to content

Commit 52eaea6

Browse files
committed
feat(net): add global rate limiter test
1 parent 5b5d01f commit 52eaea6

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.tron.core.services.ratelimiter;
2+
3+
import java.lang.reflect.Field;
4+
import org.junit.Assert;
5+
import org.junit.Test;
6+
import org.tron.core.Constant;
7+
import org.tron.core.config.args.Args;
8+
9+
public class GlobalRateLimiterTest {
10+
11+
@Test
12+
public void testAcquire() throws Exception {
13+
String[] a = new String[0];
14+
Args.setParam(a, Constant.TESTNET_CONF);
15+
RuntimeData runtimeData = new RuntimeData(null);
16+
Field field = runtimeData.getClass().getDeclaredField("address");
17+
field.setAccessible(true);
18+
field.set(runtimeData, "127.0.0.1");
19+
Assert.assertEquals(runtimeData.getRemoteAddr(), "127.0.0.1");
20+
GlobalRateLimiter.acquire(runtimeData);
21+
}
22+
}

0 commit comments

Comments
 (0)