Skip to content

Commit

Permalink
JavaDoc Improvements & coverage improvements
Browse files Browse the repository at this point in the history
Final 1.0.0
  • Loading branch information
GoodforGod committed Nov 13, 2018
1 parent 296d156 commit 08edbb2
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public Optional<String> txSendRaw(final String hexEncodedTx) throws ApiException
final StringProxyTO response = postRequest(urlParams, "", StringProxyTO.class);
if(response.getError() != null)
throw new EtherScanException("Error occurred with code " + response.getError().getCode()
+ " with message " + response.getError().getMessage());
+ " with message " + response.getError().getMessage()
+ ", error id " + response.getId() + ", jsonRPC " + response.getJsonrpc());

return (BasicUtils.isEmpty(response.getResult()))
? Optional.empty()
Expand Down
82 changes: 38 additions & 44 deletions src/test/java/io/api/etherscan/logs/LogQueryBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.api.etherscan.model.query.LogOp;
import io.api.etherscan.model.query.impl.LogQuery;
import io.api.etherscan.model.query.impl.LogQueryBuilder;
import io.api.etherscan.model.query.impl.LogTopicQuadro;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -19,8 +20,8 @@ public class LogQueryBuilderTest extends Assert {
@Test
public void singleCorrect() {
LogQuery single = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545")
.build();
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545")
.build();

assertNotNull(single);
assertNotNull(single.getParams());
Expand Down Expand Up @@ -107,7 +108,7 @@ public void tripleInCorrectTopic1() {
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
.setOpTopic0_1(LogOp.AND)
.setOpTopic0_2(null)
.setOpTopic0_2(LogOp.AND)
.setOpTopic1_2(LogOp.AND)
.build();

Expand All @@ -119,10 +120,10 @@ public void tripleInCorrectTopic1() {
public void tripleInCorrectTopic2() {
LogQuery triple = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c", 379224, 400000)
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"null",
null,
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
.setOpTopic0_1(LogOp.AND)
.setOpTopic0_2(null)
.setOpTopic0_2(LogOp.AND)
.setOpTopic1_2(LogOp.AND)
.build();

Expand All @@ -135,9 +136,9 @@ public void tripleInCorrectTopic3() {
LogQuery triple = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c", 379224, 400000)
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
"null")
null)
.setOpTopic0_1(LogOp.AND)
.setOpTopic0_2(null)
.setOpTopic0_2(LogOp.AND)
.setOpTopic1_2(LogOp.AND)
.build();

Expand Down Expand Up @@ -209,59 +210,55 @@ public void tupleIncorrectTopic1() {

@Test(expected = LogQueryException.class)
public void quadroIncorrectOp1() {
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
null,
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
"0x72657075746174696f6e00000000000000000000000000000000000000000000");

topicQuadro
.setOpTopic0_1(null)
.setOpTopic0_2(LogOp.OR)
.setOpTopic0_3(LogOp.AND)
.setOpTopic1_2(LogOp.OR)
.setOpTopic1_3(LogOp.OR)
.setOpTopic2_3(LogOp.OR)
.build();

assertNotNull(quadro);
assertNotNull(quadro.getParams());
}

@Test(expected = LogQueryException.class)
public void quadroIncorrectOp2() {
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
null,
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
.setOpTopic0_1(LogOp.AND)
"0x72657075746174696f6e00000000000000000000000000000000000000000000");

topicQuadro.setOpTopic0_1(LogOp.AND)
.setOpTopic0_2(null)
.setOpTopic0_3(LogOp.AND)
.setOpTopic1_2(LogOp.OR)
.setOpTopic1_3(LogOp.OR)
.setOpTopic2_3(LogOp.OR)
.build();

assertNotNull(quadro);
assertNotNull(quadro.getParams());
}

@Test(expected = LogQueryException.class)
public void quadroIncorrectOp3() {
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
null,
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
"0x72657075746174696f6e00000000000000000000000000000000000000000000");

topicQuadro
.setOpTopic0_1(LogOp.AND)
.setOpTopic0_2(LogOp.OR)
.setOpTopic0_3(null)
.setOpTopic1_2(LogOp.OR)
.setOpTopic1_3(LogOp.OR)
.setOpTopic2_3(LogOp.OR)
.build();

assertNotNull(quadro);
assertNotNull(quadro.getParams());
}

@Test(expected = LogQueryException.class)
Expand All @@ -285,59 +282,56 @@ public void quadroInCorrectAgainTopic() {

@Test(expected = LogQueryException.class)
public void quadroInCorrectOp4() {
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
"",
"")
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545");

topicQuadro
.setOpTopic0_1(LogOp.AND)
.setOpTopic0_2(LogOp.OR)
.setOpTopic0_3(LogOp.AND)
.setOpTopic1_2(null)
.setOpTopic1_3(LogOp.OR)
.setOpTopic2_3(LogOp.OR)
.build();

assertNotNull(quadro);
assertNotNull(quadro.getParams());
}

@Test(expected = LogQueryException.class)
public void quadroInCorrectOp5() {
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
"",
"")
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545");

topicQuadro
.setOpTopic0_1(LogOp.AND)
.setOpTopic0_2(LogOp.OR)
.setOpTopic0_3(LogOp.AND)
.setOpTopic1_2(LogOp.AND)
.setOpTopic1_3(null)
.setOpTopic2_3(LogOp.OR)
.build();

assertNotNull(quadro);
assertNotNull(quadro.getParams());
}

@Test(expected = LogQueryException.class)
public void quadroInCorrectOp6() {
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
"",
"")
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545");

topicQuadro
.setOpTopic0_1(LogOp.AND)
.setOpTopic0_2(LogOp.OR)
.setOpTopic0_3(LogOp.AND)
.setOpTopic1_2(LogOp.AND)
.setOpTopic1_3(LogOp.OR)
.setOpTopic2_3(null)
.build();

assertNotNull(quadro);
assertNotNull(quadro.getParams());
}

@Test(expected = LogQueryException.class)
Expand Down
13 changes: 8 additions & 5 deletions src/test/java/io/api/etherscan/proxy/ProxyTxApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ public class ProxyTxApiTest extends Assert {
public void correctByHash() {
Optional<TxProxy> tx = api.proxy().tx("0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1");
assertTrue(tx.isPresent());
assertNotNull(tx.get().getBlockHash());
assertNotNull(tx.get().getFrom());
assertNotNull(tx.get().getTo());
assertNotNull(tx.get().getHash());
assertNotNull(tx.get().getNonce());

TxProxy txProxy = tx.get();
assertNotNull(txProxy.getBlockHash());
assertNotNull(txProxy.getBlockNumber());
assertNotNull(txProxy.getFrom());
assertNotNull(txProxy.getTo());
assertNotNull(txProxy.getHash());
assertNotNull(txProxy.getNonce());
}

@Test
Expand Down
28 changes: 15 additions & 13 deletions src/test/java/io/api/etherscan/proxy/ProxyTxReceiptApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ public class ProxyTxReceiptApiTest extends Assert {
public void correct() {
Optional<ReceiptProxy> infoProxy = api.proxy().txReceipt("0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1");
assertTrue(infoProxy.isPresent());
assertNotNull(infoProxy.get().getBlockHash());
assertNotNull(infoProxy.get().getRoot());
assertNotNull(infoProxy.get().getFrom());
assertNotNull(infoProxy.get().getTo());
assertNotNull(infoProxy.get().getBlockNumber());
assertNotNull(infoProxy.get().getBlockHash());
assertNotNull(infoProxy.get().getTransactionHash());
assertNotNull(infoProxy.get().getTransactionIndex());
assertNotNull(infoProxy.get().getGasUsed());
assertNotNull(infoProxy.get().getCumulativeGasUsed());
assertNotNull(infoProxy.get().getLogs());
assertNotNull(infoProxy.get().getLogsBloom());
assertNull(infoProxy.get().getContractAddress());

ReceiptProxy receiptProxy = infoProxy.get();
assertNotNull(receiptProxy.getBlockHash());
assertNotNull(receiptProxy.getRoot());
assertNotNull(receiptProxy.getFrom());
assertNotNull(receiptProxy.getTo());
assertNotNull(receiptProxy.getBlockNumber());
assertNotNull(receiptProxy.getBlockHash());
assertNotNull(receiptProxy.getTransactionHash());
assertNotNull(receiptProxy.getTransactionIndex());
assertNotNull(receiptProxy.getGasUsed());
assertNotNull(receiptProxy.getCumulativeGasUsed());
assertNotNull(receiptProxy.getLogs());
assertNotNull(receiptProxy.getLogsBloom());
assertNull(receiptProxy.getContractAddress());
}

@Test(expected = InvalidTxHashException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
Expand All @@ -16,7 +17,7 @@
* @author GoodforGod
* @since 13.11.2018
*/
public class UtilTests extends Assert {
public class BasicUtilsTests extends Assert {

@Test(expected = EtherScanException.class)
public void responseValidateEmpty() {
Expand All @@ -31,9 +32,16 @@ public void responseValidateNullable() {
}

@Test
public void partitionEmpty() {
public void partitionNewArrayList() {
ArrayList<String> list = new ArrayList<>();
List<List<String>> lists = BasicUtils.partition(list, 12);
assertTrue(lists.isEmpty());
}

@Test
public void partitionEmpty() {
List<String> list = Collections.emptyList();
List<List<String>> lists = BasicUtils.partition(list, 12);
assertTrue(lists.isEmpty());
}
}

0 comments on commit 08edbb2

Please sign in to comment.