Skip to content

Commit

Permalink
update checkstyle warnings fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhallhall committed Nov 14, 2019
1 parent aaa514a commit 8ec872f
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 102 deletions.
4 changes: 2 additions & 2 deletions framework/src/test/java/org/tron/common/utils/ByteString.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public void test() {
com.google.protobuf.ByteString one = com.google.protobuf.ByteString.copyFromUtf8("1111");
com.google.protobuf.ByteString one2 = com.google.protobuf.ByteString.copyFromUtf8("1111");
com.google.protobuf.ByteString two = com.google.protobuf.ByteString.copyFromUtf8("2222");
com.google.protobuf.ByteString array[] = {one, two};
com.google.protobuf.ByteString array2[] = {two, one2};
com.google.protobuf.ByteString [] array = {one, two};
com.google.protobuf.ByteString [] array2 = {two, one2};

list1.addAll(Arrays.asList(array));
list2.addAll(Arrays.asList(array2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ private Any getContract(long count, String assetName) {
.build());
}

private Any getContract(long count, ByteString assetName) {
return Any.pack(
ParticipateAssetIssueContract.newBuilder()
.setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)))
.setToAddress(ByteString.copyFrom(ByteArray.fromHexString(TO_ADDRESS)))
.setAssetName(assetName)
.setAmount(count)
.build());
}

private Any getContractWithOwner(long count, String ownerAddress) {
String assertName = ASSET_NAME;
if (dbManager.getDynamicPropertiesStore().getAllowSameTokenName() == 1) {
Expand Down Expand Up @@ -178,16 +188,6 @@ private Any getContractWithTo(long count, String toAddress) {
.build());
}

private Any getContract(long count, ByteString assetName) {
return Any.pack(
ParticipateAssetIssueContract.newBuilder()
.setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)))
.setToAddress(ByteString.copyFrom(ByteArray.fromHexString(TO_ADDRESS)))
.setAssetName(assetName)
.setAmount(count)
.build());
}

private void initAssetIssue(long startTimestmp, long endTimestmp) {
long id = dbManager.getDynamicPropertiesStore().getTokenIdNum() + 1;
dbManager.getDynamicPropertiesStore().saveTokenIdNum(id);
Expand Down Expand Up @@ -1106,8 +1106,8 @@ public void assetNameTest() {

// 1 byte readable character ok.
assetName = "t";
initAssetIssue(dbManager.getDynamicPropertiesStore().
getLatestBlockHeaderTimestamp() - 1000,
initAssetIssue(dbManager.getDynamicPropertiesStore()
.getLatestBlockHeaderTimestamp() - 1000,
dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() + 1000,
assetName);
actuator = new ParticipateAssetIssueActuator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,46 +336,5 @@ public void invalidName() {
} catch (ContractExeException e) {
Assert.assertFalse(e instanceof ContractExeException);
}
// //Too short name 7 bytes
// try {
// UpdateAccountActuator actuator = new UpdateAccountActuator(
// getContract("testnam", OWNER_ADDRESS), dbManager);
// actuator.validate();
// actuator.execute(ret);
// Assert.assertFalse(true);
// } catch (ContractValidateException e) {
// Assert.assertTrue(e instanceof ContractValidateException);
// Assert.assertEquals("Invalid accountName", e.getMessage());
// } catch (ContractExeException e) {
// Assert.assertFalse(e instanceof ContractExeException);
// }
//
// //Can't contain space
// try {
// UpdateAccountActuator actuator = new UpdateAccountActuator(
// getContract("t e", OWNER_ADDRESS), dbManager);
// actuator.validate();
// actuator.execute(ret);
// Assert.assertFalse(true);
// } catch (ContractValidateException e) {
// Assert.assertTrue(e instanceof ContractValidateException);
// Assert.assertEquals("Invalid accountName", e.getMessage());
// } catch (ContractExeException e) {
// Assert.assertFalse(e instanceof ContractExeException);
// }
// //Can't contain chinese characters
// try {
// UpdateAccountActuator actuator = new UpdateAccountActuator(
// getContract(ByteString.copyFrom(ByteArray.fromHexString("E6B58BE8AF95"))
// , OWNER_ADDRESS), dbManager);
// actuator.validate();
// actuator.execute(ret);
// Assert.assertFalse(true);
// } catch (ContractValidateException e) {
// Assert.assertTrue(e instanceof ContractValidateException);
// Assert.assertEquals("Invalid accountName", e.getMessage());
// } catch (ContractExeException e) {
// Assert.assertFalse(e instanceof ContractExeException);
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void testQpsRateLimiterAdapter() {
long t0 = System.currentTimeMillis();
CountDownLatch latch = new CountDownLatch(20);
for (int i = 0; i < 20; i++) {
Thread thread = new Thread(new MyThread(latch, strategy));
Thread thread = new Thread(new AdaptorThread(latch, strategy));
thread.start();
}

Expand All @@ -150,25 +150,4 @@ public void testQpsRateLimiterAdapter() {
}
}

class MyThread implements Runnable {

private CountDownLatch latch;
private QpsStrategy strategy;

public MyThread(CountDownLatch latch, QpsStrategy strategy) {
this.latch = latch;
this.strategy = strategy;
}

@Override
public void run() {
strategy.acquire();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {

}
latch.countDown();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.tron.core.services.ratelimiter.adaptor;

import java.util.concurrent.CountDownLatch;
import org.tron.core.services.ratelimiter.strategy.QpsStrategy;

class AdaptorThread implements Runnable {

private CountDownLatch latch;
private QpsStrategy strategy;

public AdaptorThread(CountDownLatch latch, QpsStrategy strategy) {
this.latch = latch;
this.strategy = strategy;
}

@Override
public void run() {
strategy.acquire();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
latch.countDown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ public Thread newThread(Runnable r) {

long startGenerate = System.currentTimeMillis();
LongStream.range(0L, count).forEach(l -> {
generatePool.execute(() -> {
try {
benchmarkCreateSpend();
} catch (Exception ex) {
ex.printStackTrace();
logger.error("", ex);
}
});
});
generatePool.execute(() -> {
try {
benchmarkCreateSpend();
} catch (Exception ex) {
ex.printStackTrace();
logger.error("", ex);
}
});
});

countDownLatch.await();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public void calBenchmarkVerifySpend() throws ZksnarkException, BadItemException
long maxTime = 0;
double totalTime = 0.0;

String result[] = generateSpendAndOutputParams();
String [] result = generateSpendAndOutputParams();
String spend = result[0];
String dataToBeSigned = result[1];

Expand Down Expand Up @@ -508,7 +508,7 @@ public void calBenchmarkVerifyOutput() throws ZksnarkException, BadItemException
long maxTime = 0;
double totalTime = 0.0;

String result[] = generateSpendAndOutputParams();
String [] result = generateSpendAndOutputParams();
String outputParams = result[2];

for (int i = 0; i < count; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,6 @@
import stest.tron.wallet.common.client.utils.Base58;
import stest.tron.wallet.common.client.utils.TransactionUtils;

/*class AccountComparator implements Comparator {
public int compare(Object o1, Object o2) {
return Long.compare(((Account) o2).getBalance(), ((Account) o1).getBalance());
}
}*/

class WitnessComparator implements Comparator {

public int compare(Object o1, Object o2) {
return Long.compare(((Witness) o2).getVoteCount(), ((Witness) o1).getVoteCount());
}
}

public class WalletClient {
private static final Logger logger = LoggerFactory.getLogger("WalletClient");
private static final String FilePath = "Wallet";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ private static Coder getParamCoder(String type) {
return new CoderDynamicBytes();
case "trcToken":
return new CoderNumber();
default:
System.out.println(type);
}

if (paramTypeBytes.matcher(type).find()) {
Expand Down

0 comments on commit 8ec872f

Please sign in to comment.