Commit 48377c5d authored by 0Tyler's avatar 0Tyler

contract Tester

parent 31f628bb
package edu.prlab.tyler.iotgateway.contract;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.runners.MethodSorters;
import org.web3j.protocol.core.methods.response.Web3ClientVersion;
import org.web3j.protocol.http.HttpService;
import org.web3j.quorum.Quorum;
import org.web3j.tx.gas.ContractGasProvider;
import org.web3j.tx.gas.StaticGasProvider;
import java.math.BigInteger;
@FixMethodOrder(value = MethodSorters.NAME_ASCENDING)
public class ContractTester {
private static final String rpcUrl = "http://localhost:22001";
private static final String privateKey = "7777777777777777777777777777777777777777777777777777777777777777";
protected static final ContractGasProvider DEFAULT_GAS_PROVIDER = new StaticGasProvider(
BigInteger.ZERO,
BigInteger.valueOf(1000000000L)
);
@BeforeEach
public void setUp() {
}
@Test
public void deployContract() throws Exception {
System.out.println("test start");
Quorum quorum = Quorum.build(new HttpService(rpcUrl));
Web3ClientVersion web3ClientVersion = quorum.web3ClientVersion().sendAsync().get();
String clientVersion = web3ClientVersion.getWeb3ClientVersion();
System.out.println("web3j版本 : " + clientVersion);
String userAddress = quorum.ethAccounts().send().getAccounts().get(0);
System.out.println("User : " + userAddress);
// ClientTransactionManager manager = new ClientTransactionManager(quorum, userAddress);
// Credentials credentials = Credentials.create(privateKey);
// DeviceContract deviceContract = DeviceContract.deploy(quorum, manager,DEFAULT_GAS_PROVIDER).send();
//
// System.out.println("智慧合約地址:" + deviceContract.getContractAddress());
//
// Assert.assertNotNull(deviceContract);
System.out.println("test end");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment