Skip to content

Commit 08edbb2

Browse files
committed
JavaDoc Improvements & coverage improvements
Final 1.0.0
1 parent 296d156 commit 08edbb2

File tree

5 files changed

+73
-65
lines changed

5 files changed

+73
-65
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public Optional<String> txSendRaw(final String hexEncodedTx) throws ApiException
143143
final StringProxyTO response = postRequest(urlParams, "", StringProxyTO.class);
144144
if(response.getError() != null)
145145
throw new EtherScanException("Error occurred with code " + response.getError().getCode()
146-
+ " with message " + response.getError().getMessage());
146+
+ " with message " + response.getError().getMessage()
147+
+ ", error id " + response.getId() + ", jsonRPC " + response.getJsonrpc());
147148

148149
return (BasicUtils.isEmpty(response.getResult()))
149150
? Optional.empty()

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

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import io.api.etherscan.model.query.LogOp;
66
import io.api.etherscan.model.query.impl.LogQuery;
77
import io.api.etherscan.model.query.impl.LogQueryBuilder;
8+
import io.api.etherscan.model.query.impl.LogTopicQuadro;
89
import org.junit.Assert;
910
import org.junit.Test;
1011

@@ -19,8 +20,8 @@ public class LogQueryBuilderTest extends Assert {
1920
@Test
2021
public void singleCorrect() {
2122
LogQuery single = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
22-
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545")
23-
.build();
23+
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545")
24+
.build();
2425

2526
assertNotNull(single);
2627
assertNotNull(single.getParams());
@@ -107,7 +108,7 @@ public void tripleInCorrectTopic1() {
107108
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
108109
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
109110
.setOpTopic0_1(LogOp.AND)
110-
.setOpTopic0_2(null)
111+
.setOpTopic0_2(LogOp.AND)
111112
.setOpTopic1_2(LogOp.AND)
112113
.build();
113114

@@ -119,10 +120,10 @@ public void tripleInCorrectTopic1() {
119120
public void tripleInCorrectTopic2() {
120121
LogQuery triple = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c", 379224, 400000)
121122
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
122-
"null",
123+
null,
123124
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
124125
.setOpTopic0_1(LogOp.AND)
125-
.setOpTopic0_2(null)
126+
.setOpTopic0_2(LogOp.AND)
126127
.setOpTopic1_2(LogOp.AND)
127128
.build();
128129

@@ -135,9 +136,9 @@ public void tripleInCorrectTopic3() {
135136
LogQuery triple = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c", 379224, 400000)
136137
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
137138
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
138-
"null")
139+
null)
139140
.setOpTopic0_1(LogOp.AND)
140-
.setOpTopic0_2(null)
141+
.setOpTopic0_2(LogOp.AND)
141142
.setOpTopic1_2(LogOp.AND)
142143
.build();
143144

@@ -209,59 +210,55 @@ public void tupleIncorrectTopic1() {
209210

210211
@Test(expected = LogQueryException.class)
211212
public void quadroIncorrectOp1() {
212-
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
213+
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
213214
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
214-
null,
215+
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
215216
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
216-
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
217+
"0x72657075746174696f6e00000000000000000000000000000000000000000000");
218+
219+
topicQuadro
217220
.setOpTopic0_1(null)
218221
.setOpTopic0_2(LogOp.OR)
219222
.setOpTopic0_3(LogOp.AND)
220223
.setOpTopic1_2(LogOp.OR)
221224
.setOpTopic1_3(LogOp.OR)
222225
.setOpTopic2_3(LogOp.OR)
223226
.build();
224-
225-
assertNotNull(quadro);
226-
assertNotNull(quadro.getParams());
227227
}
228228

229229
@Test(expected = LogQueryException.class)
230230
public void quadroIncorrectOp2() {
231-
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
231+
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
232232
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
233-
null,
233+
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
234234
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
235-
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
236-
.setOpTopic0_1(LogOp.AND)
235+
"0x72657075746174696f6e00000000000000000000000000000000000000000000");
236+
237+
topicQuadro.setOpTopic0_1(LogOp.AND)
237238
.setOpTopic0_2(null)
238239
.setOpTopic0_3(LogOp.AND)
239240
.setOpTopic1_2(LogOp.OR)
240241
.setOpTopic1_3(LogOp.OR)
241242
.setOpTopic2_3(LogOp.OR)
242243
.build();
243-
244-
assertNotNull(quadro);
245-
assertNotNull(quadro.getParams());
246244
}
247245

248246
@Test(expected = LogQueryException.class)
249247
public void quadroIncorrectOp3() {
250-
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
248+
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
251249
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
252-
null,
250+
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
253251
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
254-
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
252+
"0x72657075746174696f6e00000000000000000000000000000000000000000000");
253+
254+
topicQuadro
255255
.setOpTopic0_1(LogOp.AND)
256256
.setOpTopic0_2(LogOp.OR)
257257
.setOpTopic0_3(null)
258258
.setOpTopic1_2(LogOp.OR)
259259
.setOpTopic1_3(LogOp.OR)
260260
.setOpTopic2_3(LogOp.OR)
261261
.build();
262-
263-
assertNotNull(quadro);
264-
assertNotNull(quadro.getParams());
265262
}
266263

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

286283
@Test(expected = LogQueryException.class)
287284
public void quadroInCorrectOp4() {
288-
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
285+
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
289286
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
290287
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
291-
"",
292-
"")
288+
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
289+
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545");
290+
291+
topicQuadro
293292
.setOpTopic0_1(LogOp.AND)
294293
.setOpTopic0_2(LogOp.OR)
295294
.setOpTopic0_3(LogOp.AND)
296295
.setOpTopic1_2(null)
297296
.setOpTopic1_3(LogOp.OR)
298297
.setOpTopic2_3(LogOp.OR)
299298
.build();
300-
301-
assertNotNull(quadro);
302-
assertNotNull(quadro.getParams());
303299
}
304300

305301
@Test(expected = LogQueryException.class)
306302
public void quadroInCorrectOp5() {
307-
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
303+
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
308304
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
309305
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
310-
"",
311-
"")
306+
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
307+
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545");
308+
309+
topicQuadro
312310
.setOpTopic0_1(LogOp.AND)
313311
.setOpTopic0_2(LogOp.OR)
314312
.setOpTopic0_3(LogOp.AND)
315313
.setOpTopic1_2(LogOp.AND)
316314
.setOpTopic1_3(null)
317315
.setOpTopic2_3(LogOp.OR)
318316
.build();
319-
320-
assertNotNull(quadro);
321-
assertNotNull(quadro.getParams());
322317
}
323318

324319
@Test(expected = LogQueryException.class)
325320
public void quadroInCorrectOp6() {
326-
LogQuery quadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
321+
LogTopicQuadro topicQuadro = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
327322
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
328323
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
329-
"",
330-
"")
324+
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
325+
"0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545");
326+
327+
topicQuadro
331328
.setOpTopic0_1(LogOp.AND)
332329
.setOpTopic0_2(LogOp.OR)
333330
.setOpTopic0_3(LogOp.AND)
334331
.setOpTopic1_2(LogOp.AND)
335332
.setOpTopic1_3(LogOp.OR)
336333
.setOpTopic2_3(null)
337334
.build();
338-
339-
assertNotNull(quadro);
340-
assertNotNull(quadro.getParams());
341335
}
342336

343337
@Test(expected = LogQueryException.class)

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ public class ProxyTxApiTest extends Assert {
2222
public void correctByHash() {
2323
Optional<TxProxy> tx = api.proxy().tx("0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1");
2424
assertTrue(tx.isPresent());
25-
assertNotNull(tx.get().getBlockHash());
26-
assertNotNull(tx.get().getFrom());
27-
assertNotNull(tx.get().getTo());
28-
assertNotNull(tx.get().getHash());
29-
assertNotNull(tx.get().getNonce());
25+
26+
TxProxy txProxy = tx.get();
27+
assertNotNull(txProxy.getBlockHash());
28+
assertNotNull(txProxy.getBlockNumber());
29+
assertNotNull(txProxy.getFrom());
30+
assertNotNull(txProxy.getTo());
31+
assertNotNull(txProxy.getHash());
32+
assertNotNull(txProxy.getNonce());
3033
}
3134

3235
@Test

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@ 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());
25+
26+
ReceiptProxy receiptProxy = infoProxy.get();
27+
assertNotNull(receiptProxy.getBlockHash());
28+
assertNotNull(receiptProxy.getRoot());
29+
assertNotNull(receiptProxy.getFrom());
30+
assertNotNull(receiptProxy.getTo());
31+
assertNotNull(receiptProxy.getBlockNumber());
32+
assertNotNull(receiptProxy.getBlockHash());
33+
assertNotNull(receiptProxy.getTransactionHash());
34+
assertNotNull(receiptProxy.getTransactionIndex());
35+
assertNotNull(receiptProxy.getGasUsed());
36+
assertNotNull(receiptProxy.getCumulativeGasUsed());
37+
assertNotNull(receiptProxy.getLogs());
38+
assertNotNull(receiptProxy.getLogsBloom());
39+
assertNull(receiptProxy.getContractAddress());
3840
}
3941

4042
@Test(expected = InvalidTxHashException.class)

src/test/java/io/api/util/UtilTests.java renamed to src/test/java/io/api/util/BasicUtilsTests.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.junit.Test;
99

1010
import java.util.ArrayList;
11+
import java.util.Collections;
1112
import java.util.List;
1213

1314
/**
@@ -16,7 +17,7 @@
1617
* @author GoodforGod
1718
* @since 13.11.2018
1819
*/
19-
public class UtilTests extends Assert {
20+
public class BasicUtilsTests extends Assert {
2021

2122
@Test(expected = EtherScanException.class)
2223
public void responseValidateEmpty() {
@@ -31,9 +32,16 @@ public void responseValidateNullable() {
3132
}
3233

3334
@Test
34-
public void partitionEmpty() {
35+
public void partitionNewArrayList() {
3536
ArrayList<String> list = new ArrayList<>();
3637
List<List<String>> lists = BasicUtils.partition(list, 12);
3738
assertTrue(lists.isEmpty());
3839
}
40+
41+
@Test
42+
public void partitionEmpty() {
43+
List<String> list = Collections.emptyList();
44+
List<List<String>> lists = BasicUtils.partition(list, 12);
45+
assertTrue(lists.isEmpty());
46+
}
3947
}

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