Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd13f5a4

Browse files
committed
[1.1.0-SNAPSHOT]
Rest before timeout check for api not exceed rate
1 parent315ef5f commitd13f5a4

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

‎src/test/java/io/api/ApiRunner.java‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,26 @@ public class ApiRunner extends Assert {
1111
privatestaticfinalEtherScanApiapiRopsten;
1212
privatestaticfinalEtherScanApiapiRinkeby;
1313
privatestaticfinalEtherScanApiapiKovan;
14+
privatestaticfinalStringkey;
1415

1516
static {
1617
finalStringapiKey =System.getenv("API_KEY");
17-
finalStringkeyOrDefault = (apiKey ==null ||apiKey.isEmpty())
18+
key = (apiKey ==null ||apiKey.isEmpty())
1819
?EtherScanApi.DEFAULT_KEY
1920
:apiKey;
2021

21-
finalQueueManagerqueue =keyOrDefault.equals(EtherScanApi.DEFAULT_KEY)
22+
finalQueueManagerqueue =key.equals(EtherScanApi.DEFAULT_KEY)
2223
?QueueManager.DEFAULT_KEY_QUEUE
2324
:newQueueManager(1,2);
2425

25-
api =newEtherScanApi(keyOrDefault,EthNetwork.MAINNET,queue);
26-
apiRopsten =newEtherScanApi(keyOrDefault,EthNetwork.ROPSTEN,queue);
27-
apiRinkeby =newEtherScanApi(keyOrDefault,EthNetwork.RINKEBY,queue);
28-
apiKovan =newEtherScanApi(keyOrDefault,EthNetwork.KOVAN,queue);
26+
api =newEtherScanApi(key,EthNetwork.MAINNET,queue);
27+
apiRopsten =newEtherScanApi(key,EthNetwork.ROPSTEN,queue);
28+
apiRinkeby =newEtherScanApi(key,EthNetwork.RINKEBY,queue);
29+
apiKovan =newEtherScanApi(key,EthNetwork.KOVAN,queue);
30+
}
31+
32+
publicstaticStringgetKey() {
33+
returnkey;
2934
}
3035

3136
publicstaticEtherScanApigetApi() {

‎src/test/java/io/api/etherscan/EtherScanApiTest.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
importorg.junit.Test;
1414

1515
importjava.util.List;
16+
importjava.util.concurrent.TimeUnit;
1617
importjava.util.function.Supplier;
1718

1819
/**
@@ -75,9 +76,10 @@ public void noTimeoutUnlimitedAwait() {
7576
}
7677

7778
@Test(expected =ApiTimeoutException.class)
78-
publicvoidtimeout() {
79+
publicvoidtimeout()throwsInterruptedException {
80+
TimeUnit.SECONDS.sleep(5);
7981
Supplier<IHttpExecutor>supplier = () ->newHttpExecutor(300,300);
80-
EtherScanApiapi =newEtherScanApi(EthNetwork.KOVAN,supplier);
82+
EtherScanApiapi =newEtherScanApi(getKey(),EthNetwork.KOVAN,supplier);
8183
List<Block>blocks =api.account().minedBlocks("0x0010f94b296A852aAac52EA6c5Ac72e03afD032D");
8284
assertNotNull(blocks);
8385
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp