Skip to content

Commit eafadc1

Browse files
committed
modify stest and open multi sign
1 parent 20b6c31 commit eafadc1

5 files changed

Lines changed: 29 additions & 18 deletions

File tree

‎src/test/java/stest/tron/wallet/common/client/utils/PublicMethed.java‎

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,21 +1953,21 @@ public static SmartContract.ABI jsonStr2Abi(String jsonStr) {
19531953
for (int index = 0; index < jsonRoot.size(); index++) {
19541954
JsonElement abiItem = jsonRoot.get(index);
19551955
boolean anonymous = abiItem.getAsJsonObject().get("anonymous") != null
1956-
? abiItem.getAsJsonObject().get("anonymous").getAsBoolean() : false;
1956+
? abiItem.getAsJsonObject().get("anonymous").getAsBoolean() : false;
19571957
final boolean constant = abiItem.getAsJsonObject().get("constant") != null
1958-
? abiItem.getAsJsonObject().get("constant").getAsBoolean() : false;
1958+
? abiItem.getAsJsonObject().get("constant").getAsBoolean() : false;
19591959
final String name = abiItem.getAsJsonObject().get("name") != null
1960-
? abiItem.getAsJsonObject().get("name").getAsString() : null;
1960+
? abiItem.getAsJsonObject().get("name").getAsString() : null;
19611961
JsonArray inputs = abiItem.getAsJsonObject().get("inputs") != null
1962-
? abiItem.getAsJsonObject().get("inputs").getAsJsonArray() : null;
1962+
? abiItem.getAsJsonObject().get("inputs").getAsJsonArray() : null;
19631963
final JsonArray outputs = abiItem.getAsJsonObject().get("outputs") != null
1964-
? abiItem.getAsJsonObject().get("outputs").getAsJsonArray() : null;
1964+
? abiItem.getAsJsonObject().get("outputs").getAsJsonArray() : null;
19651965
String type = abiItem.getAsJsonObject().get("type") != null
1966-
? abiItem.getAsJsonObject().get("type").getAsString() : null;
1966+
? abiItem.getAsJsonObject().get("type").getAsString() : null;
19671967
final boolean payable = abiItem.getAsJsonObject().get("payable") != null
1968-
? abiItem.getAsJsonObject().get("payable").getAsBoolean() : false;
1968+
? abiItem.getAsJsonObject().get("payable").getAsBoolean() : false;
19691969
final String stateMutability = abiItem.getAsJsonObject().get("stateMutability") != null
1970-
? abiItem.getAsJsonObject().get("stateMutability").getAsString() : null;
1970+
? abiItem.getAsJsonObject().get("stateMutability").getAsString() : null;
19711971
if (type == null) {
19721972
logger.error("No type!");
19731973
return null;
@@ -1989,15 +1989,17 @@ public static SmartContract.ABI jsonStr2Abi(String jsonStr) {
19891989
for (int j = 0; j < inputs.size(); j++) {
19901990
JsonElement inputItem = inputs.get(j);
19911991
if (inputItem.getAsJsonObject().get("name") == null
1992-
|| inputItem.getAsJsonObject().get("type") == null) {
1992+
|| inputItem.getAsJsonObject().get("type") == null) {
19931993
logger.error("Input argument invalid due to no name or no type!");
19941994
return null;
19951995
}
19961996
String inputName = inputItem.getAsJsonObject().get("name").getAsString();
19971997
String inputType = inputItem.getAsJsonObject().get("type").getAsString();
19981998
SmartContract.ABI.Entry.Param.Builder paramBuilder = SmartContract.ABI.Entry.Param
1999-
.newBuilder();
2000-
paramBuilder.setIndexed(false);
1999+
.newBuilder();
2000+
JsonElement indexed = inputItem.getAsJsonObject().get("indexed");
2001+
2002+
paramBuilder.setIndexed((indexed == null)?false: indexed.getAsBoolean());
20012003
paramBuilder.setName(inputName);
20022004
paramBuilder.setType(inputType);
20032005
entryBuilder.addInputs(paramBuilder.build());
@@ -2009,15 +2011,17 @@ public static SmartContract.ABI jsonStr2Abi(String jsonStr) {
20092011
for (int k = 0; k < outputs.size(); k++) {
20102012
JsonElement outputItem = outputs.get(k);
20112013
if (outputItem.getAsJsonObject().get("name") == null
2012-
|| outputItem.getAsJsonObject().get("type") == null) {
2014+
|| outputItem.getAsJsonObject().get("type") == null) {
20132015
logger.error("Output argument invalid due to no name or no type!");
20142016
return null;
20152017
}
20162018
String outputName = outputItem.getAsJsonObject().get("name").getAsString();
20172019
String outputType = outputItem.getAsJsonObject().get("type").getAsString();
20182020
SmartContract.ABI.Entry.Param.Builder paramBuilder = SmartContract.ABI.Entry.Param
2019-
.newBuilder();
2020-
paramBuilder.setIndexed(false);
2021+
.newBuilder();
2022+
JsonElement indexed = outputItem.getAsJsonObject().get("indexed");
2023+
2024+
paramBuilder.setIndexed((indexed == null)?false: indexed.getAsBoolean());
20212025
paramBuilder.setName(outputName);
20222026
paramBuilder.setType(outputType);
20232027
entryBuilder.addOutputs(paramBuilder.build());

‎src/test/java/stest/tron/wallet/contract/grammar/ContractGrammar003.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ public void testGrammar019() {
486486
"timetest()", "#", false,
487487
0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull);
488488
PublicMethed.waitProduceNextBlock(blockingStubFull);
489+
PublicMethed.waitProduceNextBlock(blockingStubFull1);
489490
Optional<TransactionInfo> infoById = null;
490491
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull1);
491492
Assert.assertTrue(infoById.get().getResultValue() == 0);

‎src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage005.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,27 @@ public void testEnergyCostDetail() {
8888
Assert.assertTrue(PublicMethed.sendcoin(linkage005Address, 5000000000000L, fromAddress,
8989
testKey003, blockingStubFull));
9090
Integer times = 0;
91-
while (!PublicMethed.freezeBalance(linkage005Address, 200000000000L,
91+
while (!PublicMethed.freezeBalance(linkage005Address, 250000000000L,
9292
3, linkage005Key, blockingStubFull)) {
9393
times++;
9494
if (times == 3) {
9595
break;
9696
}
9797
try {
98-
Thread.sleep(500);
98+
Thread.sleep(1500);
9999
} catch (InterruptedException e) {
100100
e.printStackTrace();
101101
}
102102
}
103103
times = 0;
104-
while (!PublicMethed.freezeBalanceGetEnergy(linkage005Address, 200000000000L,
104+
while (!PublicMethed.freezeBalanceGetEnergy(linkage005Address, 250000000000L,
105105
3, 1, linkage005Key, blockingStubFull)) {
106106
times++;
107107
if (times == 3) {
108108
break;
109109
}
110110
try {
111-
Thread.sleep(500);
111+
Thread.sleep(1500);
112112
} catch (InterruptedException e) {
113113
e.printStackTrace();
114114
}

‎src/test/java/stest/tron/wallet/contract/scenario/ContractScenario012.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public void triggerTransactionCoin() {
9898
txid = PublicMethed.triggerContract(contractAddress,
9999
"sendToAddress2(address)", receiveAddress, false,
100100
0, 100000000L, contract012Address, contract012Key, blockingStubFull);
101+
PublicMethed.waitProduceNextBlock(blockingStubFull);
101102
logger.info(txid);
102103
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
103104
Assert.assertTrue(infoById.get().getResultValue() == 1);
@@ -115,6 +116,7 @@ public void triggerTransactionCoin() {
115116
txid = PublicMethed.triggerContract(contractAddress,
116117
"sendToAddress2(address)", receiveAddress, false,
117118
0, 100000000L, contract012Address, contract012Key, blockingStubFull);
119+
PublicMethed.waitProduceNextBlock(blockingStubFull);
118120
logger.info(txid);
119121
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
120122
logger.info("result is " + infoById.get().getResultValue());
@@ -126,9 +128,11 @@ public void triggerTransactionCoin() {
126128
//This time, trigger the methed sendToAddress2 is OK.
127129
Assert.assertTrue(PublicMethed.sendcoin(receiverAddress,10000000L,fromAddress,
128130
testKey002,blockingStubFull));
131+
PublicMethed.waitProduceNextBlock(blockingStubFull);
129132
txid = PublicMethed.triggerContract(contractAddress,
130133
"sendToAddress2(address)", receiveAddress, false,
131134
0, 100000000L, contract012Address, contract012Key, blockingStubFull);
135+
PublicMethed.waitProduceNextBlock(blockingStubFull);
132136
logger.info(txid);
133137
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
134138
logger.info("result is " + infoById.get().getResultValue());

‎src/test/resources/testng.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<packages>
1010
<package name="stest.tron.wallet.transfer">
1111
</package>
12+
<package name="stest.tron.wallet.mutisign">
13+
</package>
1214
</packages>
1315
</test>
1416
<test name="Stest account">

0 commit comments

Comments
 (0)