Skip to content

Commit 051bf29

Browse files
committed
Code coverage improvements
README badges
1 parent 48d4aa4 commit 051bf29

14 files changed

+98
-8
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# java-etherscan-api
22

3+
![travis](https://travis-ci.org/GoodforGod/java-etherscan-api.svg?branch=master)
4+
[![Maintainability](https://api.codeclimate.com/v1/badges/808997be2e69ff1ae8fe/maintainability)](https://codeclimate.com/github/GoodforGod/java-etherscan-api/maintainability)
5+
[![codecov](https://codecov.io/gh/GoodforGod/java-etherscan-api/branch/master/graph/badge.svg)](https://codecov.io/gh/GoodforGod/java-etherscan-api)
6+
37
[Etherscan](https://etherscan.io/apis) Java API implementation.
48

59
Library supports all available EtherScan *API* calls for all available *Ethereum Networks*.

src/main/java/io/api/etherscan/model/Supply.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
*/
1111
public class Supply extends Wei {
1212

13-
public Supply() {
14-
super();
15-
}
16-
17-
public Supply(long value) {
18-
super(value);
19-
}
20-
2113
public Supply(BigInteger value) {
2214
super(value);
2315
}

src/test/java/io/api/etherscan/account/AccountBalanceListTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ public void correctMoreThat20Addresses() {
4747
for(Balance balance : balances) {
4848
assertNotNull(balance.getAddress());
4949
assertNotEquals(0, balance.getWei());
50+
assertNotEquals(0, balance.getKwei());
51+
assertNotEquals(0, balance.getMwei());
52+
assertNotEquals(0, balance.getEther());
53+
assertNotEquals(0, balance.getGwei());
5054
}
55+
56+
assertFalse(balances.get(0).equals(balances.get(1)));
5157
}
5258

5359
@Test(expected = InvalidAddressException.class)

src/test/java/io/api/etherscan/account/AccountMinedBlocksTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public void correct() {
6969

7070
assertEquals(blocksMined, blocks.size());
7171
assertBlocks(blocks);
72+
Block block = new Block();
73+
assertFalse(blocks.get(0).equals(block));
7274
}
7375

7476
@Test(expected = InvalidAddressException.class)

src/test/java/io/api/etherscan/account/AccountTokenBalanceTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.junit.runners.Parameterized;
1212
import org.junit.runners.Parameterized.Parameters;
1313

14+
import java.math.BigInteger;
1415
import java.util.Arrays;
1516
import java.util.Collection;
1617

@@ -90,6 +91,9 @@ public void correct() {
9091
assertNotNull(balance.getAddress());
9192
assertNotNull(balance.getContract());
9293
assertNotEquals(0, balance.getWei());
94+
TokenBalance balance1 = new TokenBalance("", BigInteger.ONE, "");
95+
assertFalse(balance.equals(balance1));
96+
assertFalse(balance.hashCode() == balance1.hashCode());
9397
}
9498

9599
@Test(expected = InvalidAddressException.class)

src/test/java/io/api/etherscan/account/AccountTxInternalByHashTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ public void correct() {
8282
assertNotNull(txs.get(0).getTimeStamp());
8383
assertNotNull(txs.get(0).getGas());
8484
assertNotNull(txs.get(0).getValue());
85+
assertNotNull(txs.get(0).getType());
86+
assertFalse(txs.get(0).haveError());
87+
assertFalse(txs.get(0).haveError());
88+
assertNotEquals(-1, txs.get(0).getTraceId());
8589
assertTrue(BasicUtils.isEmpty(txs.get(0).getErrCode()));
8690
}
8791

src/test/java/io/api/etherscan/account/AccountTxTokenTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ private void assertTxs(List<TxToken> txs) {
6262
assertNotNull(tx.getFrom());
6363
assertNotNull(tx.getTo());
6464
assertNotNull(tx.getTimeStamp());
65+
assertNotNull(tx.getTokenDecimal());
66+
assertNotEquals(0,(tx.getConfirmations()));
67+
assertNotNull(tx.getGasUsed());
68+
assertNotEquals(0,(tx.getCumulativeGasUsed()));
69+
assertNotEquals(0, tx.getTransactionIndex());
6570
}
6671
}
6772
}

src/test/java/io/api/etherscan/account/AccountTxsTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void correctStartBlockEndBlock() {
4949
assertNotNull(txs);
5050
assertEquals(3, txs.size());
5151
assertTxs(txs);
52+
assertFalse(txs.get(0).equals(txs.get(1)));
5253
}
5354

5455
@Test(expected = InvalidAddressException.class)
@@ -65,10 +66,15 @@ public void correctParamWithEmptyExpectedResult() {
6566

6667
private void assertTxs(List<Tx> txs) {
6768
for (Tx tx : txs) {
69+
assertFalse(tx.haveError());
6870
assertNotNull(tx.getBlockHash());
6971
assertNotNull(tx.getFrom());
7072
assertNotNull(tx.getTo());
7173
assertNotNull(tx.getTimeStamp());
74+
assertNotEquals(-1, (tx.getNonce()));
75+
assertNotEquals(0, (tx.getTransactionIndex()));
76+
assertNotEquals(0, tx.getConfirmations());
77+
assertNotNull(tx.getTxreceipt_status());
7278
}
7379
}
7480
}

src/test/java/io/api/etherscan/block/BlockApiTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public void correct() {
2828
assertFalse(uncles.get().getUncles().isEmpty());
2929
assertNotNull(uncles.get().getUncles().get(0).getBlockreward());
3030
assertNotNull(uncles.get().getUncles().get(0).getMiner());
31+
32+
assertNotEquals(0, uncles.get().hashCode());
3133
}
3234

3335
@Test

src/test/java/io/api/etherscan/logs/LogQueryBuilderTest.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,45 @@ public void quadroCorrect() {
119119
assertNotNull(quadro.getParams());
120120
}
121121

122+
@Test(expected = LogQueryException.class)
123+
public void quadroIncorrectTopic() {
124+
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
125+
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
126+
null,
127+
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
128+
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
129+
.setOpTopic0_1(LogOp.AND)
130+
.setOpTopic0_2(LogOp.OR)
131+
.setOpTopic0_3(LogOp.AND)
132+
.setOpTopic1_2(LogOp.OR)
133+
.setOpTopic1_3(LogOp.OR)
134+
.setOpTopic2_3(LogOp.OR)
135+
.build();
136+
137+
assertNotNull(quadro);
138+
assertNotNull(quadro.getParams());
139+
}
140+
141+
142+
@Test(expected = LogQueryException.class)
143+
public void quadroInCorrectAgainTopic() {
144+
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
145+
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
146+
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
147+
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
148+
null)
149+
.setOpTopic0_1(LogOp.AND)
150+
.setOpTopic0_2(LogOp.OR)
151+
.setOpTopic0_3(LogOp.AND)
152+
.setOpTopic1_2(LogOp.OR)
153+
.setOpTopic1_3(LogOp.OR)
154+
.setOpTopic2_3(LogOp.OR)
155+
.build();
156+
157+
assertNotNull(quadro);
158+
assertNotNull(quadro.getParams());
159+
}
160+
122161
@Test(expected = LogQueryException.class)
123162
public void quadroInCorrectOp() {
124163
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")

src/test/java/io/api/etherscan/logs/LogsApiTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public void validateQuery() {
7676
assertNotNull(logs.get(0).getTransactionHash());
7777
assertNotEquals(0, logs.get(0).getTransactionIndex());
7878
assertNotNull(logs.get(0).getGasUsed());
79+
assertNotNull(logs.get(0).getTopics());
80+
assertNotEquals(0, logs.get(0).getLogIndex());
81+
assertNotNull(logs.get(0).getGasPrice());
7982
}
8083
}
8184
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ public void correctByBlockNo() {
3838
assertNotNull(tx.get().getTo());
3939
assertNotNull(tx.get().getHash());
4040
assertNotNull(tx.get().getNonce());
41+
assertNotNull(tx.get().getS());
42+
assertNotNull(tx.get().getR());
43+
assertNotNull(tx.get().getValue());
44+
assertNotNull(tx.get().getV());
45+
assertNotNull(tx.get().getGas());
46+
assertNotNull(tx.get().getGasPrice());
47+
assertNotNull(tx.get().getBlockHash());
48+
assertNotNull(tx.get().getTransactionIndex());
49+
assertNotNull(tx.get().getInput());
4150
}
4251

4352
@Test(expected = InvalidTxHashException.class)

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ public class ProxyTxReceiptApiTest extends Assert {
2222
public void correct() {
2323
Optional<ReceiptProxy> infoProxy = api.proxy().txReceipt("0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1");
2424
assertTrue(infoProxy.isPresent());
25+
assertNotNull(infoProxy.get().getBlockHash());
26+
assertNotNull(infoProxy.get().getRoot());
27+
assertNotNull(infoProxy.get().getFrom());
28+
assertNotNull(infoProxy.get().getTo());
29+
assertNotNull(infoProxy.get().getBlockNumber());
30+
assertNotNull(infoProxy.get().getBlockHash());
31+
assertNotNull(infoProxy.get().getTransactionHash());
32+
assertNotNull(infoProxy.get().getTransactionIndex());
33+
assertNotNull(infoProxy.get().getGasUsed());
34+
assertNotNull(infoProxy.get().getCumulativeGasUsed());
35+
assertNotNull(infoProxy.get().getLogs());
36+
assertNotNull(infoProxy.get().getLogsBloom());
37+
assertNull(infoProxy.get().getContractAddress());
2538
}
2639

2740
@Test(expected = InvalidTxHashException.class)

src/test/java/io/api/etherscan/transaction/TransactionExecApiTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public void correct() {
2323
Optional<Status> status = api.txs().execStatus("0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a");
2424
assertTrue(status.isPresent());
2525
assertTrue(status.get().haveError());
26+
assertNotNull(status.get().getErrDescription());
2627
}
2728

2829
@Test(expected = InvalidTxHashException.class)

0 commit comments

Comments
 (0)