Search in sources :

Example 1 with Contract

use of org.web3j.tx.Contract in project quorum-acceptance-tests by ConsenSys.

the class Permissions method executePermInit.

@Step("From <node> execute <permissionVersion> permissions init on <upgrContractKey> passing <interfaceContractKey> and <implContractKey> contract addresses")
public void executePermInit(QuorumNetworkProperty.Node node, String permissionVersion, String upgrContractKey, String interfaceContractKey, String implContractKey) {
    String upgrContractAddress = mustHaveValue(DataStoreFactory.getScenarioDataStore(), upgrContractKey, Contract.class).getContractAddress();
    String interfaceContractAddress = mustHaveValue(DataStoreFactory.getScenarioDataStore(), interfaceContractKey, Contract.class).getContractAddress();
    String implContractAddress = mustHaveValue(DataStoreFactory.getScenarioDataStore(), implContractKey, Contract.class).getContractAddress();
    TransactionReceipt tx = permissionContractService.executeNetworkInit(node, upgrContractAddress, interfaceContractAddress, implContractAddress, permissionVersion).blockingFirst();
    assertThat(tx.getTransactionHash()).isNotBlank();
}
Also used : TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 2 with Contract

use of org.web3j.tx.Contract in project quorum-acceptance-tests by ConsenSys.

the class Permissions method setupStorecAsPublicDependentContractUntilBlockHeightReached.

@Step("Deploy <contractName> smart contract with initial value <initialValue> from a default account in <node> until block height reaches <qip714block>")
public void setupStorecAsPublicDependentContractUntilBlockHeightReached(String contractName, int initialValue, QuorumNetworkProperty.Node node, int qip714block) {
    int curBlockHeight = utilService.getCurrentBlockNumber().blockingFirst().getBlockNumber().intValue();
    while (curBlockHeight < qip714block) {
        Contract c = contractService.createGenericStoreContract(node, contractName, initialValue, null, false, null, PrivacyFlag.StandardPrivate).blockingFirst();
        assertThat(c).isNotNull();
        curBlockHeight = utilService.getCurrentBlockNumber().blockingFirst().getBlockNumber().intValue();
        logger.debug("curBlockHeight:{} height:{}", curBlockHeight, qip714block);
    }
    logger.debug("block height reached");
}
Also used : Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 3 with Contract

use of org.web3j.tx.Contract in project quorum-acceptance-tests by ConsenSys.

the class Permissions method setupStorecAsPublicDependentContract.

@Step("Deploy <contractName> smart contract with initial value <initialValue> from a default account in <node> fails with error <error>")
public void setupStorecAsPublicDependentContract(String contractName, int initialValue, QuorumNetworkProperty.Node node, String error) {
    Contract c = null;
    String exMsg = "";
    try {
        c = contractService.createGenericStoreContract(node, contractName, initialValue, null, false, null, null).blockingFirst();
    } catch (Exception ex) {
        exMsg = ex.getMessage();
        logger.debug("deploy contract failed " + ex.getMessage());
    }
    assertThat(c).isNull();
// assertThat(exMsg.contains(error)).isTrue();
}
Also used : Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 4 with Contract

use of org.web3j.tx.Contract in project quorum-acceptance-tests by ConsenSys.

the class MultiTenancy method invokeGetMethodOnSimpleContract.

@Step("`<clientName>` invokes get in <contractName> on `<node>` and gets value <expectedValue>")
public void invokeGetMethodOnSimpleContract(String clientName, String contractName, Node node, int expectedValue) {
    Contract c = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName, Contract.class);
    BigInteger actualValue = requestAccessToken(clientName).flatMap(t -> contractService.readSimpleContractValue(node, c.getContractAddress())).doOnTerminate(Context::removeAccessToken).onErrorReturn(err -> {
        if (StringUtils.equals("Empty value (0x) returned from contract", err.getMessage())) {
            return BigInteger.ZERO;
        }
        throw new RuntimeException(err);
    }).blockingFirst();
    assertThat(actualValue).isEqualTo(expectedValue);
}
Also used : AbstractSpecImplementation(com.quorum.gauge.core.AbstractSpecImplementation) StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) EthChainId(com.quorum.gauge.ext.EthChainId) TransactionException(org.web3j.protocol.exceptions.TransactionException) PrivacyFlag(com.quorum.gauge.common.PrivacyFlag) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Response(org.web3j.protocol.core.Response) AtomicReference(java.util.concurrent.atomic.AtomicReference) Credentials(org.web3j.crypto.Credentials) ExtensionService(com.quorum.gauge.services.ExtensionService) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) DataStore(com.thoughtworks.gauge.datastore.DataStore) Context(com.quorum.gauge.common.Context) Service(org.springframework.stereotype.Service) WalletUtils(org.web3j.crypto.WalletUtils) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) DataStoreFactory(com.thoughtworks.gauge.datastore.DataStoreFactory) Node(com.quorum.gauge.common.QuorumNetworkProperty.Node) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step) Logger(org.slf4j.Logger) QuorumNode(com.quorum.gauge.common.QuorumNode) QuorumNetworkProperty(com.quorum.gauge.common.QuorumNetworkProperty) Ints(com.google.common.primitives.Ints) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) Stream(java.util.stream.Stream) WalletData(com.quorum.gauge.common.config.WalletData) org.web3j.protocol.core.methods.response(org.web3j.protocol.core.methods.response) Table(com.thoughtworks.gauge.Table) Context(com.quorum.gauge.common.Context) BigInteger(java.math.BigInteger) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 5 with Contract

use of org.web3j.tx.Contract in project quorum-acceptance-tests by ConsenSys.

the class MultiTenancy method deployNodeManagedPublicContract.

@Step("`<clientName>` deploys a <contractId> public contract, named <contractName>, by sending a transaction to `<node>` using `<ethAccount>`")
public void deployNodeManagedPublicContract(String clientName, String contractId, String contractName, Node node, String ethAccount) {
    Contract contract = requestAccessToken(clientName).flatMap(t -> contractService.createPublicSimpleContract(42, node, ethAccount)).doOnTerminate(Context::removeAccessToken).doOnNext(c -> {
        if (c == null || !c.getTransactionReceipt().isPresent()) {
            throw new RuntimeException("contract not deployed");
        }
    }).blockingFirst();
    logger.debug("Saving contract address {} with name {}", contract.getContractAddress(), contractName);
    DataStoreFactory.getScenarioDataStore().put(contractName, contract);
}
Also used : AbstractSpecImplementation(com.quorum.gauge.core.AbstractSpecImplementation) StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) EthChainId(com.quorum.gauge.ext.EthChainId) TransactionException(org.web3j.protocol.exceptions.TransactionException) PrivacyFlag(com.quorum.gauge.common.PrivacyFlag) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Response(org.web3j.protocol.core.Response) AtomicReference(java.util.concurrent.atomic.AtomicReference) Credentials(org.web3j.crypto.Credentials) ExtensionService(com.quorum.gauge.services.ExtensionService) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) DataStore(com.thoughtworks.gauge.datastore.DataStore) Context(com.quorum.gauge.common.Context) Service(org.springframework.stereotype.Service) WalletUtils(org.web3j.crypto.WalletUtils) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) DataStoreFactory(com.thoughtworks.gauge.datastore.DataStoreFactory) Node(com.quorum.gauge.common.QuorumNetworkProperty.Node) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step) Logger(org.slf4j.Logger) QuorumNode(com.quorum.gauge.common.QuorumNode) QuorumNetworkProperty(com.quorum.gauge.common.QuorumNetworkProperty) Ints(com.google.common.primitives.Ints) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) Stream(java.util.stream.Stream) WalletData(com.quorum.gauge.common.config.WalletData) org.web3j.protocol.core.methods.response(org.web3j.protocol.core.methods.response) Table(com.thoughtworks.gauge.Table) Context(com.quorum.gauge.common.Context) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Aggregations

Contract (org.web3j.tx.Contract)149 Step (com.thoughtworks.gauge.Step)132 TransactionReceipt (org.web3j.protocol.core.methods.response.TransactionReceipt)49 Service (org.springframework.stereotype.Service)47 PrivacyFlag (com.quorum.gauge.common.PrivacyFlag)43 Collectors (java.util.stream.Collectors)42 Logger (org.slf4j.Logger)42 LoggerFactory (org.slf4j.LoggerFactory)42 QuorumNode (com.quorum.gauge.common.QuorumNode)41 AbstractSpecImplementation (com.quorum.gauge.core.AbstractSpecImplementation)38 DataStoreFactory (com.thoughtworks.gauge.datastore.DataStoreFactory)38 BigInteger (java.math.BigInteger)38 Observable (io.reactivex.Observable)35 QuorumNetworkProperty (com.quorum.gauge.common.QuorumNetworkProperty)32 Context (com.quorum.gauge.common.Context)28 Autowired (org.springframework.beans.factory.annotation.Autowired)26 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)22 Response (org.web3j.protocol.core.Response)22 WalletData (com.quorum.gauge.common.config.WalletData)21 java.util (java.util)21