Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2336 from tronprotocol/improve_dailybuild
Improve dailybuild
- Loading branch information
Showing
7 changed files
with
287 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
src/test/java/stest/tron/wallet/other/deployMainGateway.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.