Skip to content

Commit

Permalink
Merge pull request #2336 from tronprotocol/improve_dailybuild
Browse files Browse the repository at this point in the history
Improve dailybuild
  • Loading branch information
MiraculousWang committed Jul 2, 2019
2 parents 54bce62 + 55f88b3 commit dea9a63
Show file tree
Hide file tree
Showing 7 changed files with 287 additions and 15 deletions.
2 changes: 2 additions & 0 deletions deploy.sh
@@ -1,8 +1,10 @@
#!/bin/bash
if [[ "$TRAVIS_BRANCH" = "develop" || "$TRAVIS_BRANCH" = "master" ]];then
stestlogname="`date +%Y%m%d%H%M%S`_stest.log"
echo "try to test stest_server network"
timeout 10 ping -c 5 47.93.42.145 > /dev/null || exit 1
timeout 10 ping -c 5 47.93.18.60 > /dev/null || exit 1
echo "stest_server network good"
stest_server=""
docker_num_in_145=`ssh -p 22008 -t java-tron@47.93.42.145 'docker ps -a | wc -l'`
docker_num_in_145=`echo $docker_num_in_145 | tr -d "\r"`
Expand Down
Expand Up @@ -133,13 +133,12 @@ public void test1Grammar014() {

Assert.assertTrue(infoById1.get().getResultValue() == 0);
Assert.assertTrue(returnnumber1 == 0);

Optional<TransactionInfo> infoById4 = null;
String initParmes = "\"" + Base58.encode58Check(contractAddress1) + "\",\"1\"";
String txid4 = PublicMethed.triggerContract(contractAddress,
"callTest(address,uint256)", initParmes, false,
0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
Optional<TransactionInfo> infoById4 = null;
infoById4 = PublicMethed.getTransactionInfoById(txid4, blockingStubFull);

Assert.assertTrue(infoById4.get().getResultValue() == 0);
Expand Down Expand Up @@ -279,6 +278,7 @@ public void test2Grammar015() {
"callExistFunc()", "#", false,
0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
String i = ByteArray.toHexString(Hash.sha3("ExistFuncCalled(bytes,uint256)".getBytes()));
String resultvalue = ByteArray
Expand Down Expand Up @@ -391,6 +391,7 @@ public void test4Grammar017() {
"check(uint256)", "1", false,
0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
Optional<TransactionInfo> infoById1 = PublicMethed
.getTransactionInfoById(txid1, blockingStubFull1);
Long returnnumber2 = ByteArray.toLong(ByteArray
Expand Down Expand Up @@ -431,12 +432,11 @@ public void test5Grammar018() {

Assert.assertTrue(infoById.get().getResultValue() == 0);
Assert.assertTrue(returnnumber == 1);

Optional<TransactionInfo> infoById1 = null;
String txid1 = PublicMethed.triggerContract(contractAddress,
"testMulmod()", "#", false,
0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
Optional<TransactionInfo> infoById1 = null;
infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull);
Long returnnumber1 = ByteArray.toLong(ByteArray
.fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray())));
Expand Down Expand Up @@ -465,8 +465,8 @@ public void test5Grammar018() {
String txid4 = PublicMethed.triggerContract(contractAddress,
"testSha3()", "#", false,
0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
Optional<TransactionInfo> infoById4 = null;
PublicMethed.waitProduceNextBlock(blockingStubFull);
infoById4 = PublicMethed.getTransactionInfoById(txid4, blockingStubFull);
Assert.assertTrue(infoById4.get().getResultValue() == 0);
}
Expand All @@ -484,13 +484,13 @@ public void test6Grammar019() {
byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit,
0L, 100, null, testKeyForGrammarAddress3,
grammarAddress3, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull1);
PublicMethed.waitProduceNextBlock(blockingStubFull);
String txid = PublicMethed.triggerContract(contractAddress,
"timetest()", "#", false,
0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull1);
Optional<TransactionInfo> infoById = null;
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull1);
PublicMethed.waitProduceNextBlock(blockingStubFull);
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
Assert.assertTrue(infoById.get().getResultValue() == 1);

}
Expand All @@ -508,13 +508,12 @@ public void test7Grammar020() {
0L, 100, null, testKeyForGrammarAddress3,
grammarAddress3, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
Optional<TransactionInfo> infoById = null;
String txid = PublicMethed.triggerContract(contractAddress,
"test()", "#", false,
0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
Optional<TransactionInfo> infoById = null;
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull1);

infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
Assert.assertTrue(infoById.get().getResultValue() == 0);

}
Expand Down
Expand Up @@ -306,7 +306,6 @@ public void test3TransferTrxNonexistentTarget() {
@Test(enabled = true, description = "Transfer trx to myself")
public void test4TransferTrxSelf() {


Account info;

AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress,
Expand Down Expand Up @@ -441,7 +440,6 @@ public void test5TransferTrxNonexistentTarget() {
@Test(enabled = true, description = "Transfer trx to myself and insufficient balance")
public void test6TransferTrxSelf() {


Account info;

AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress,
Expand Down Expand Up @@ -744,7 +742,7 @@ public void test9TransferTrctoken() {
Assert.assertTrue(PublicMethed.transferAsset(addressxx,
assetAccountId.toByteArray(), 100L, contractExcAddress, contractExcKey,
blockingStubFull));

PublicMethed.waitProduceNextBlock(blockingStubFull);
Long returnAddressBytesAccountCountBefore = PublicMethed
.getAssetIssueValue(addressxx, assetAccountId, blockingStubFull);
logger.info("returnAddressBytesAccountCountBefore : " + returnAddressBytesAccountCountBefore);
Expand Down
Expand Up @@ -164,6 +164,7 @@ public void test2SendEnough() {
Assert.assertTrue(PublicMethed
.sendcoin(contractAddress, 3000000L, testNetAccountAddress, testNetAccountKey,
blockingStubFull));
PublicMethed.waitProduceNextBlock(blockingStubFull);
Account info;

AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress,
Expand Down
138 changes: 138 additions & 0 deletions src/test/java/stest/tron/wallet/other/deployMainGateway.java
@@ -0,0 +1,138 @@
package stest.tron.wallet.other;

import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.tron.api.WalletGrpc;
import org.tron.api.WalletSolidityGrpc;
import org.tron.common.crypto.ECKey;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.Utils;
import org.tron.core.Wallet;
import org.tron.protos.Protocol.Account;
import org.tron.protos.Protocol.SmartContract;
import org.tron.protos.Protocol.TransactionInfo;
import stest.tron.wallet.common.client.Configuration;
import stest.tron.wallet.common.client.Parameter.CommonConstant;
import stest.tron.wallet.common.client.WalletClient;
import stest.tron.wallet.common.client.utils.Base58;
import stest.tron.wallet.common.client.utils.PublicMethed;

@Slf4j
public class deployMainGateway {


private final String testDepositTrx = "324a2052e491e99026442d81df4d2777292840c1b3949e20696c49096c6bacb7";
private final byte[] testDepositAddress = PublicMethed.getFinalAddress(testDepositTrx);
private Long maxFeeLimit = Configuration.getByPath("testng.conf")
.getLong("defaultParameter.maxFeeLimit");
private ManagedChannel channelFull = null;
private WalletGrpc.WalletBlockingStub blockingStubFull = null;



private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null;

private String fullnode = Configuration.getByPath("testng.conf")
.getStringList("fullnode.ip.list").get(0);

ECKey ecKey1 = new ECKey(Utils.getRandom());
byte[] depositAddress = ecKey1.getAddress();
String testKeyFordeposit = ByteArray.toHexString(ecKey1.getPrivKeyBytes());

@BeforeSuite
public void beforeSuite() {
Wallet wallet = new Wallet();
Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET);
}

/**
* constructor.
*/

@BeforeClass(enabled = true)
public void beforeClass() {
// PublicMethed.printAddress(testKeyFordeposit);
channelFull = ManagedChannelBuilder.forTarget(fullnode)
.usePlaintext(true)
.build();
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
}

@Test(enabled = true, description = "deploy Main Chain Gateway")
public void test1DepositTrc20001() {

PublicMethed.printAddress(testKeyFordeposit);

Assert.assertTrue(PublicMethed
.sendcoin(depositAddress, 1000_000_000L, testDepositAddress, testDepositTrx,
blockingStubFull));
PublicMethed.waitProduceNextBlock(blockingStubFull);

Account accountOralce = PublicMethed.queryAccount(depositAddress, blockingStubFull);
long OralceBalance = accountOralce.getBalance();
logger.info("OralceBalance: " + OralceBalance);

String contractName = "gateWayContract";
String code = Configuration.getByPath("testng.conf")
.getString("code.code_MainGateway");
String abi = Configuration.getByPath("testng.conf")
.getString("abi.abi_MainGateway");
String parame = "\"" + Base58.encode58Check(testDepositAddress) + "\"";

String deployTxid = PublicMethed
.deployContractWithConstantParame(contractName, abi, code, "constructor(address)",
parame, "",
maxFeeLimit,
0L, 100, null, testKeyFordeposit, depositAddress
, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);

Optional<TransactionInfo> infoById = PublicMethed
.getTransactionInfoById(deployTxid, blockingStubFull);
byte[] mainChainGateway = infoById.get().getContractAddress().toByteArray();
String mainChainGatewayAddress = WalletClient.encode58Check(mainChainGateway);
Assert.assertEquals(0, infoById.get().getResultValue());
Assert.assertNotNull(mainChainGateway);

SmartContract smartContract = PublicMethed.getContract(mainChainGateway,
blockingStubFull);
Assert.assertNotNull(smartContract.getAbi());

String outputPath = "./src/test/resources/mainChainGatewayAddress" ;
try {
File mainChainFile = new File(outputPath);
Boolean cun = mainChainFile.createNewFile();
FileWriter writer = new FileWriter(mainChainFile);
BufferedWriter out = new BufferedWriter(writer);
out.write(mainChainGatewayAddress);

out.close();
writer.close();
}catch (Exception e){
e.printStackTrace();
}

}

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

}

0 comments on commit dea9a63

Please sign in to comment.