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")

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