Skip to content

Commit a1982d4

Browse files
author
wangzihe
committed
Modify stest checkstyle
1 parent 078af23 commit a1982d4

15 files changed

Lines changed: 119 additions & 85 deletions

‎src/test/java/stest/tron/wallet/common/client/WalletClient.java‎

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
import stest.tron.wallet.common.client.utils.Base58;
4646
import stest.tron.wallet.common.client.utils.TransactionUtils;
4747

48-
class AccountComparator implements Comparator {
48+
/*class AccountComparator implements Comparator {
4949
5050
public int compare(Object o1, Object o2) {
5151
return Long.compare(((Account) o2).getBalance(), ((Account) o1).getBalance());
5252
}
53-
}
53+
}*/
5454

5555
class WitnessComparator implements Comparator {
5656

@@ -235,7 +235,7 @@ public void logout() {
235235
* Get a Wallet from storage.
236236
*/
237237

238-
public static WalletClient GetWalletByStorage(String password) {
238+
public static WalletClient getWalletByStorage(String password) {
239239
String priKeyEnced = loadPriKey();
240240
if (priKeyEnced == null) {
241241
return null;
@@ -463,7 +463,7 @@ public static Transaction createAssetIssueTransaction(AssetIssueContract contrac
463463
return rpcCli.createAssetIssue(contract);
464464
}
465465

466-
public static Block GetBlock(long blockNum) {
466+
public static Block getGetBlock(long blockNum) {
467467
return rpcCli.getBlock(blockNum);
468468
}
469469
/**
@@ -534,6 +534,19 @@ public static Transaction createTransaction4Transfer(Contract.TransferContract c
534534
Transaction transaction = rpcCli.createTransaction(contract);
535535
return transaction;
536536
}
537+
538+
/**
539+
* constructor.
540+
*/
541+
542+
public static Contract.AccountCreateContract createAccountCreateContract(byte[] owner,
543+
byte[] address) {
544+
Contract.AccountCreateContract.Builder builder = Contract.AccountCreateContract.newBuilder();
545+
builder.setOwnerAddress(ByteString.copyFrom(owner));
546+
builder.setAccountAddress(ByteString.copyFrom(address));
547+
return builder.build();
548+
}
549+
537550
/**
538551
* constructor.
539552
*/
@@ -571,17 +584,7 @@ public static Transaction createAccountTransaction(byte[] owner, byte[] address)
571584
Contract.AccountCreateContract contract = createAccountCreateContract(owner, address);
572585
return rpcCli.createAccount(contract);
573586
}
574-
/**
575-
* constructor.
576-
*/
577587

578-
public static Contract.AccountCreateContract createAccountCreateContract(byte[] owner,
579-
byte[] address) {
580-
Contract.AccountCreateContract.Builder builder = Contract.AccountCreateContract.newBuilder();
581-
builder.setOwnerAddress(ByteString.copyFrom(owner));
582-
builder.setAccountAddress(ByteString.copyFrom(address));
583-
return builder.build();
584-
}
585588
/**
586589
* constructor.
587590
*/
@@ -673,7 +676,7 @@ private static String loadPriKey() {
673676
* Get a Wallet from storage.
674677
*/
675678

676-
public static WalletClient GetWalletByStorageIgnorPrivKey() {
679+
public static WalletClient getWalletByStorageIgnorPrivKey() {
677680
try {
678681
String pubKey = loadPubKey(); //04 PubKey[128]
679682
if (StringUtils.isEmpty(pubKey)) {
@@ -927,10 +930,10 @@ public static Optional<TransactionList> getTransactionsToThis(byte[] address) {
927930
* constructor.
928931
*/
929932

930-
public boolean freezeBalance(long frozen_balance, long frozen_duration) {
933+
public boolean freezeBalance(long frozenBalance, long frozenDuration) {
931934

932-
FreezeBalanceContract contract = createFreezeBalanceContract(frozen_balance,
933-
frozen_duration);
935+
FreezeBalanceContract contract = createFreezeBalanceContract(frozenBalance,
936+
frozenDuration);
934937

935938
Transaction transaction = rpcCli.createTransaction(contract);
936939

@@ -942,14 +945,14 @@ public boolean freezeBalance(long frozen_balance, long frozen_duration) {
942945
return rpcCli.broadcastTransaction(transaction);
943946
}
944947

945-
private FreezeBalanceContract createFreezeBalanceContract(long frozen_balance,
946-
long frozen_duration) {
948+
private FreezeBalanceContract createFreezeBalanceContract(long frozenBalance,
949+
long frozenDuration) {
947950
byte[] address = getAddress();
948951
FreezeBalanceContract.Builder builder = FreezeBalanceContract.newBuilder();
949952
ByteString byteAddreess = ByteString.copyFrom(address);
950953

951-
builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozen_balance)
952-
.setFrozenDuration(frozen_duration);
954+
builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance)
955+
.setFrozenDuration(frozenDuration);
953956

954957
return builder.build();
955958
}
@@ -1012,8 +1015,8 @@ public static Block getBlock(long blockNum) {
10121015
return rpcCli.getBlock(blockNum);
10131016
}
10141017

1015-
public static Optional<Block> getBlockById(String blockID) {
1016-
return rpcCli.getBlockById(blockID);
1018+
public static Optional<Block> getBlockById(String blockId) {
1019+
return rpcCli.getBlockById(blockId);
10171020
}
10181021

10191022
public static Optional<BlockList> getBlockByLimitNext(long start, long end) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public static Coder getParamCoder(String type) {
6161
return new CoderDynamicBytes();
6262
case "trcToken":
6363
return new CoderNumber();
64+
default:
65+
6466
}
6567

6668
if (paramTypeBytes.matcher(type).find()) {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public long longValueSafe() {
168168
* constructor.
169169
*/
170170

171-
public BigInteger sValue() {
171+
public BigInteger ssValue() {
172172
return new BigInteger(data);
173173
}
174174

@@ -309,14 +309,14 @@ public void div(DataWord word) {
309309
*/
310310

311311
// TODO: improve with no BigInteger
312-
public void sDiv(DataWord word) {
312+
public void ssDiv(DataWord word) {
313313

314314
if (word.isZero()) {
315315
this.and(ZERO);
316316
return;
317317
}
318318

319-
BigInteger result = sValue().divide(word.sValue());
319+
BigInteger result = ssValue().divide(word.ssValue());
320320
this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));
321321
}
322322

@@ -350,15 +350,15 @@ public void mod(DataWord word) {
350350
* constructor.
351351
*/
352352

353-
public void sMod(DataWord word) {
353+
public void ssMod(DataWord word) {
354354

355355
if (word.isZero()) {
356356
this.and(ZERO);
357357
return;
358358
}
359359

360-
BigInteger result = sValue().abs().mod(word.sValue().abs());
361-
result = (sValue().signum() == -1) ? result.negate() : result;
360+
BigInteger result = ssValue().abs().mod(word.ssValue().abs());
361+
result = (ssValue().signum() == -1) ? result.negate() : result;
362362

363363
this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));
364364
}
@@ -462,7 +462,7 @@ public void signExtend(byte k) {
462462
if (0 > k || k > 31) {
463463
throw new IndexOutOfBoundsException();
464464
}
465-
byte mask = this.sValue().testBit((k * 8) + 7) ? (byte) 0xff : 0;
465+
byte mask = this.ssValue().testBit((k * 8) + 7) ? (byte) 0xff : 0;
466466
for (int i = 31; i > k; i--) {
467467
this.data[31 - i] = mask;
468468
}

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

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,17 +2967,17 @@ private static Permission json2Permission(JSONObject json) {
29672967
permissionBuilder.setTypeValue(type);
29682968
}
29692969
if (json.containsKey("permission_name")) {
2970-
String permission_name = json.getString("permission_name");
2971-
permissionBuilder.setPermissionName(permission_name);
2970+
String permissionName = json.getString("permission_name");
2971+
permissionBuilder.setPermissionName(permissionName);
29722972
}
29732973
if (json.containsKey("threshold")) {
2974-
// long threshold = json.getLong("threshold");
2974+
// long threshold = json.getLong("threshold");
29752975
long threshold = Long.parseLong(json.getString("threshold"));
29762976
permissionBuilder.setThreshold(threshold);
29772977
}
29782978
if (json.containsKey("parent_id")) {
2979-
int parent_id = json.getInteger("parent_id");
2980-
permissionBuilder.setParentId(parent_id);
2979+
int parentId = json.getInteger("parent_id");
2980+
permissionBuilder.setParentId(parentId);
29812981
}
29822982
if (json.containsKey("operations")) {
29832983
byte[] operations = ByteArray.fromHexString(json.getString("operations"));
@@ -2991,8 +2991,6 @@ private static Permission json2Permission(JSONObject json) {
29912991
JSONObject key = keys.getJSONObject(i);
29922992
String address = key.getString("address");
29932993
long weight = Long.parseLong(key.getString("weight"));
2994-
// long weight = key.getLong("weight");
2995-
// keyBuilder.setAddress(ByteString.copyFrom(address.getBytes()));
29962994
keyBuilder.setAddress(ByteString.copyFrom(WalletClient.decodeFromBase58Check(address)));
29972995
keyBuilder.setWeight(weight);
29982996
keyList.add(keyBuilder.build());
@@ -3015,28 +3013,28 @@ public static boolean accountPermissionUpdate(String permissionJson, byte[] owne
30153013
} catch (Exception ex) {
30163014
ex.printStackTrace();
30173015
}
3018-
ECKey ecKey = temKey;
3016+
final ECKey ecKey = temKey;
30193017

30203018
Contract.AccountPermissionUpdateContract.Builder builder =
30213019
Contract.AccountPermissionUpdateContract.newBuilder();
30223020

30233021
JSONObject permissions = JSONObject.parseObject(permissionJson);
3024-
JSONObject owner_permission = permissions.getJSONObject("owner_permission");
3025-
JSONObject witness_permission = permissions.getJSONObject("witness_permission");
3026-
JSONArray active_permissions = permissions.getJSONArray("active_permissions");
3022+
JSONObject ownersPermission = permissions.getJSONObject("owner_permission");
3023+
JSONObject witnesssPermission = permissions.getJSONObject("witness_permission");
3024+
JSONArray activesPermissions = permissions.getJSONArray("active_permissions");
30273025

3028-
if (owner_permission != null) {
3029-
Permission ownerPermission = json2Permission(owner_permission);
3026+
if (ownersPermission != null) {
3027+
Permission ownerPermission = json2Permission(ownersPermission);
30303028
builder.setOwner(ownerPermission);
30313029
}
3032-
if (witness_permission != null) {
3033-
Permission witnessPermission = json2Permission(witness_permission);
3030+
if (witnesssPermission != null) {
3031+
Permission witnessPermission = json2Permission(witnesssPermission);
30343032
builder.setWitness(witnessPermission);
30353033
}
3036-
if (active_permissions != null) {
3034+
if (activesPermissions != null) {
30373035
List<Permission> activePermissionList = new ArrayList<>();
3038-
for (int j = 0; j < active_permissions.size(); j++) {
3039-
JSONObject permission = active_permissions.getJSONObject(j);
3036+
for (int j = 0; j < activesPermissions.size(); j++) {
3037+
JSONObject permission = activesPermissions.getJSONObject(j);
30403038
activePermissionList.add(json2Permission(permission));
30413039
}
30423040
builder.addAllActives(activePermissionList);
@@ -3495,28 +3493,28 @@ public static GrpcAPI.Return accountPermissionUpdateForResponse(String permissio
34953493
} catch (Exception ex) {
34963494
ex.printStackTrace();
34973495
}
3498-
ECKey ecKey = temKey;
3496+
final ECKey ecKey = temKey;
34993497

35003498
Contract.AccountPermissionUpdateContract.Builder builder =
35013499
Contract.AccountPermissionUpdateContract.newBuilder();
35023500

35033501
JSONObject permissions = JSONObject.parseObject(permissionJson);
3504-
JSONObject owner_permission = permissions.getJSONObject("owner_permission");
3505-
JSONObject witness_permission = permissions.getJSONObject("witness_permission");
3506-
JSONArray active_permissions = permissions.getJSONArray("active_permissions");
3502+
JSONObject ownersPermission = permissions.getJSONObject("owner_permission");
3503+
JSONObject witnesssPermission = permissions.getJSONObject("witness_permission");
3504+
JSONArray activesPermissions = permissions.getJSONArray("active_permissions");
35073505

3508-
if (owner_permission != null) {
3509-
Permission ownerPermission = json2Permission(owner_permission);
3506+
if (ownersPermission != null) {
3507+
Permission ownerPermission = json2Permission(ownersPermission);
35103508
builder.setOwner(ownerPermission);
35113509
}
3512-
if (witness_permission != null) {
3513-
Permission witnessPermission = json2Permission(witness_permission);
3510+
if (witnesssPermission != null) {
3511+
Permission witnessPermission = json2Permission(witnesssPermission);
35143512
builder.setWitness(witnessPermission);
35153513
}
3516-
if (active_permissions != null) {
3514+
if (activesPermissions != null) {
35173515
List<Permission> activePermissionList = new ArrayList<>();
3518-
for (int j = 0; j < active_permissions.size(); j++) {
3519-
JSONObject permission = active_permissions.getJSONObject(j);
3516+
for (int j = 0; j < activesPermissions.size(); j++) {
3517+
JSONObject permission = activesPermissions.getJSONObject(j);
35203518
activePermissionList.add(json2Permission(permission));
35213519
}
35223520
builder.addAllActives(activePermissionList);

‎src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue005.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void testGetAssetIssueByName() {
108108

109109

110110
//Get asset issue by name success.
111-
ByteString assetNameBs = ByteString.copyFrom(name.getBytes());
111+
112112
GrpcAPI.BytesMessage request = GrpcAPI.BytesMessage.newBuilder().setValue(assetAccountId)
113113
.build();
114114
Contract.AssetIssueContract assetIssueByName =
@@ -121,6 +121,7 @@ public void testGetAssetIssueByName() {
121121

122122
//Get asset issue by name failed when the name is not correct.There is no exception.
123123
String wrongName = name + "_wrong";
124+
ByteString assetNameBs = ByteString.copyFrom(name.getBytes());
124125
assetNameBs = ByteString.copyFrom(wrongName.getBytes());
125126
request = GrpcAPI.BytesMessage.newBuilder().setValue(assetNameBs).build();
126127
assetIssueByName = blockingStubFull.getAssetIssueByName(request);

‎src/test/java/stest/tron/wallet/dailybuild/manual/ContractLinkage006.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public void teststackOutByContract2() {
319319
logger.info("afterFreeNetUsed2:" + afterFreeNetUsed2);
320320

321321
Assert.assertTrue((beforeBalance2 - fee2) == afterBalance2);
322-
// Assert.assertTrue(afterNetUsed2 > beforeNetUsed2);
322+
// Assert.assertTrue(afterNetUsed2 > beforeNetUsed2);
323323
Assert.assertTrue((beforeEnergyUsed2 + energyUsed2) >= afterEnergyUsed2);
324324
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
325325
Assert.assertTrue(infoById.get().getResultValue() == 1);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ public void deployTronNative() {
7373
ECKey ecKey1 = new ECKey(Utils.getRandom());
7474
byte[] contract002Address = ecKey1.getAddress();
7575
String contract002Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes());
76-
logger.info("From balance is "
77-
+ PublicMethed.queryAccount(fromAddress, blockingStubFull).getBalance());
7876
Assert.assertTrue(PublicMethed.sendcoin(contract002Address, 50000000L, fromAddress,
7977
testKey002, blockingStubFull));
8078
PublicMethed.waitProduceNextBlock(blockingStubFull);

‎src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario011.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ public void deployGeneScienceInterface() {
241241
logger.info("after cpu usage is " + Long.toString(cpuUsage));
242242
}
243243

244-
@Test(enabled = true,description = "Set three contract address for Kitty Core, set three CXO roles")
244+
@Test(enabled = true,description = "Set three contract address for Kitty Core, "
245+
+ "set three CXO roles")
245246
public void triggerToSetThreeContractAddressToKittyCore() {
246247
//Set SaleAuctionAddress to kitty core.
247248
String saleContractString = "\"" + Base58.encode58Check(saleClockAuctionContractAddress) + "\"";

‎src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestBlock001.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ public class WalletTestBlock001 {
3636
private String soliditynode = Configuration.getByPath("testng.conf")
3737
.getStringList("solidityNode.ip.list").get(0);
3838

39+
/**
40+
* constructor.
41+
*/
3942
@BeforeSuite
4043
public void beforeSuite() {
4144
Wallet wallet = new Wallet();
4245
Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET);
4346
}
47+
/**
48+
* constructor.
49+
*/
4450

4551
@BeforeClass
4652
public void beforeClass() {
@@ -55,6 +61,9 @@ public void beforeClass() {
5561
blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity);
5662
}
5763

64+
/**
65+
* constructor.
66+
*/
5867
@Test(enabled = true,description = "Get now block from fullnode")
5968
public void testCurrentBlock() {
6069
Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build());
@@ -78,6 +87,9 @@ public void testCurrentBlock() {
7887
newBlock.getTransactionsList();
7988
}
8089

90+
/**
91+
* constructor.
92+
*/
8193
@Test(enabled = true,description = "Get now block from solidity")
8294
public void testCurrentBlockFromSolidity() {
8395
Block currentBlock = blockingStubSolidity

0 commit comments

Comments
 (0)