Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5740,7 +5740,7 @@ public synchronized static HashMap<String, String> getBycodeAbi(String solFile,
logger.debug("outputPath: " + outputPath);
String cmd =
compile
+ " --optimize --evm-version cancun --bin --abi --overwrite "
+ " --optimize --bin --abi --overwrite "
+ absolutePath
+ "/"
+ solFile
Expand Down Expand Up @@ -5798,7 +5798,7 @@ public synchronized static HashMap<String, String> getBycodeAbiWithParam(String
logger.debug("outputPath: " + outputPath);
String cmd =
compile
+ " --optimize " + param +" --evm-version cancun --bin --abi --overwrite "
+ " --optimize " + param +" --bin --abi --overwrite "
+ absolutePath
+ "/"
+ solFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ void test18UnfreezeTriggerPortialUnvote() {
String witnessTB4 = "TB4B1RMhoPeivkj4Hebm6tttHjRY9yQFes";
String args = "[\"" + witnessTT1 + "\",\"" + witnessTB4 + "\"],[200,200]";
voteWitness(contractAddress, args);
withdrawReward(contractAddress);
String methedStr = "unfreezeBalanceV2(uint256,uint256)";
String argsStr = "10000000,0";
String txid = PublicMethed.triggerContract(contractAddress, methedStr, argsStr,
Expand Down Expand Up @@ -805,6 +806,21 @@ public void voteWitness(byte[] con, String args) {
logger.info("transactionInfo: " + transactionInfo.toString());
}

public void withdrawReward(byte[] con) {
String methodStr = "withdrawReward()";

String triggerTxid = PublicMethed.triggerContract(con, methodStr, "#", false,
0, maxFeeLimit, testFoundationAddress, testFoundationKey, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);

TransactionInfo transactionInfo = PublicMethed
.getTransactionInfoById(triggerTxid, blockingStubFull).get();
Assert.assertEquals(0, transactionInfo.getResultValue());
Assert.assertEquals(contractResult.SUCCESS,
transactionInfo.getReceipt().getResult());

}


void create2NewFreezeContract() {
String methedStr = "getPredictedAddress(bytes32)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void beforeClass() {

String filePath = "src/test/resources/soliditycode/blob.sol";
String contractName = "C";
String compileParam = "--via-ir";
String compileParam = "--experimental-via-ir";
HashMap retMap = PublicMethed.getBycodeAbiWithParam(filePath, contractName, compileParam);
String code = retMap.get("byteCode").toString();
String abi = retMap.get("abI").toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void sucideToActiveAcount02() {
logger.info("sucideToActiveAcount02 info: " + info.toString());
Assert.assertEquals(code.SUCESS, info.getResult());
Assert.assertEquals(contractResult.SUCCESS, info.getReceipt().getResult());
Assert.assertEquals(27283, info.getReceipt().getEnergyUsageTotal());
Assert.assertEquals(26993, info.getReceipt().getEnergyUsageTotal());
String contractC = PublicMethed.queryAccount(contractAddressC, blockingStubFull).toString();
System.out.println("contractC ccc: " + contractC);
Assert.assertEquals("", contractC);
Expand Down Expand Up @@ -198,7 +198,7 @@ void sucideToActiveAcount03() {
logger.info("sucideToActiveAcount03 info: " + info.toString());
Assert.assertEquals(code.SUCESS, info.getResult());
Assert.assertEquals(contractResult.SUCCESS, info.getReceipt().getResult());
Assert.assertEquals(52283, info.getReceipt().getEnergyUsageTotal());
Assert.assertEquals(51993, info.getReceipt().getEnergyUsageTotal());
String contractC = PublicMethed.queryAccount(contractAddressC, blockingStubFull).toString();
System.out.println("contractC ccc: " + contractC);
Assert.assertEquals("", contractC);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package stest.tron.wallet.dailybuild.tvmnewcommand.newGrammar;

import com.google.protobuf.ByteString;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Hex;
import org.junit.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.tron.api.GrpcAPI;
import org.tron.api.WalletGrpc;
import org.tron.protos.Protocol;
import org.tron.protos.contract.SmartContractOuterClass;
import stest.tron.wallet.common.client.Configuration;
import stest.tron.wallet.common.client.utils.ByteArray;
import stest.tron.wallet.common.client.utils.ECKey;
import stest.tron.wallet.common.client.utils.PublicMethed;
import stest.tron.wallet.common.client.utils.Utils;

import java.util.HashMap;
import java.util.concurrent.TimeUnit;

@Slf4j
public class NewFeatureForSolc0825 {

private final String testNetAccountKey = Configuration.getByPath("testng.conf")
.getString("foundationAccount.key2");
private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey);
byte[] contractC = null;
ECKey ecKey1 = new ECKey(Utils.getRandom());
byte[] contractExcAddress = ecKey1.getAddress();
String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes());
private Long maxFeeLimit = Configuration.getByPath("testng.conf")
.getLong("defaultParameter.maxFeeLimit");
private ManagedChannel channelFull = null;
private WalletGrpc.WalletBlockingStub blockingStubFull = null;
private String fullnode = Configuration.getByPath("testng.conf")
.getStringList("fullnode.ip.list").get(0);


/**
* constructor.
*/

@BeforeClass(enabled = true)
public void beforeClass() {
PublicMethed.printAddress(contractExcKey);
channelFull = ManagedChannelBuilder.forTarget(fullnode)
.usePlaintext()
.build();
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
Assert.assertTrue(PublicMethed
.sendcoin(contractExcAddress, 11010_000_000L,
testNetAccountAddress, testNetAccountKey, blockingStubFull));
PublicMethed.waitProduceNextBlock(blockingStubFull);
String filePath = "src/test/resources/soliditycode/NewFeature0825.sol";
String contractName = "C";
HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName);
String code = retMap.get("byteCode").toString();
String abi = retMap.get("abI").toString();
Assert.assertTrue(code.contains("5e"));
contractC = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit,
0L, 100, null, contractExcKey,
contractExcAddress, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
SmartContractOuterClass.SmartContract smartContract = PublicMethed.getContract(contractC,
blockingStubFull);
Assert.assertNotNull(smartContract.getAbi());
}


@Test(enabled = true, description = "Code Generator: Use ``MCOPY`` instead of ``MLOAD``/``MSTORE`` loop " +
"when copying byte arrays.")
public void test001McopyCopyBytes() {
String txid = PublicMethed
.triggerContract(contractC,"copyBytes()", "#", false,
0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);

Protocol.TransactionInfo info = PublicMethed.getTransactionInfoById(txid, blockingStubFull).get();
Assert.assertEquals(Protocol.TransactionInfo.code.SUCESS, info.getResult());
String out = ByteArray.toHexString(info.getContractResult(0).toByteArray()).substring(128);
Assert.assertEquals("6161616161000000000000000000000000000000000000000000000000000000", out);
}

@Test(enabled = true, description = "Code Generator: Use ``MCOPY`` instead of ``MLOAD``/``MSTORE`` loop " +
"when copying byte arrays.")
public void test002McopyCopyString() {
String txid = PublicMethed
.triggerContract(contractC, "copyString()", "#", false,
0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
Protocol.TransactionInfo info = PublicMethed.getTransactionInfoById(txid, blockingStubFull).get();
Assert.assertEquals(Protocol.TransactionInfo.code.SUCESS, info.getResult());
String out = ByteArray.toHexString(info.getContractResult(0).toByteArray()).substring(128);
Assert.assertEquals("72657475726e20737472696e6700000000000000000000000000000000000000", out);

}

/**
* constructor.
*/
@AfterClass
public void shutdown() throws InterruptedException {
PublicMethed.freedResource(contractExcAddress, contractExcKey,
testNetAccountAddress, blockingStubFull);
if (channelFull != null) {
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);
}
}


}

Loading