Search in sources :

Example 1 with EthEstimateGas

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);
}
Also used : EthEstimateGas(org.web3j.protocol.core.methods.response.EthEstimateGas) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 2 with EthEstimateGas

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);
}
Also used : EthEstimateGas(org.web3j.protocol.core.methods.response.EthEstimateGas) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 3 with EthEstimateGas

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();
}
Also used : DataStore(com.thoughtworks.gauge.datastore.DataStore) EthEstimateGas(org.web3j.protocol.core.methods.response.EthEstimateGas) TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt) BigInteger(java.math.BigInteger) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 4 with EthEstimateGas

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);
}
Also used : EthEstimateGas(org.web3j.protocol.core.methods.response.EthEstimateGas) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 5 with EthEstimateGas

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);
}
Also used : EthEstimateGas(org.web3j.protocol.core.methods.response.EthEstimateGas) EVMTest(org.web3j.EVMTest) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

EthEstimateGas (org.web3j.protocol.core.methods.response.EthEstimateGas)10 Step (com.thoughtworks.gauge.Step)8 Contract (org.web3j.tx.Contract)5 BigInteger (java.math.BigInteger)2 Test (org.junit.jupiter.api.Test)2 DataStore (com.thoughtworks.gauge.datastore.DataStore)1 Random (java.util.Random)1 Disabled (org.junit.jupiter.api.Disabled)1 EVMTest (org.web3j.EVMTest)1 MessageDecodingException (org.web3j.exceptions.MessageDecodingException)1 TransactionReceipt (org.web3j.protocol.core.methods.response.TransactionReceipt)1