Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit14ccb53

Browse files
committed
[2.0.0-SNAPSHOT]
Test asserts fixedLog contract improvedTests reinforced
1 parent1416a23 commit14ccb53

File tree

7 files changed

+138
-27
lines changed

7 files changed

+138
-27
lines changed

‎src/main/java/io/goodforgod/api/etherscan/model/EthSupply.java‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
importjava.util.Objects;
55

66
/**
7-
* Please Add Description Here.
8-
*
97
* @author Anton Kurako (GoodforGod)
108
* @since 14.05.2023
119
*/
@@ -100,10 +98,26 @@ public EthSupplyBuilder withWithdrawnTotal(Wei withdrawnTotal) {
10098

10199
publicEthSupplybuild() {
102100
EthSupplyethSupply =newEthSupply();
103-
ethSupply.BurntFees =this.burntFees.toString();
104-
ethSupply.Eth2Staking =this.eth2Staking.toString();
105-
ethSupply.EthSupply =this.ethSupply.toString();
106-
ethSupply.WithdrawnTotal =this.withdrawnTotal.toString();
101+
if (this.burntFees !=null) {
102+
ethSupply.BurntFees =this.burntFees.toString();
103+
}else {
104+
ethSupply.BurntFees =BigInteger.ZERO.toString();
105+
}
106+
if (this.eth2Staking !=null) {
107+
ethSupply.Eth2Staking =this.eth2Staking.toString();
108+
}else {
109+
ethSupply.Eth2Staking =BigInteger.ZERO.toString();
110+
}
111+
if (this.ethSupply !=null) {
112+
ethSupply.EthSupply =this.ethSupply.toString();
113+
}else {
114+
ethSupply.EthSupply =BigInteger.ZERO.toString();
115+
}
116+
if (this.withdrawnTotal !=null) {
117+
ethSupply.WithdrawnTotal =this.withdrawnTotal.toString();
118+
}else {
119+
ethSupply.WithdrawnTotal =BigInteger.ZERO.toString();
120+
}
107121
returnethSupply;
108122
}
109123
}

‎src/main/java/io/goodforgod/api/etherscan/model/Log.java‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
importcom.google.gson.annotations.Expose;
44
importio.goodforgod.api.etherscan.util.BasicUtils;
5-
importjava.math.BigInteger;
65
importjava.time.LocalDateTime;
76
importjava.time.ZoneOffset;
87
importjava.util.List;
@@ -28,10 +27,10 @@ public class Log {
2827
privateStringdata;
2928
privateStringgasPrice;
3029
@Expose(deserialize =false,serialize =false)
31-
privateBigInteger_gasPrice;
30+
privateWei_gasPrice;
3231
privateStringgasUsed;
3332
@Expose(deserialize =false,serialize =false)
34-
privateBigInteger_gasUsed;
33+
privateWei_gasUsed;
3534
privateList<String>topics;
3635
privateStringlogIndex;
3736
@Expose(deserialize =false,serialize =false)
@@ -93,17 +92,17 @@ public String getData() {
9392
returndata;
9493
}
9594

96-
publicBigIntegergetGasPrice() {
95+
publicWeigetGasPrice() {
9796
if (!BasicUtils.isEmpty(gasPrice)) {
98-
_gasPrice =BasicUtils.parseHex(gasPrice);
97+
_gasPrice =Wei.ofWei(BasicUtils.parseHex(gasPrice));
9998
}
10099

101100
return_gasPrice;
102101
}
103102

104-
publicBigIntegergetGasUsed() {
103+
publicWeigetGasUsed() {
105104
if (!BasicUtils.isEmpty(gasUsed)) {
106-
_gasUsed =BasicUtils.parseHex(gasUsed);
105+
_gasUsed =Wei.ofWei(BasicUtils.parseHex(gasUsed));
107106
}
108107

109108
return_gasUsed;
@@ -172,8 +171,8 @@ public static final class LogBuilder {
172171
privateLongtransactionIndex;
173172
privateLocalDateTimetimeStamp;
174173
privateStringdata;
175-
privateBigIntegergasPrice;
176-
privateBigIntegergasUsed;
174+
privateWeigasPrice;
175+
privateWeigasUsed;
177176
privateList<String>topics;
178177
privateLonglogIndex;
179178

@@ -209,12 +208,12 @@ public LogBuilder withData(String data) {
209208
returnthis;
210209
}
211210

212-
publicLogBuilderwithGasPrice(BigIntegergasPrice) {
211+
publicLogBuilderwithGasPrice(WeigasPrice) {
213212
this.gasPrice =gasPrice;
214213
returnthis;
215214
}
216215

217-
publicLogBuilderwithGasUsed(BigIntegergasUsed) {
216+
publicLogBuilderwithGasUsed(WeigasUsed) {
218217
this.gasUsed =gasUsed;
219218
returnthis;
220219
}
@@ -233,7 +232,6 @@ public Log build() {
233232
Loglog =newLog();
234233
log.address =this.address;
235234
if (this.gasPrice !=null) {
236-
log.gasPrice =String.valueOf(this.gasPrice);
237235
log._gasPrice =this.gasPrice;
238236
}
239237
log._logIndex =this.logIndex;
@@ -246,7 +244,6 @@ public Log build() {
246244
}
247245
log.data =this.data;
248246
if (this.gasUsed !=null) {
249-
log.gasUsed =String.valueOf(this.gasUsed);
250247
log._gasUsed =this.gasUsed;
251248
}
252249
log.logIndex =String.valueOf(this.logIndex);

‎src/test/java/io/goodforgod/api/etherscan/account/AccountTxErc20Tests.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private void assertTxs(List<TxErc20> txs) {
7171
assertNotNull(tx.getTokenDecimal());
7272
assertNotEquals(-1, (tx.getConfirmations()));
7373
assertNotNull(tx.getGasUsed());
74-
assertNotEquals(-1,tx.getGasUsedCumulative());
74+
assertNotEquals(-1,tx.getGasUsedCumulative().asWei().intValue());
7575
assertNotEquals(-1,tx.getTransactionIndex());
7676
}
7777
}

‎src/test/java/io/goodforgod/api/etherscan/account/AccountTxRc1155TokenTests.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void correct() {
1818
assertNotNull(txs);
1919
assertFalse(txs.isEmpty());
2020
assertTxs(txs);
21-
assertNotEquals(0,txs.get(0).getGasPrice());
21+
assertNotEquals(0,txs.get(0).getGasPrice().asWei().intValue());
2222
assertNotEquals(-1,txs.get(0).getNonce());
2323

2424
assertNotNull(txs.get(0).toString());
@@ -75,7 +75,7 @@ private void asserTx(TxErc1155 tx) {
7575
assertNotNull(tx.getTokenValue());
7676
assertNotEquals(-1, (tx.getConfirmations()));
7777
assertNotNull(tx.getGasUsed());
78-
assertNotEquals(-1,tx.getGasUsedCumulative());
78+
assertNotEquals(-1,tx.getGasUsedCumulative().asWei().intValue());
7979
assertNotEquals(-1,tx.getTransactionIndex());
8080
}
8181
}

‎src/test/java/io/goodforgod/api/etherscan/account/AccountTxRc721TokenTests.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void correct() {
1818
assertNotNull(txs);
1919
assertEquals(16,txs.size());
2020
assertTxs(txs);
21-
assertNotEquals(0,txs.get(0).getGasPrice());
21+
assertNotEquals(0,txs.get(0).getGasPrice().asWei().intValue());
2222
assertNotEquals(-1,txs.get(0).getNonce());
2323

2424
assertNotNull(txs.get(0).toString());
@@ -73,7 +73,7 @@ private void assertTxs(List<TxErc721> txs) {
7373
assertNotNull(tx.getTokenDecimal());
7474
assertNotEquals(-1, (tx.getConfirmations()));
7575
assertNotNull(tx.getGasUsed());
76-
assertNotEquals(-1,tx.getGasUsedCumulative());
76+
assertNotEquals(-1,tx.getGasUsedCumulative().asWei().intValue());
7777
assertNotEquals(-1,tx.getTransactionIndex());
7878
}
7979
}

‎src/test/java/io/goodforgod/api/etherscan/model/ModelBuilderTests.java‎

Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
packageio.goodforgod.api.etherscan.model;
22

3+
importio.goodforgod.api.etherscan.model.proxy.BlockProxy;
4+
importio.goodforgod.api.etherscan.model.proxy.ReceiptProxy;
5+
importio.goodforgod.api.etherscan.model.proxy.TxProxy;
36
importjava.math.BigDecimal;
47
importjava.math.BigInteger;
58
importjava.time.LocalDateTime;
9+
importjava.util.Arrays;
610
importjava.util.Collections;
711
importorg.junit.jupiter.api.Assertions;
812
importorg.junit.jupiter.api.Test;
@@ -84,8 +88,8 @@ void logBuilder() {
8488
.withAddress("1")
8589
.withBlockNumber(1L)
8690
.withData("1")
87-
.withGasPrice(BigInteger.ONE)
88-
.withGasUsed(BigInteger.ONE)
91+
.withGasPrice(Wei.ofWei(1))
92+
.withGasUsed(Wei.ofWei(1))
8993
.withLogIndex(1L)
9094
.withTimeStamp(timestamp)
9195
.withTransactionHash("1")
@@ -268,4 +272,100 @@ void txInternalBuilder() {
268272
assertEquals("1",value.getTo());
269273
assertEquals("1",value.getFrom());
270274
}
275+
276+
@Test
277+
voidethSupplyBuilder() {
278+
EthSupplyvalue =EthSupply.builder()
279+
.withBurntFees(Wei.ofWei(1))
280+
.withEth2Staking(Wei.ofWei(1))
281+
.withEthSupply(Wei.ofWei(1))
282+
.withWithdrawnTotal(Wei.ofWei(1))
283+
.build();
284+
285+
assertNotNull(value);
286+
assertEquals(BigInteger.valueOf(1),value.getTotal().asWei());
287+
288+
EthSupplyvalueEmpty =EthSupply.builder()
289+
.build();
290+
assertNotNull(valueEmpty);
291+
assertEquals(BigInteger.ZERO,valueEmpty.getTotal().asWei());
292+
}
293+
294+
@Test
295+
voidreceiptProxyBuilder() {
296+
LocalDateTimetimestamp =LocalDateTime.now();
297+
ReceiptProxyvalue =ReceiptProxy.builder()
298+
.withBlockHash("1")
299+
.withBlockNumber(1L)
300+
.withContractAddress("1")
301+
.withCumulativeGasUsed(Wei.ofWei(1))
302+
.withFrom("1")
303+
.withTo("1")
304+
.withGasUsed(Wei.ofWei(1))
305+
.withRoot("1")
306+
.withLogsBloom("1")
307+
.withTransactionHash("1")
308+
.withTransactionIndex(1L)
309+
.withLogs(Arrays.asList(Log.builder()
310+
.withTopics(Arrays.asList("1"))
311+
.withTransactionIndex(1L)
312+
.withTransactionHash("1")
313+
.withTimeStamp(timestamp)
314+
.withLogIndex(1L)
315+
.withGasUsed(Wei.ofWei(1))
316+
.withGasPrice(Wei.ofWei(1))
317+
.withData("1")
318+
.withAddress("1")
319+
.build()))
320+
.build();
321+
322+
assertNotNull(value);
323+
assertEquals(BigInteger.valueOf(1),value.getGasUsed().asWei());
324+
}
325+
326+
@Test
327+
voidblockProxyBuilder() {
328+
LocalDateTimetimestamp =LocalDateTime.now();
329+
BlockProxyvalue =BlockProxy.builder()
330+
.withGasUsed(Wei.ofWei(1))
331+
.withLogsBloom("1")
332+
.withDifficulty("1")
333+
.withExtraData("1")
334+
.withGasLimit(Wei.ofWei(1))
335+
.withHash("1")
336+
.withMiner("1")
337+
.withMixHash("1")
338+
.withNonce("1")
339+
.withNumber(1L)
340+
.withParentHash("1")
341+
.withReceiptsRoot("1")
342+
.withSha3Uncles("1")
343+
.withSize(1L)
344+
.withStateRoot("1")
345+
.withTimestamp(timestamp)
346+
.withTotalDifficulty("1")
347+
.withTransactionsRoot("1")
348+
.withUncles(Arrays.asList("1"))
349+
.withTransactions(Arrays.asList(TxProxy.builder()
350+
.withBlockHash("1")
351+
.withBlockNumber(1L)
352+
.withFrom("1")
353+
.withGas(Wei.ofWei(1))
354+
.withGasPrice(Wei.ofWei(1))
355+
.withHash("1")
356+
.withInput("1")
357+
.withNonce(1L)
358+
.withR("1")
359+
.withS("1")
360+
.withTo("1")
361+
.withTransactionIndex(1L)
362+
.withV("1")
363+
.withValue("1")
364+
.withV("1")
365+
.build()))
366+
.build();
367+
368+
assertNotNull(value);
369+
assertEquals(BigInteger.valueOf(1),value.getGasUsed().asWei());
370+
}
271371
}

‎src/test/java/io/goodforgod/api/etherscan/statistic/StatisticTokenSupplyApiTests.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class StatisticTokenSupplyApiTests extends ApiRunner {
1616
voidcorrect() {
1717
Weisupply =getApi().stats().supply("0x57d90b64a1a57749b0f932f1a3395792e12e7055");
1818
assertNotNull(supply);
19-
assertNotEquals(BigInteger.ZERO,supply);
19+
assertNotEquals(BigInteger.ZERO,supply.asWei());
2020
}
2121

2222
@Test

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp