Skip to content

Commit e4dfd1c

Browse files
committed
rm utf-8 string instead of bytestring
1 parent 0dbe99d commit e4dfd1c

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

src/test/java/org/tron/core/actuator/ParticipateAssetIssueActuatorTest.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.google.protobuf.Any;
44
import com.google.protobuf.ByteString;
55
import java.io.File;
6-
import java.nio.charset.Charset;
76
import org.joda.time.DateTime;
87
import org.junit.AfterClass;
98
import org.junit.Assert;
@@ -584,8 +583,9 @@ public void assetNameTest() {
584583
}
585584

586585
//Contain chinese character, throw exception.
587-
assetName = new String(ByteArray.fromHexString("E6B58BE8AF95"), Charset.forName("UTF-8"));
588-
actuator = new ParticipateAssetIssueActuator(getContract(1000L, assetName), dbManager);
586+
actuator = new ParticipateAssetIssueActuator(
587+
getContract(1000L, ByteString.copyFrom(ByteArray.fromHexString("E6B58BE8AF95"))),
588+
dbManager);
589589
ret = new TransactionResultCapsule();
590590
try {
591591
actuator.validate();
@@ -825,39 +825,39 @@ public void multiplyOverflowTest() {
825825
}
826826

827827
/**
828-
* exchangeAmount <= 0 trx, throw exception
828+
* exchangeAmount <= 0 trx, throw exception
829829
*/
830830
@Test
831831
public void exchangeAmountTest() {
832832

833833
dbManager.getDynamicPropertiesStore().saveLatestBlockHeaderTimestamp(1000000);
834834
AssetIssueContract assetIssueContract =
835-
AssetIssueContract.newBuilder()
836-
.setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(TO_ADDRESS)))
837-
.setName(ByteString.copyFrom(ByteArray.fromString(ASSET_NAME)))
838-
.setTotalSupply(TOTAL_SUPPLY)
839-
.setTrxNum(100)
840-
.setNum(1)
841-
.setStartTime(dbManager.getHeadBlockTimeStamp() - 10000)
842-
.setEndTime(dbManager.getHeadBlockTimeStamp() + 11000000)
843-
.setVoteScore(VOTE_SCORE)
844-
.setDescription(ByteString.copyFrom(ByteArray.fromString(DESCRIPTION)))
845-
.setUrl(ByteString.copyFrom(ByteArray.fromString(URL)))
846-
.build();
835+
AssetIssueContract.newBuilder()
836+
.setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(TO_ADDRESS)))
837+
.setName(ByteString.copyFrom(ByteArray.fromString(ASSET_NAME)))
838+
.setTotalSupply(TOTAL_SUPPLY)
839+
.setTrxNum(100)
840+
.setNum(1)
841+
.setStartTime(dbManager.getHeadBlockTimeStamp() - 10000)
842+
.setEndTime(dbManager.getHeadBlockTimeStamp() + 11000000)
843+
.setVoteScore(VOTE_SCORE)
844+
.setDescription(ByteString.copyFrom(ByteArray.fromString(DESCRIPTION)))
845+
.setUrl(ByteString.copyFrom(ByteArray.fromString(URL)))
846+
.build();
847847
AssetIssueCapsule assetIssueCapsule = new AssetIssueCapsule(assetIssueContract);
848848
dbManager.getAssetIssueStore()
849-
.put(assetIssueCapsule.getName().toByteArray(), assetIssueCapsule);
849+
.put(assetIssueCapsule.getName().toByteArray(), assetIssueCapsule);
850850

851851
AccountCapsule toAccountCapsule = dbManager.getAccountStore()
852-
.get(ByteArray.fromHexString(TO_ADDRESS));
852+
.get(ByteArray.fromHexString(TO_ADDRESS));
853853
toAccountCapsule.addAsset(ASSET_NAME, TOTAL_SUPPLY);
854854
dbManager.getAccountStore().put(toAccountCapsule.getAddress().toByteArray(), toAccountCapsule);
855855
AccountCapsule owner = dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS));
856856
owner.setBalance(100000000000000L);
857857
dbManager.getAccountStore().put(owner.getAddress().toByteArray(), owner);
858858

859859
ParticipateAssetIssueActuator actuator = new ParticipateAssetIssueActuator(getContract(1),
860-
dbManager);
860+
dbManager);
861861

862862
TransactionResultCapsule ret = new TransactionResultCapsule();
863863
try {

src/test/java/org/tron/core/actuator/TransferAssetActuatorTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.google.protobuf.Any;
2121
import com.google.protobuf.ByteString;
2222
import java.io.File;
23-
import java.nio.charset.Charset;
2423
import lombok.extern.slf4j.Slf4j;
2524
import org.junit.AfterClass;
2625
import org.junit.Assert;
@@ -619,8 +618,7 @@ public void assetNameTest() {
619618
}
620619

621620
//Contain chinese character, throw exception.
622-
assetName = new String(ByteArray.fromHexString("E6B58BE8AF95"), Charset.forName("UTF-8")); //Chinese characters test
623-
actuator = new TransferAssetActuator(getContract(100L, assetName), dbManager);
621+
actuator = new TransferAssetActuator(getContract(100L, ByteString.copyFrom(ByteArray.fromHexString("E6B58BE8AF95"))), dbManager);
624622
try {
625623
actuator.validate();
626624
actuator.execute(ret);

src/test/java/org/tron/core/actuator/UpdateAccountActuatorTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.google.protobuf.Any;
44
import com.google.protobuf.ByteString;
55
import java.io.File;
6-
import java.nio.charset.Charset;
76
import lombok.extern.slf4j.Slf4j;
87
import org.junit.AfterClass;
98
import org.junit.Assert;
@@ -327,7 +326,7 @@ public void invalidName() {
327326
//Can't contain chinese characters
328327
try {
329328
UpdateAccountActuator actuator = new UpdateAccountActuator(
330-
getContract(new String(ByteArray.fromHexString("E6B58BE8AF95"), Charset.forName("UTF-8"))
329+
getContract(ByteString.copyFrom(ByteArray.fromHexString("E6B58BE8AF95"))
331330
, OWNER_ADDRESS), dbManager);
332331
actuator.validate();
333332
actuator.execute(ret);

0 commit comments

Comments
 (0)