Skip to content

Commit aa43ad2

Browse files
authored
Merge pull request tronprotocol#3185 from paoerpaul/op_code
optimize code
2 parents a51c246 + 4f68970 commit aa43ad2

File tree

11 files changed

+251
-278
lines changed

11 files changed

+251
-278
lines changed

framework/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletExchange001.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,11 @@ public void test8GetExchangeListFromPbft() {
373373
*/
374374
@Test(enabled = true)
375375
public void test9GetExchangeByIdFromPbft() {
376-
Assert.assertEquals(PublicMethed.getExchange(exchangeId.toString(),blockingStubPbft),
377-
PublicMethed.getExchange(exchangeId.toString(),blockingStubSolidity));
376+
Assert.assertEquals(PublicMethed.getExchange(exchangeId.toString(), blockingStubPbft),
377+
PublicMethed.getExchange(exchangeId.toString(), blockingStubSolidity));
378378
}
379379

380380

381-
382-
383381
/**
384382
* constructor.
385383
*/

framework/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue016.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ public void test01GetAssetIssueNet() {
179179
@Test(enabled = true, description = "Get asset issue by name from Solidity")
180180
public void test02GetAssetIssueByNameFromSolidity() {
181181
Assert.assertEquals(PublicMethed.getAssetIssueByNameFromSolidity(name,
182-
blockingStubSolidity).getTotalSupply(),totalSupply);
182+
blockingStubSolidity).getTotalSupply(), totalSupply);
183183
}
184184

185185
@Test(enabled = true, description = "Get asset issue by name from PBFT")
186186
public void test03GetAssetIssueByNameFromPbft() {
187187
Assert.assertEquals(PublicMethed.getAssetIssueByNameFromSolidity(name,
188-
blockingStubPbft).getTotalSupply(),totalSupply);
188+
blockingStubPbft).getTotalSupply(), totalSupply);
189189
}
190190

191191
@Test(enabled = true, description = "Get asset issue list from PBFT")
@@ -206,23 +206,19 @@ public void test05GetAssetIssueListFromSolidity() {
206206
@Test(enabled = true, description = "Get asset issue list paginated from PBFT")
207207
public void test06GetAssetIssetListPaginatedFromPbft() {
208208
Assert.assertTrue(PublicMethed.listAssetIssuepaginatedFromSolidity(
209-
blockingStubPbft,0L,1L).get().getAssetIssueCount() == 1);
209+
blockingStubPbft, 0L, 1L).get().getAssetIssueCount() == 1);
210210
}
211211

212212

213213
@Test(enabled = true, description = "Get asset issue list paginated from Solidity")
214214
public void test05GetAssetIssueListPaginatedFromSolidity() {
215215
Assert.assertTrue(PublicMethed.listAssetIssuepaginatedFromSolidity(
216-
blockingStubSolidity,0L,1L).get().getAssetIssueCount() == 1);
216+
blockingStubSolidity, 0L, 1L).get().getAssetIssueCount() == 1);
217217
Assert.assertTrue(PublicMethed.listAssetIssuepaginatedFromSolidity(
218-
blockingStubSoliInFull,0L,1L).get().getAssetIssueCount() == 1);
218+
blockingStubSoliInFull, 0L, 1L).get().getAssetIssueCount() == 1);
219219
}
220220

221221

222-
223-
224-
225-
226222
/**
227223
* constructor.
228224
*/

framework/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue020.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,16 @@ public void test03GetAssetIssueByIdFromPbft() {
199199
@Test(enabled = true, description = "Get asset issue list by name from Solidity")
200200
public void test04GetAssetIssueListByNameFromSolidity() {
201201
Assert.assertEquals(PublicMethed.getAssetIssueListByNameFromSolidity(name,
202-
blockingStubSolidity).get().getAssetIssueList().get(0).getTotalSupply(),totalSupply);
202+
blockingStubSolidity).get().getAssetIssueList().get(0).getTotalSupply(), totalSupply);
203203
}
204204

205205
@Test(enabled = true, description = "Get asset issue list by name from PBFT")
206206
public void test05GetAssetIssueListByNameFromPbft() {
207207
Assert.assertEquals(PublicMethed.getAssetIssueListByNameFromSolidity(name,
208-
blockingStubPbft).get().getAssetIssue(0).getTotalSupply(),totalSupply);
208+
blockingStubPbft).get().getAssetIssue(0).getTotalSupply(), totalSupply);
209209
}
210210

211211

212-
213212
/**
214213
* constructor.
215214
*/

framework/src/test/java/stest/tron/wallet/dailybuild/http/HttpSrReward.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,29 @@
11
package stest.tron.wallet.dailybuild.http;
22

3-
import com.alibaba.fastjson.JSONArray;
43
import com.alibaba.fastjson.JSONObject;
54
import com.google.gson.JsonArray;
65
import com.google.gson.JsonObject;
76
import lombok.extern.slf4j.Slf4j;
87
import org.apache.http.HttpResponse;
9-
import org.apache.http.client.methods.HttpGet;
108
import org.junit.Assert;
119
import org.testng.annotations.AfterClass;
1210
import org.testng.annotations.Test;
1311
import org.tron.common.crypto.ECKey;
1412
import org.tron.common.utils.ByteArray;
1513
import org.tron.common.utils.Utils;
16-
import org.tron.core.capsule.AccountCapsule;
1714
import stest.tron.wallet.common.client.Configuration;
1815
import stest.tron.wallet.common.client.utils.HttpMethed;
1916
import stest.tron.wallet.common.client.utils.PublicMethed;
2017

2118
@Slf4j
2219
public class HttpSrReward {
20+
2321
private final String foundationAccountKey = Configuration.getByPath("testng.conf")
2422
.getString("foundationAccount.key1");
2523
private final byte[] foundationAddressByte = PublicMethed.getFinalAddress(foundationAccountKey);
2624
private final String srKey = Configuration.getByPath("testng.conf")
2725
.getString("witness.key1");
2826
private final String srAddress = PublicMethed.getAddressString(srKey);
29-
private JSONObject responseContent;
30-
private HttpResponse response;
31-
private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list")
32-
.get(0);
3327
Long totalReward = 0L;
3428
Integer cycle = 0;
3529
Long amount = 50000000L;
@@ -40,6 +34,10 @@ public class HttpSrReward {
4034
private final byte[] voteAccountAddressByte = PublicMethed.getFinalAddress(voteAccountKey);
4135
JsonArray voteKeys = new JsonArray();
4236
JsonObject voteElement = new JsonObject();
37+
private JSONObject responseContent;
38+
private HttpResponse response;
39+
private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list")
40+
.get(0);
4341

4442
/**
4543
* constructor.
@@ -73,7 +71,7 @@ public void test02GetAccountReward() throws Exception {
7371
0, voteAccountKey);
7472
Assert.assertTrue(HttpMethed.verificationResult(response));
7573
HttpMethed.waitToProduceOneBlock(httpnode);
76-
voteElement.addProperty("vote_address",srAddress);
74+
voteElement.addProperty("vote_address", srAddress);
7775
voteElement.addProperty("vote_count", frozenAmount / 1000000L);
7876
voteKeys.add(voteElement);
7977
response = HttpMethed
@@ -92,7 +90,7 @@ public void test02GetAccountReward() throws Exception {
9290
System.out.println("totalReward:" + totalReward);
9391
System.out.println("responseContent.getLong(srAddress):" + responseContent.getLong(srAddress));
9492
//Assert.assertTrue(totalReward == responseContent.getLong(srAddress));
95-
Assert.assertEquals(totalReward,responseContent.getLong(srAddress));
93+
Assert.assertEquals(totalReward, responseContent.getLong(srAddress));
9694
}
9795

9896
/**
@@ -115,7 +113,7 @@ public void test03GetAccountLastUnwithdrawReward() throws Exception {
115113
@Test(enabled = true, description = "Get SR profit by cycle")
116114
public void test04GetSrProfitByCycle() throws Exception {
117115
response = HttpMethed
118-
.getSrProfitByCycle(httpnode, srAddress,cycle - 1, cycle + 2);
116+
.getSrProfitByCycle(httpnode, srAddress, cycle - 1, cycle + 2);
119117
responseContent = HttpMethed.parseResponseContent(response);
120118
HttpMethed.printJsonContent(responseContent);
121119
Long total = responseContent.getLong("total");
@@ -132,7 +130,7 @@ public void test04GetSrProfitByCycle() throws Exception {
132130
@Test(enabled = true, description = "Get SR dividends by cycle")
133131
public void test05GetSrDividendsByCycle() throws Exception {
134132
response = HttpMethed
135-
.getSrDividendsByCycle(httpnode, srAddress,cycle - 1, cycle + 2);
133+
.getSrDividendsByCycle(httpnode, srAddress, cycle - 1, cycle + 2);
136134
responseContent = HttpMethed.parseResponseContent(response);
137135
HttpMethed.printJsonContent(responseContent);
138136
Long total = responseContent.getLong("total");
@@ -147,7 +145,7 @@ public void test05GetSrDividendsByCycle() throws Exception {
147145
*/
148146
@Test(enabled = true, description = "Get now SR annualized rate")
149147
public void test06GetNowSrAnnualizedRate() throws Exception {
150-
response = HttpMethed.getNowSrAnnualizedRate(httpnode,srAddress);
148+
response = HttpMethed.getNowSrAnnualizedRate(httpnode, srAddress);
151149
responseContent = HttpMethed.parseResponseContent(response);
152150
HttpMethed.printJsonContent(responseContent);
153151
Assert.assertTrue(responseContent.getDouble("annualizedRateOfReturn") > 0);

framework/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario002.java

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package stest.tron.wallet.dailybuild.manual;
22

3-
import com.google.protobuf.ByteString;
43
import io.grpc.ManagedChannel;
54
import io.grpc.ManagedChannelBuilder;
65
import java.util.HashMap;
@@ -31,10 +30,10 @@ public class ContractScenario002 {
3130
private final String testKey002 = Configuration.getByPath("testng.conf")
3231
.getString("foundationAccount.key1");
3332
private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002);
34-
private String txid;
3533
ECKey ecKey1 = new ECKey(Utils.getRandom());
3634
byte[] contract002Address = ecKey1.getAddress();
3735
String contract002Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes());
36+
private String txid;
3837
private ManagedChannel channelFull = null;
3938
private ManagedChannel channelSolidity = null;
4039
private ManagedChannel channelSoliInFull = null;
@@ -174,55 +173,53 @@ public void test02GetContractWithInvalidAddress() {
174173
*/
175174
@Test(enabled = true, description = "Get transaction by id from solidity")
176175
public void test03GetTransactionByIdFromSolidity() {
177-
Assert.assertFalse(PublicMethed.getTransactionById(txid,blockingStubSolidity)
176+
Assert.assertFalse(PublicMethed.getTransactionById(txid, blockingStubSolidity)
178177
.get().getSignature(0).isEmpty());
179-
Assert.assertEquals(PublicMethed.getTransactionById(txid,blockingStubFull),
180-
PublicMethed.getTransactionById(txid,blockingStubSolidity));
178+
Assert.assertEquals(PublicMethed.getTransactionById(txid, blockingStubFull),
179+
PublicMethed.getTransactionById(txid, blockingStubSolidity));
181180
}
182181

183182
/**
184183
* constructor.
185184
*/
186185
@Test(enabled = true, description = "Get transaction by id from PBFT")
187186
public void test04GetTransactionByIdFromPbft() {
188-
Assert.assertFalse(PublicMethed.getTransactionById(txid,blockingStubPbft)
187+
Assert.assertFalse(PublicMethed.getTransactionById(txid, blockingStubPbft)
189188
.get().getSignature(0).isEmpty());
190-
Assert.assertEquals(PublicMethed.getTransactionById(txid,blockingStubSoliInFull),
191-
PublicMethed.getTransactionById(txid,blockingStubPbft));
189+
Assert.assertEquals(PublicMethed.getTransactionById(txid, blockingStubSoliInFull),
190+
PublicMethed.getTransactionById(txid, blockingStubPbft));
192191
}
193192

194193
/**
195194
* constructor.
196195
*/
197196
@Test(enabled = true, description = "Get transaction by id from Solidity")
198197
public void test05GetTransactionInfoByIdFromSolidity() throws Exception {
199-
long netUsage = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getReceipt()
198+
long netUsage = PublicMethed.getTransactionInfoById(txid, blockingStubFull).get().getReceipt()
200199
.getNetUsage();
201200

201+
Assert.assertEquals(PublicMethed.getTransactionInfoByIdFromSolidity(txid, blockingStubSolidity)
202+
.get().getReceipt().getNetUsage(), netUsage);
202203

203-
Assert.assertEquals(PublicMethed.getTransactionInfoByIdFromSolidity(txid,blockingStubSolidity)
204-
.get().getReceipt().getNetUsage(),netUsage);
205-
206-
Assert.assertEquals(PublicMethed.getTransactionInfoByIdFromSolidity(txid,blockingStubSoliInFull)
207-
.get().getReceipt().getNetUsage(),netUsage);
204+
Assert
205+
.assertEquals(PublicMethed.getTransactionInfoByIdFromSolidity(txid, blockingStubSoliInFull)
206+
.get().getReceipt().getNetUsage(), netUsage);
208207
}
209208

210209
/**
211210
* constructor.
212211
*/
213212
@Test(enabled = true, description = "Get transaction by id from PBFT")
214213
public void test06GetTransactionInfoByIdFromPbft() {
215-
long energyUsage = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getReceipt()
214+
long energyUsage = PublicMethed.getTransactionInfoById(txid, blockingStubFull).get()
215+
.getReceipt()
216216
.getEnergyUsage();
217217

218-
Assert.assertEquals(PublicMethed.getTransactionInfoByIdFromSolidity(txid,blockingStubPbft)
219-
.get().getReceipt().getEnergyUsage(),energyUsage);
218+
Assert.assertEquals(PublicMethed.getTransactionInfoByIdFromSolidity(txid, blockingStubPbft)
219+
.get().getReceipt().getEnergyUsage(), energyUsage);
220220
}
221221

222222

223-
224-
225-
226223
/**
227224
* constructor.
228225
*/

framework/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount013.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void beforeClass() {
107107
blockingStubPbft = WalletSolidityGrpc.newBlockingStub(channelPbft);
108108
}
109109

110-
@Test(enabled = true,description = "Delegate resource for bandwidth and energy")
110+
@Test(enabled = true, description = "Delegate resource for bandwidth and energy")
111111
public void test1DelegateResourceForBandwidthAndEnergy() {
112112
//Create account013
113113
ECKey ecKey1 = new ECKey(Utils.getRandom());
@@ -225,7 +225,7 @@ public void test1DelegateResourceForBandwidthAndEnergy() {
225225
logger.info("After receiver net limit is " + receiverResource.getNetLimit());
226226
}
227227

228-
@Test(enabled = true,description = "Get delegate resource index")
228+
@Test(enabled = true, description = "Get delegate resource index")
229229
public void test2getDelegatedResourceAndDelegateResourceAccountIndex() {
230230
//Create Account4
231231
ECKey ecKey4 = new ECKey(Utils.getRandom());
@@ -333,7 +333,7 @@ public void test2getDelegatedResourceAndDelegateResourceAccountIndex() {
333333
account5DelegatedResourceAddress, blockingStubFull));
334334
}
335335

336-
@Test(enabled = true,description = "Prepare delegate resource token")
336+
@Test(enabled = true, description = "Prepare delegate resource token")
337337
public void test3PrepareToken() {
338338
//Create Account7
339339
ECKey ecKey7 = new ECKey(Utils.getRandom());
@@ -362,7 +362,7 @@ public void test3PrepareToken() {
362362

363363
}
364364

365-
@Test(enabled = true,description = "Delegate resource about transfer asset")
365+
@Test(enabled = true, description = "Delegate resource about transfer asset")
366366
public void test4DelegateResourceAboutTransferAsset() {
367367
//Wait for 3s
368368
PublicMethed.waitProduceNextBlock(blockingStubFull);
@@ -421,7 +421,7 @@ public void test4DelegateResourceAboutTransferAsset() {
421421
Assert.assertTrue(account5CurrentBandwidth == account5CurrentBandwidthAfterTrans);
422422
}
423423

424-
@Test(enabled = true,description = "Can't delegate resource for contract")
424+
@Test(enabled = true, description = "Can't delegate resource for contract")
425425
public void test5CanNotDelegateResourceToContract() {
426426
//Create Account6
427427
ECKey ecKey6 = new ECKey(Utils.getRandom());
@@ -456,7 +456,7 @@ public void test5CanNotDelegateResourceToContract() {
456456
}
457457

458458

459-
@Test(enabled = true,description = "Get delegate resource from solidity")
459+
@Test(enabled = true, description = "Get delegate resource from solidity")
460460
public void test6GetDelegateResourceFromSolidity() {
461461
Optional<GrpcAPI.DelegatedResourceList> delegateResource = PublicMethed
462462
.getDelegatedResourceFromSolidity(account013Address, receiverDelegateAddress,
@@ -467,7 +467,7 @@ public void test6GetDelegateResourceFromSolidity() {
467467
.getFrozenBalanceForBandwidth() == 10000000);
468468
}
469469

470-
@Test(enabled = true,description = "Get delegate resource from PBFT")
470+
@Test(enabled = true, description = "Get delegate resource from PBFT")
471471
public void test7GetDelegateResourceFromPbft() {
472472
Optional<GrpcAPI.DelegatedResourceList> delegateResource = PublicMethed
473473
.getDelegatedResourceFromSolidity(account013Address, receiverDelegateAddress,
@@ -478,25 +478,23 @@ public void test7GetDelegateResourceFromPbft() {
478478
.getFrozenBalanceForBandwidth() == 10000000);
479479
}
480480

481-
@Test(enabled = true,description = "Get delegate resource index from solidity")
481+
@Test(enabled = true, description = "Get delegate resource index from solidity")
482482
public void test8GetDelegateResourceIndexFromSolidity() {
483-
Optional<Protocol.DelegatedResourceAccountIndex> delegateResourceIndex = PublicMethed
483+
Optional<Protocol.DelegatedResourceAccountIndex> delegateResourceIndex = PublicMethed
484484
.getDelegatedResourceAccountIndexFromSolidity(account013Address,
485485
blockingStubSolidity);
486486
Assert.assertTrue(delegateResourceIndex.get().getToAccountsCount() == 2);
487487
}
488488

489-
@Test(enabled = true,description = "Get delegate resource index from PBFT")
489+
@Test(enabled = true, description = "Get delegate resource index from PBFT")
490490
public void test9GetDelegateResourceIndexFromPbft() {
491-
Optional<Protocol.DelegatedResourceAccountIndex> delegateResourceIndex = PublicMethed
491+
Optional<Protocol.DelegatedResourceAccountIndex> delegateResourceIndex = PublicMethed
492492
.getDelegatedResourceAccountIndexFromSolidity(account013Address,
493493
blockingStubSolidity);
494494
Assert.assertTrue(delegateResourceIndex.get().getToAccountsCount() == 2);
495495
}
496496

497497

498-
499-
500498
/**
501499
* constructor.
502500
*/

0 commit comments

Comments
 (0)