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

Commit48d4aa4

Browse files
committed
Test coverage improvement
Proxy block uncle fix
1 parenta2a5411 commit48d4aa4

File tree

9 files changed

+63
-28
lines changed

9 files changed

+63
-28
lines changed
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
packageio.api.etherscan;
22

3-
importio.api.etherscan.core.impl.EtherScanApi;
4-
importio.api.etherscan.executor.IHttpExecutor;
5-
importio.api.etherscan.executor.impl.HttpExecutor;
6-
importio.api.etherscan.model.EthNetwork;
7-
8-
importjava.util.function.Supplier;
9-
103
publicclassApp {
114
publicstaticvoidmain(String[]args) {
12-
intconnectionTimeout =10000;
13-
intreadTimeout =7000;
14-
Supplier<IHttpExecutor>supplier = () ->newHttpExecutor(connectionTimeout);
155

16-
EtherScanApiapi =newEtherScanApi(EthNetwork.RINKEBY,supplier);
17-
EtherScanApiapiWithKey =newEtherScanApi("YourApiKey",EthNetwork.MAINNET,supplier);
186
}
197
}

‎src/main/java/io/api/etherscan/core/impl/ProxyApiProvider.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public Optional<BlockProxy> blockUncle(final long blockNo, final long index) thr
8686
finallongcompBlockNo =BasicUtils.compensateMinBlock(blockNo);
8787
finallongcompIndex =BasicUtils.compensateMinBlock(index);
8888

89-
finalStringurlParams =ACT_UNCLE_BY_BLOCKNOINDEX_PARAM +TAG_PARAM +compBlockNo +INDEX_PARAM +compIndex;
89+
finalStringurlParams =ACT_UNCLE_BY_BLOCKNOINDEX_PARAM +TAG_PARAM
90+
+"0x" +Long.toHexString(compBlockNo) +INDEX_PARAM +"0x" +Long.toHexString(compIndex);
9091
finalBlockProxyTOresponse =getRequest(urlParams,BlockProxyTO.class);
9192
returnOptional.ofNullable(response.getResult());
9293
}

‎src/main/java/io/api/etherscan/error/InvalidDataHexException.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,4 @@ public class InvalidDataHexException extends ApiException {
1111
publicInvalidDataHexException(Stringmessage) {
1212
super(message);
1313
}
14-
15-
publicInvalidDataHexException(Stringmessage,Throwablecause) {
16-
super(message,cause);
17-
}
1814
}

‎src/main/java/io/api/etherscan/error/InvalidTxHashException.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,4 @@ public class InvalidTxHashException extends ApiException {
1111
publicInvalidTxHashException(Stringmessage) {
1212
super(message);
1313
}
14-
15-
publicInvalidTxHashException(Stringmessage,Throwablecause) {
16-
super(message,cause);
17-
}
1814
}

‎src/main/java/io/api/etherscan/error/ParseException.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
*/
99
publicclassParseExceptionextendsApiException {
1010

11-
publicParseException(Stringmessage) {
12-
super(message);
13-
}
14-
1511
publicParseException(Stringmessage,Throwablecause) {
1612
super(message,cause);
1713
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void nullNetwork() {
5151

5252
@Test(expected =ApiTimeoutException.class)
5353
publicvoidtimeout() {
54-
Supplier<IHttpExecutor>supplier = () ->newHttpExecutor(1000,1000);
54+
Supplier<IHttpExecutor>supplier = () ->newHttpExecutor(300,300);
5555
EtherScanApiapi =newEtherScanApi(EthNetwork.KOVAN,supplier);
5656
List<Block>blocks =api.account().minedBlocks("0x0010f94b296A852aAac52EA6c5Ac72e03afD032D");
5757
assertNotNull(api);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
packageio.api.etherscan.proxy;
2+
3+
importio.api.etherscan.core.impl.EtherScanApi;
4+
importorg.junit.Assert;
5+
importorg.junit.Test;
6+
7+
/**
8+
* ! NO DESCRIPTION !
9+
*
10+
* @author GoodforGod
11+
* @since 13.11.2018
12+
*/
13+
publicclassProxyBlockLastNoApiTestextendsAssert {
14+
15+
privatefinalEtherScanApiapi =newEtherScanApi();
16+
17+
@Test
18+
publicvoidcorrect() {
19+
longnoLast =api.proxy().blockNoLast();
20+
assertNotEquals(0,noLast);
21+
}
22+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
packageio.api.etherscan.proxy;
2+
3+
importio.api.etherscan.core.impl.EtherScanApi;
4+
importio.api.etherscan.model.proxy.BlockProxy;
5+
importorg.junit.Assert;
6+
importorg.junit.Test;
7+
8+
importjava.util.Optional;
9+
10+
/**
11+
* ! NO DESCRIPTION !
12+
*
13+
* @author GoodforGod
14+
* @since 13.11.2018
15+
*/
16+
publicclassProxyBlockUncleApiTestextendsAssert {
17+
18+
privatefinalEtherScanApiapi =newEtherScanApi();
19+
20+
@Test
21+
publicvoidcorrect() {
22+
Optional<BlockProxy>block =api.proxy().blockUncle(603183,0);
23+
assertTrue(block.isPresent());
24+
assertNotNull(block.get().getHash());
25+
}
26+
27+
@Test
28+
publicvoidcorrectParamWithEmptyExpectedResult() {
29+
Optional<BlockProxy>block =api.proxy().blockUncle(5120,1);
30+
assertFalse(block.isPresent());
31+
}
32+
33+
@Test
34+
publicvoidcorrectParamNegativeNo() {
35+
Optional<BlockProxy>block =api.proxy().blockUncle(-603183,0);
36+
assertFalse(block.isPresent());
37+
}
38+
}

‎src/test/java/io/api/etherscan/proxy/ProxyTxSendRawApiTest.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
importio.api.etherscan.error.EtherScanException;
55
importio.api.etherscan.error.InvalidDataHexException;
66
importorg.junit.Assert;
7-
importorg.junit.Ignore;
87
importorg.junit.Test;
98

109
importjava.util.Optional;
@@ -15,7 +14,6 @@
1514
* @author GoodforGod
1615
* @since 03.11.2018
1716
*/
18-
@Ignore
1917
//TODO contact etherscan and ask about method behavior
2018
publicclassProxyTxSendRawApiTestextendsAssert {
2119

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp