Skip to content

Commit 45454c3

Browse files
Merge pull request tronprotocol#2305 from tronprotocol/feature/add_TVMNewCommand_stest_back
modify testcase
2 parents b38e658 + cb03339 commit 45454c3

26 files changed

+136
-89
lines changed

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

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.HashMap;
2121
import java.util.List;
2222
import java.util.Map;
23-
import java.util.Objects;
2423
import java.util.Optional;
2524
import java.util.regex.Matcher;
2625
import java.util.regex.Pattern;
@@ -49,8 +48,6 @@
4948
import org.tron.common.crypto.Hash;
5049
import org.tron.common.utils.ByteArray;
5150
import org.tron.common.utils.ByteUtil;
52-
import org.tron.common.utils.Utils;
53-
5451
import org.tron.core.Wallet;
5552
import org.tron.keystore.WalletFile;
5653
import org.tron.protos.Contract;
@@ -61,7 +58,6 @@
6158
import org.tron.protos.Protocol;
6259
import org.tron.protos.Protocol.Account;
6360
import org.tron.protos.Protocol.Block;
64-
//import org.tron.protos.Protocol.DeferredTransaction;
6561
import org.tron.protos.Protocol.DelegatedResourceAccountIndex;
6662
import org.tron.protos.Protocol.Exchange;
6763
import org.tron.protos.Protocol.Key;
@@ -74,6 +70,8 @@
7470
import stest.tron.wallet.common.client.Parameter.CommonConstant;
7571
import stest.tron.wallet.common.client.WalletClient;
7672

73+
//import org.tron.protos.Protocol.DeferredTransaction;
74+
7775

7876
public class PublicMethed {
7977

@@ -3061,13 +3059,10 @@ public static String triggerContract(byte[] contractAddress, String method, Stri
30613059
/**
30623060
* constructor.
30633061
*/
3064-
3065-
public static String triggerParamListContract(byte[] contractAddress, String method,
3066-
List<Object> params,
3062+
public static String triggerContract(byte[] contractAddress, String method, String argsStr,
30673063
Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue,
30683064
byte[] ownerAddress,
30693065
String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) {
3070-
30713066
Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET);
30723067
ECKey temKey = null;
30733068
try {
@@ -3077,9 +3072,13 @@ public static String triggerParamListContract(byte[] contractAddress, String met
30773072
ex.printStackTrace();
30783073
}
30793074
final ECKey ecKey = temKey;
3075+
if (argsStr.equalsIgnoreCase("#")) {
3076+
logger.info("argsstr is #");
3077+
argsStr = "";
3078+
}
30803079

30813080
byte[] owner = ownerAddress;
3082-
byte[] input = Hex.decode(AbiUtil.parseMethod(method, params));
3081+
byte[] input = Hex.decode(AbiUtil.parseMethod(method, argsStr, isHex));
30833082

30843083
Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder();
30853084
builder.setOwnerAddress(ByteString.copyFrom(owner));
@@ -3152,18 +3151,18 @@ public static String triggerParamListContract(byte[] contractAddress, String met
31523151
} else {
31533152
return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()));
31543153
}
3155-
3156-
31573154
}
31583155

31593156
/**
31603157
* constructor.
31613158
*/
31623159

3163-
public static String triggerContract(byte[] contractAddress, String method, String argsStr,
3160+
public static String triggerParamListContract(byte[] contractAddress, String method,
3161+
List<Object> params,
31643162
Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue,
31653163
byte[] ownerAddress,
31663164
String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) {
3165+
31673166
Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET);
31683167
ECKey temKey = null;
31693168
try {
@@ -3173,13 +3172,9 @@ public static String triggerContract(byte[] contractAddress, String method, Stri
31733172
ex.printStackTrace();
31743173
}
31753174
final ECKey ecKey = temKey;
3176-
if (argsStr.equalsIgnoreCase("#")) {
3177-
logger.info("argsstr is #");
3178-
argsStr = "";
3179-
}
31803175

31813176
byte[] owner = ownerAddress;
3182-
byte[] input = Hex.decode(AbiUtil.parseMethod(method, argsStr, isHex));
3177+
byte[] input = Hex.decode(AbiUtil.parseMethod(method, params));
31833178

31843179
Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder();
31853180
builder.setOwnerAddress(ByteString.copyFrom(owner));
@@ -3252,6 +3247,8 @@ public static String triggerContract(byte[] contractAddress, String method, Stri
32523247
} else {
32533248
return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()));
32543249
}
3250+
3251+
32553252
}
32563253

32573254
/**
@@ -4488,6 +4485,9 @@ public static HashMap<String, String> getBycodeAbiForLibrary(String solFile,
44884485
return retMap;
44894486
}
44904487

4488+
/**
4489+
* constructor.
4490+
*/
44914491
public static String triggerConstantContract(byte[] contractAddress, String method,
44924492
String argsStr,
44934493
Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue,
@@ -4584,7 +4584,10 @@ public static String triggerConstantContract(byte[] contractAddress, String meth
45844584
}
45854585
}
45864586

4587-
public static String clearContractABI(byte[] contractAddress,
4587+
/**
4588+
* constructor.
4589+
*/
4590+
public static String clearContractAbi(byte[] contractAddress,
45884591
byte[] ownerAddress,
45894592
String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) {
45904593
Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET);
@@ -4604,10 +4607,10 @@ public static String clearContractABI(byte[] contractAddress,
46044607
builder.setOwnerAddress(ByteString.copyFrom(owner));
46054608
builder.setContractAddress(ByteString.copyFrom(contractAddress));
46064609

4607-
Contract.ClearABIContract clearABIContract = builder.build();
4610+
Contract.ClearABIContract clearAbiContract = builder.build();
46084611

46094612
TransactionExtention transactionExtention = blockingStubFull
4610-
.clearContractABI(clearABIContract);
4613+
.clearContractABI(clearAbiContract);
46114614
if (transactionExtention == null || !transactionExtention.getResult().getResult()) {
46124615
System.out.println("RPC create call trx failed!");
46134616
System.out.println("Code = " + transactionExtention.getResult().getCode());
@@ -4670,8 +4673,10 @@ public static String clearContractABI(byte[] contractAddress,
46704673
}
46714674
}
46724675

4673-
4674-
public static TransactionExtention clearContractABIForExtention(byte[] contractAddress,
4676+
/**
4677+
* constructor.
4678+
*/
4679+
public static TransactionExtention clearContractAbiForExtention(byte[] contractAddress,
46754680
byte[] ownerAddress,
46764681
String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) {
46774682
Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET);
@@ -4691,15 +4696,17 @@ public static TransactionExtention clearContractABIForExtention(byte[] contractA
46914696
builder.setOwnerAddress(ByteString.copyFrom(owner));
46924697
builder.setContractAddress(ByteString.copyFrom(contractAddress));
46934698

4694-
Contract.ClearABIContract clearABIContract = builder.build();
4699+
Contract.ClearABIContract clearAbiContract = builder.build();
46954700

46964701
TransactionExtention transactionExtention = blockingStubFull
4697-
.clearContractABI(clearABIContract);
4702+
.clearContractABI(clearAbiContract);
46984703
return transactionExtention;
46994704

47004705
}
47014706

4702-
4707+
/**
4708+
* constructor.
4709+
*/
47034710
public static TransactionExtention triggerConstantContractForExtention(byte[] contractAddress,
47044711
String method,
47054712
String argsStr,
@@ -4778,6 +4785,9 @@ public static TransactionExtention triggerContractForExtention(byte[] contractAd
47784785

47794786
}
47804787

4788+
/**
4789+
* constructor.
4790+
*/
47814791
public static String create2(String[] parameters) {
47824792
if (parameters == null || parameters.length != 3) {
47834793
logger.error("create2 needs 3 parameter:\ncreate2 address code salt");

src/test/java/stest/tron/wallet/common/client/utils/PublicMethedForMutiSign.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4512,7 +4512,7 @@ public static Boolean exchangeCreate1(byte[] firstTokenId, long firstTokenBalanc
45124512
}
45134513

45144514

4515-
public static boolean clearContractABI(byte[] contractAddress,
4515+
public static boolean clearContractAbi(byte[] contractAddress,
45164516
byte[] ownerAddress,
45174517
String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId,
45184518
String[] permissionKeyString) {

src/test/java/stest/tron/wallet/dailybuild/http/HttpTestClearABIContract001.java renamed to src/test/java/stest/tron/wallet/dailybuild/http/HttpTestClearAbiContract001.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import stest.tron.wallet.common.client.utils.PublicMethed;
1818

1919
@Slf4j
20-
public class HttpTestClearABIContract001 {
20+
public class HttpTestClearAbiContract001 {
2121

2222
private final String testKey002 = Configuration.getByPath("testng.conf")
2323
.getString("foundationAccount.key1");
@@ -100,8 +100,8 @@ public void test2GetContract() {
100100
Assert.assertEquals(responseContent.getString("origin_address"),
101101
ByteArray.toHexString(assetOwnerAddress));
102102
Assert
103-
.assertThat(responseContent.getString("abi")
104-
, containsString("testView"));
103+
.assertThat(responseContent.getString("abi"),
104+
containsString("testView"));
105105

106106
Assert.assertEquals(responseContent.getString("origin_energy_limit"), "11111111111111");
107107
Assert.assertEquals(responseContent.getString("name"), contractName);
@@ -129,7 +129,7 @@ public void test3TriggerConstantContract() {
129129
* constructor.
130130
*/
131131
@Test(enabled = true, description = "Trigger contract by http")
132-
public void test4ClearABIContract() {
132+
public void test4ClearAbiContract() {
133133

134134
HttpResponse httpResponse = HttpMethed
135135
.clearABiGetTxid(httpnode, assetOwnerAddress, contractAddress, assetOwnerKey);

src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign018.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void test1MutiSignForClearContractAbi() {
162162
SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull);
163163
Assert.assertTrue(smartContract.getAbi().toString() != null);
164164
Assert.assertTrue(PublicMethedForMutiSign
165-
.clearContractABI(contractAddress, ownerAddress, ownerKey,
165+
.clearContractAbi(contractAddress, ownerAddress, ownerKey,
166166
blockingStubFull, 2, permissionKeyString));
167167
PublicMethed.waitProduceNextBlock(blockingStubFull);
168168

@@ -240,7 +240,7 @@ public void test2MutiSignForClearContractAbiForDefault() {
240240
SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull);
241241
Assert.assertTrue(smartContract.getAbi().toString() != null);
242242
Assert.assertTrue(PublicMethedForMutiSign
243-
.clearContractABI(contractAddress, ownerAddress, ownerKey,
243+
.clearContractAbi(contractAddress, ownerAddress, ownerKey,
244244
blockingStubFull, 2, permissionKeyString));
245245
PublicMethed.waitProduceNextBlock(blockingStubFull);
246246

@@ -295,7 +295,7 @@ public void test3MutiSignForClearContractAbiForDefault() {
295295
SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull);
296296
Assert.assertTrue(smartContract.getAbi().toString() != null);
297297
Assert.assertTrue(PublicMethedForMutiSign
298-
.clearContractABI(contractAddress, ownerAddress, ownerKey,
298+
.clearContractAbi(contractAddress, ownerAddress, ownerKey,
299299
blockingStubFull, 2, activeDefaultKeyString));
300300
PublicMethed.waitProduceNextBlock(blockingStubFull);
301301

src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken014.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ public void test03TriggerContract() {
456456
"transferTokenTest(address,uint256,trcToken)", param, false, 0,
457457
1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key,
458458
blockingStubFull);
459-
459+
PublicMethed.waitProduceNextBlock(blockingStubFull);
460460
infoById = PublicMethed
461461
.getTransactionInfoById(triggerTxid, blockingStubFull);
462462
Assert.assertTrue(infoById.get().getResultValue() != 0);
@@ -480,7 +480,7 @@ public void test03TriggerContract() {
480480
"transferTokenTest(address,uint256,trcToken)", param, false, 0,
481481
1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key,
482482
blockingStubFull);
483-
483+
PublicMethed.waitProduceNextBlock(blockingStubFull);
484484
infoById = PublicMethed
485485
.getTransactionInfoById(triggerTxid, blockingStubFull);
486486
Assert.assertTrue(infoById.get().getResultValue() != 0);
@@ -504,7 +504,7 @@ public void test03TriggerContract() {
504504
"transferTokenTest(address,uint256,trcToken)", param, false, 0,
505505
1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key,
506506
blockingStubFull);
507-
507+
PublicMethed.waitProduceNextBlock(blockingStubFull);
508508
infoById = PublicMethed
509509
.getTransactionInfoById(triggerTxid, blockingStubFull);
510510
Assert.assertTrue(infoById.get().getResultValue() != 0);
@@ -551,7 +551,7 @@ public void test03TriggerContract() {
551551
"transferTokenTest(address,uint256,trcToken)", param, false, callValue,
552552
1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key,
553553
blockingStubFull);
554-
554+
PublicMethed.waitProduceNextBlock(blockingStubFull);
555555
infoById = PublicMethed
556556
.getTransactionInfoById(triggerTxid, blockingStubFull);
557557
Assert.assertTrue(infoById.get().getResultValue() != 0);

src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken064.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public void test01DeployTransferTokenContract() {
9898
ByteString.copyFrom(dev001Address), testKey002, blockingStubFull));
9999
Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L,
100100
0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull));
101-
PublicMethed.waitProduceNextBlock(blockingStubFull);
102101

103102
long start = System.currentTimeMillis() + 2000;
104103
long end = System.currentTimeMillis() + 1000000000;
@@ -341,6 +340,7 @@ public void test03TriggerContract() {
341340
1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key,
342341
blockingStubFull);
343342

343+
PublicMethed.waitProduceNextBlock(blockingStubFull);
344344
infoById = PublicMethed
345345
.getTransactionInfoById(triggerTxid, blockingStubFull);
346346

@@ -360,7 +360,7 @@ public void test03TriggerContract() {
360360
"transferTokenTest(address,uint256,trcToken)", param, false, callValue,
361361
1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key,
362362
blockingStubFull);
363-
363+
PublicMethed.waitProduceNextBlock(blockingStubFull);
364364
infoById = PublicMethed
365365
.getTransactionInfoById(triggerTxid, blockingStubFull);
366366

@@ -380,7 +380,7 @@ public void test03TriggerContract() {
380380
"transferTokenTest(address,uint256,trcToken)", param, false, callValue,
381381
1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key,
382382
blockingStubFull);
383-
383+
PublicMethed.waitProduceNextBlock(blockingStubFull);
384384
infoById = PublicMethed
385385
.getTransactionInfoById(triggerTxid, blockingStubFull);
386386

@@ -400,7 +400,7 @@ public void test03TriggerContract() {
400400
"transferTokenTest(address,uint256,trcToken)", param, false, callValue,
401401
1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key,
402402
blockingStubFull);
403-
403+
PublicMethed.waitProduceNextBlock(blockingStubFull);
404404
infoById = PublicMethed
405405
.getTransactionInfoById(triggerTxid, blockingStubFull);
406406

@@ -417,7 +417,7 @@ public void test03TriggerContract() {
417417
"transferTokenTestValueMaxLong(address)", param, false, callValue,
418418
1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key,
419419
blockingStubFull);
420-
420+
PublicMethed.waitProduceNextBlock(blockingStubFull);
421421
infoById = PublicMethed
422422
.getTransactionInfoById(triggerTxid, blockingStubFull);
423423
Assert.assertTrue(infoById.get().getResultValue() != 0);
@@ -433,6 +433,7 @@ public void test03TriggerContract() {
433433
"transferTokenTestValueMaxLong(address)", param, false, callValue,
434434
1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key,
435435
blockingStubFull);
436+
PublicMethed.waitProduceNextBlock(blockingStubFull);
436437

437438
infoById = PublicMethed
438439
.getTransactionInfoById(triggerTxid, blockingStubFull);

0 commit comments

Comments
 (0)