Skip to content

Commit 412f99b

Browse files
committed
[1.1.1]
ProxyBlockApiTest self queue with longer timeout
1 parent 167edcd commit 412f99b

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ public class ApiRunner extends Assert {
1111
private static final EtherScanApi apiRopsten;
1212
private static final EtherScanApi apiRinkeby;
1313
private static final EtherScanApi apiKovan;
14-
private static final String key;
14+
private static final String apiKey;
1515

1616
static {
17-
final String apiKey = System.getenv("API_KEY");
18-
key = (apiKey == null || apiKey.isEmpty())
17+
final String key = System.getenv("API_KEY");
18+
apiKey = (key == null || key.isEmpty())
1919
? EtherScanApi.DEFAULT_KEY
20-
: apiKey;
20+
: key;
2121

2222
final QueueManager queueManager = new QueueManager(2, 2100L, 2100L, 0);
23-
api = new EtherScanApi(key, EthNetwork.MAINNET, queueManager);
24-
apiKovan = new EtherScanApi(key, EthNetwork.KOVAN, queueManager);
25-
apiRopsten = new EtherScanApi(key, EthNetwork.ROPSTEN, queueManager);
26-
apiRinkeby = new EtherScanApi(key, EthNetwork.RINKEBY, queueManager);
23+
api = new EtherScanApi(ApiRunner.apiKey, EthNetwork.MAINNET, queueManager);
24+
apiKovan = new EtherScanApi(ApiRunner.apiKey, EthNetwork.KOVAN, queueManager);
25+
apiRopsten = new EtherScanApi(ApiRunner.apiKey, EthNetwork.ROPSTEN, queueManager);
26+
apiRinkeby = new EtherScanApi(ApiRunner.apiKey, EthNetwork.RINKEBY, queueManager);
2727
}
2828

29-
public static String getKey() {
30-
return key;
29+
public static String getApiKey() {
30+
return apiKey;
3131
}
3232

3333
public static EtherScanApi getApi() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void noTimeoutUnlimitedAwait() {
7979
public void timeout() throws InterruptedException {
8080
TimeUnit.SECONDS.sleep(5);
8181
Supplier<IHttpExecutor> supplier = () -> new HttpExecutor(300, 300);
82-
EtherScanApi api = new EtherScanApi(getKey(), EthNetwork.KOVAN, supplier);
82+
EtherScanApi api = new EtherScanApi(getApiKey(), EthNetwork.KOVAN, supplier);
8383
List<Block> blocks = api.account().minedBlocks("0x0010f94b296A852aAac52EA6c5Ac72e03afD032D");
8484
assertNotNull(blocks);
8585
}

src/test/java/io/api/etherscan/proxy/ProxyBlockApiTest.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package io.api.etherscan.proxy;
22

33
import io.api.ApiRunner;
4+
import io.api.etherscan.core.impl.EtherScanApi;
5+
import io.api.etherscan.manager.impl.QueueManager;
6+
import io.api.etherscan.model.EthNetwork;
47
import io.api.etherscan.model.proxy.BlockProxy;
58
import org.junit.Test;
69

@@ -14,9 +17,16 @@
1417
*/
1518
public class ProxyBlockApiTest extends ApiRunner {
1619

20+
private final EtherScanApi api;
21+
22+
public ProxyBlockApiTest() {
23+
final QueueManager queueManager = new QueueManager(1, 5100L, 5100L, 0);
24+
this.api = new EtherScanApi(getApiKey(), EthNetwork.MAINNET, queueManager);
25+
}
26+
1727
@Test
1828
public void correct() {
19-
Optional<BlockProxy> block = getApi().proxy().block(5120);
29+
Optional<BlockProxy> block = api.proxy().block(5120);
2030
assertTrue(block.isPresent());
2131
BlockProxy proxy = block.get();
2232
assertNotNull(proxy.getHash());
@@ -49,13 +59,13 @@ public void correct() {
4959

5060
@Test
5161
public void correctParamWithEmptyExpectedResult() {
52-
Optional<BlockProxy> block = getApi().proxy().block(99999999999L);
62+
Optional<BlockProxy> block = api.proxy().block(99999999999L);
5363
assertFalse(block.isPresent());
5464
}
5565

5666
@Test
5767
public void correctParamNegativeNo() {
58-
Optional<BlockProxy> block = getApi().proxy().block(-1);
68+
Optional<BlockProxy> block = api.proxy().block(-1);
5969
assertTrue(block.isPresent());
6070
assertNotNull(block.get().getHash());
6171
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy