Skip to content

Commit 48d4aa4

Browse files
committed
Test coverage improvement
Proxy block uncle fix
1 parent a2a5411 commit 48d4aa4

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
package io.api.etherscan;
22

3-
import io.api.etherscan.core.impl.EtherScanApi;
4-
import io.api.etherscan.executor.IHttpExecutor;
5-
import io.api.etherscan.executor.impl.HttpExecutor;
6-
import io.api.etherscan.model.EthNetwork;
7-
8-
import java.util.function.Supplier;
9-
103
public class App {
114
public static void main(String[] args) {
12-
int connectionTimeout = 10000;
13-
int readTimeout = 7000;
14-
Supplier<IHttpExecutor> supplier = () -> new HttpExecutor(connectionTimeout);
155

16-
EtherScanApi api = new EtherScanApi(EthNetwork.RINKEBY, supplier);
17-
EtherScanApi apiWithKey = new EtherScanApi("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
final long compBlockNo = BasicUtils.compensateMinBlock(blockNo);
8787
final long compIndex = BasicUtils.compensateMinBlock(index);
8888

89-
final String urlParams = ACT_UNCLE_BY_BLOCKNOINDEX_PARAM + TAG_PARAM + compBlockNo + INDEX_PARAM + compIndex;
89+
final String urlParams = ACT_UNCLE_BY_BLOCKNOINDEX_PARAM + TAG_PARAM
90+
+ "0x" + Long.toHexString(compBlockNo) + INDEX_PARAM + "0x" + Long.toHexString(compIndex);
9091
final BlockProxyTO response = getRequest(urlParams, BlockProxyTO.class);
9192
return Optional.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
public InvalidDataHexException(String message) {
1212
super(message);
1313
}
14-
15-
public InvalidDataHexException(String message, Throwable cause) {
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
public InvalidTxHashException(String message) {
1212
super(message);
1313
}
14-
15-
public InvalidTxHashException(String message, Throwable cause) {
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
public class ParseException extends ApiException {
1010

11-
public ParseException(String message) {
12-
super(message);
13-
}
14-
1511
public ParseException(String message, Throwable cause) {
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
public void timeout() {
54-
Supplier<IHttpExecutor> supplier = () -> new HttpExecutor(1000, 1000);
54+
Supplier<IHttpExecutor> supplier = () -> new HttpExecutor(300, 300);
5555
EtherScanApi api = new EtherScanApi(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+
package io.api.etherscan.proxy;
2+
3+
import io.api.etherscan.core.impl.EtherScanApi;
4+
import org.junit.Assert;
5+
import org.junit.Test;
6+
7+
/**
8+
* ! NO DESCRIPTION !
9+
*
10+
* @author GoodforGod
11+
* @since 13.11.2018
12+
*/
13+
public class ProxyBlockLastNoApiTest extends Assert {
14+
15+
private final EtherScanApi api = new EtherScanApi();
16+
17+
@Test
18+
public void correct() {
19+
long noLast = 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+
package io.api.etherscan.proxy;
2+
3+
import io.api.etherscan.core.impl.EtherScanApi;
4+
import io.api.etherscan.model.proxy.BlockProxy;
5+
import org.junit.Assert;
6+
import org.junit.Test;
7+
8+
import java.util.Optional;
9+
10+
/**
11+
* ! NO DESCRIPTION !
12+
*
13+
* @author GoodforGod
14+
* @since 13.11.2018
15+
*/
16+
public class ProxyBlockUncleApiTest extends Assert {
17+
18+
private final EtherScanApi api = new EtherScanApi();
19+
20+
@Test
21+
public void correct() {
22+
Optional<BlockProxy> block = api.proxy().blockUncle(603183, 0);
23+
assertTrue(block.isPresent());
24+
assertNotNull(block.get().getHash());
25+
}
26+
27+
@Test
28+
public void correctParamWithEmptyExpectedResult() {
29+
Optional<BlockProxy> block = api.proxy().blockUncle(5120, 1);
30+
assertFalse(block.isPresent());
31+
}
32+
33+
@Test
34+
public void correctParamNegativeNo() {
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
import io.api.etherscan.error.EtherScanException;
55
import io.api.etherscan.error.InvalidDataHexException;
66
import org.junit.Assert;
7-
import org.junit.Ignore;
87
import org.junit.Test;
98

109
import java.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
public class ProxyTxSendRawApiTest extends Assert {
2119

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