use of org.web3j.protocol.core.methods.response.EthEstimateGas in project quorum-acceptance-tests by ConsenSys.
the class EstimateGas method estimatePublicContract.
@Step("Estimate gas for deploying `SimpleContract` public smart contract from a default account in <from>")
public void estimatePublicContract(QuorumNetworkProperty.Node from) {
Contract c = mustHaveValue(DataStoreFactory.getSpecDataStore(), "publicContract1", Contract.class);
String encodedData = getEncodedContractDeployData(c, 0);
EthEstimateGas estimatedValue = transactionService.estimateGasForPublicContract(from, encodedData).blockingFirst();
DataStoreFactory.getScenarioDataStore().put("estimatedValue", estimatedValue);
}
use of org.web3j.protocol.core.methods.response.EthEstimateGas in project quorum-acceptance-tests by ConsenSys.
the class EstimateGas method estimatePrivateContractCall.
@Step("Estimate gas for calling the `SimpleContract` private smart contract from a default account in <from> and private for <privateFor>")
public void estimatePrivateContractCall(QuorumNode from, QuorumNode privateFor) {
Contract c = mustHaveValue(DataStoreFactory.getSpecDataStore(), "privateContract1", Contract.class);
EthEstimateGas estimatedValue = transactionService.estimateGasForPrivateContractCall(from, privateFor, c).blockingFirst();
DataStoreFactory.getScenarioDataStore().put("estimatedValue", estimatedValue);
}
use of org.web3j.protocol.core.methods.response.EthEstimateGas in project quorum-acceptance-tests by ConsenSys.
the class EstimateGas method updateContractUsingEstimatedGas.
@Step("Update contract <contractName> with value <value>, from <from> to <privateFor> using estimated gas")
public void updateContractUsingEstimatedGas(final String contractName, final int value, final QuorumNode from, final QuorumNode privateFor) {
final DataStore specStore = DataStoreFactory.getSpecDataStore();
final DataStore scenarioStore = DataStoreFactory.getScenarioDataStore();
final Contract contract = mustHaveValue(specStore, contractName, Contract.class);
final String contractAddress = contract.getContractAddress();
final EthEstimateGas estimatedGasResult = mustHaveValue(scenarioStore, "estimatedValue", EthEstimateGas.class);
final BigInteger estimatedGasLimit = estimatedGasResult.getAmountUsed();
final TransactionReceipt receipt = contractService.updateSimpleContractWithGasLimit(from, Arrays.asList(privateFor), contractAddress, estimatedGasLimit, value, Arrays.asList(PrivacyFlag.StandardPrivate)).blockingFirst();
assertThat(receipt.isStatusOK()).isTrue();
}
use of org.web3j.protocol.core.methods.response.EthEstimateGas in project quorum-acceptance-tests by ConsenSys.
the class EstimateGas method estimatePublicContractCall.
@Step("Estimate gas for calling the `SimpleContract` public smart contract from a default account in <from>")
public void estimatePublicContractCall(QuorumNode from) {
Contract c = mustHaveValue(DataStoreFactory.getSpecDataStore(), "publicContract1", Contract.class);
EthEstimateGas estimatedValue = transactionService.estimateGasForPublicContractCall(from, c).blockingFirst();
DataStoreFactory.getScenarioDataStore().put("estimatedValue", estimatedValue);
}
use of org.web3j.protocol.core.methods.response.EthEstimateGas in project web3j by web3j.
the class CoreIT method testEthEstimateGas.
@Test
@Disabled("Enable in the next release when geth is fixed")
public void testEthEstimateGas(Web3j web3j, ContractGasProvider gasProvider) throws Exception {
org.web3j.protocol.core.methods.request.Transaction transaction = org.web3j.protocol.core.methods.request.Transaction.createContractTransaction(config.validAccount(), // nonce
BigInteger.ZERO, gasProvider.getGasPrice(), config.validContractCode());
EthEstimateGas ethEstimateGas = web3j.ethEstimateGas(transaction).send();
assertEquals(ethEstimateGas.getAmountUsed().signum(), 1);
}
Aggregations