Skip to content

Commit 8cea443

Browse files
author
wangzihe
committed
Modify stest case
1 parent f6ad81a commit 8cea443

10 files changed

Lines changed: 152 additions & 18 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void beforeClass() {
5555
testKey003,blockingStubFull));
5656
}
5757

58-
@Test(enabled = false)
58+
@Test(enabled = true)
5959
public void deployWhenNoEnergyAndNoStorage() {
6060
AccountResourceMessage accountResource = PublicMethed.getAccountResource(linkage003Address,
6161
blockingStubFull);

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class ContractLinkage004 {
3838
String contractName;
3939
String code;
4040
String abi;
41+
Long currentFee;
4142

4243
ECKey ecKey1 = new ECKey(Utils.getRandom());
4344
byte[] linkage004Address = ecKey1.getAddress();
@@ -56,7 +57,7 @@ public void beforeClass() {
5657
.usePlaintext(true)
5758
.build();
5859
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
59-
Assert.assertTrue(PublicMethed.sendcoin(linkage004Address,20000000L,fromAddress,
60+
Assert.assertTrue(PublicMethed.sendcoin(linkage004Address,2000000000000L,fromAddress,
6061
testKey003,blockingStubFull));
6162
Assert.assertTrue(PublicMethed.freezeBalance(linkage004Address,1000000L,
6263
3,linkage004Key,blockingStubFull));
@@ -153,6 +154,8 @@ public void getTransactionInfoById() {
153154
logger.info("This time txid is " + txid);
154155

155156
Optional<TransactionInfo> infoById = PublicMethed.getTransactionInfoById(txid,blockingStubFull);
157+
currentFee = infoById.get().getFee();
158+
logger.info("current fee is " + currentFee.toString());
156159
Assert.assertTrue(infoById.isPresent());
157160
Assert.assertTrue(infoById.get().getFee() > 0);
158161
//logger.info(Integer.toString(infoById.get().getResultValue()));
@@ -163,7 +166,7 @@ public void getTransactionInfoById() {
163166
//Assert.assertTrue(infoById.get().getReceipt().getStorageDelta() > 200);
164167
}
165168

166-
@Test(enabled = false)
169+
@Test(enabled = true)
167170
public void testFeeLimitIsTooSmall() {
168171
Account account = PublicMethed.queryAccount(linkage004Address,blockingStubFull);
169172
Long maxFeeLimit = 0L;
@@ -176,7 +179,7 @@ public void testFeeLimitIsTooSmall() {
176179
Assert.assertTrue(infoById.get().getResultValue() == 1);
177180

178181
//When the fee limit is only short with 1 sun.
179-
maxFeeLimit = 14082200L - 1L;
182+
maxFeeLimit = currentFee - 1L;
180183
txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName,abi,code,
181184
"",maxFeeLimit, 0L, 50,null,linkage004Key,linkage004Address,blockingStubFull);
182185
logger.info("testFeeLimitIsTooSmall, the txid is " + txid);
@@ -185,7 +188,7 @@ public void testFeeLimitIsTooSmall() {
185188
Assert.assertTrue(infoById.get().getResultValue() == 1);
186189

187190
//When the fee limit is just ok.
188-
maxFeeLimit = 14082200L;
191+
maxFeeLimit = currentFee;
189192
txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName,abi,code,
190193
"",maxFeeLimit, 0L, 50,null,linkage004Key,linkage004Address,blockingStubFull);
191194
logger.info("testFeeLimitIsTooSmall, the txid is " + txid);

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void deployTransactionCoin() {
8989
Assert.assertTrue(smartContract.getAbi() != null);
9090
}
9191

92-
@Test(enabled = false)
92+
@Test(enabled = true)
9393
public void triggerTransactionCoin() {
9494
//When the contract has no money,transaction coin failed.
9595
String receiveAddress = "\"" + Base58.encode58Check(receiverAddress)
@@ -110,7 +110,21 @@ public void triggerTransactionCoin() {
110110
contract012Key,blockingStubFull));
111111

112112

113+
//In smart contract, you can't create account
114+
txid = PublicMethed.triggerContract(contractAddress,
115+
"sendToAddress2(address)", receiveAddress, false,
116+
0, 100000000L, contract012Address, contract012Key, blockingStubFull);
117+
logger.info(txid);
118+
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
119+
logger.info("result is " + infoById.get().getResultValue());
120+
Assert.assertTrue(infoById.get().getResultValue() == 1);
121+
Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() > 0);
122+
Assert.assertTrue(infoById.get().getFee() == infoById.get().getReceipt().getEnergyFee());
123+
Assert.assertFalse(infoById.get().getContractAddress().isEmpty());
124+
113125
//This time, trigger the methed sendToAddress2 is OK.
126+
Assert.assertTrue(PublicMethed.sendcoin(receiverAddress,10000000L,fromAddress,
127+
testKey002,blockingStubFull));
114128
txid = PublicMethed.triggerContract(contractAddress,
115129
"sendToAddress2(address)", receiveAddress, false,
116130
0, 100000000L, contract012Address, contract012Key, blockingStubFull);
@@ -121,6 +135,7 @@ public void triggerTransactionCoin() {
121135
Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() > 0);
122136
Assert.assertTrue(infoById.get().getFee() == infoById.get().getReceipt().getEnergyFee());
123137
Assert.assertFalse(infoById.get().getContractAddress().isEmpty());
138+
124139
}
125140

126141

‎src/test/java/stest/tron/wallet/onlineStress/MainNetTransferSendOrAsset.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package stest.tron.wallet.onlinestress;
1+
package stest.tron.wallet.onlineStress;
22

33
import io.grpc.ManagedChannel;
44
import io.grpc.ManagedChannelBuilder;

‎src/test/java/stest/tron/wallet/onlineStress/MainNetVoteOrFreezeOrCreate.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package stest.tron.wallet.onlinestress;
1+
package stest.tron.wallet.onlineStress;
22

33
import com.google.protobuf.ByteString;
44
import io.grpc.ManagedChannel;

0 commit comments

Comments
 (0)