Search in sources :

Example 1 with PrivacyFlag

use of com.quorum.gauge.common.PrivacyFlag in project quorum-acceptance-tests by ConsenSys.

the class NestedPrivateContract method callNewContractC2.

@Step("Execute <privacyFlags> <contractName>'s `newContractC2()` function with new value <newValue> in <source> and it's private for <target>")
public void callNewContractC2(String privacyFlags, String contractName, int newValue, QuorumNode source, String target) {
    Contract c1 = mustHaveValue(contractName, Contract.class);
    TransactionReceipt receipt = nestedContractService.newContractC2(source, Arrays.stream(target.split(",")).map(s -> QuorumNode.valueOf(s)).collect(Collectors.toList()), c1.getContractAddress(), BigInteger.valueOf(newValue), Arrays.stream(privacyFlags.split(",")).map(PrivacyFlag::valueOf).collect(Collectors.toList())).blockingFirst();
    Gauge.writeMessage("Transaction Hash %s", receipt.getTransactionHash());
    DataStoreFactory.getScenarioDataStore().put("transactionHash", receipt.getTransactionHash());
}
Also used : Contract(org.web3j.tx.Contract) AbstractSpecImplementation(com.quorum.gauge.core.AbstractSpecImplementation) Arrays(java.util.Arrays) Step(com.thoughtworks.gauge.Step) Logger(org.slf4j.Logger) Gauge(com.thoughtworks.gauge.Gauge) PrivacyFlag(com.quorum.gauge.common.PrivacyFlag) QuorumNode(com.quorum.gauge.common.QuorumNode) LoggerFactory(org.slf4j.LoggerFactory) Collectors(java.util.stream.Collectors) TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt) Service(org.springframework.stereotype.Service) BigInteger(java.math.BigInteger) DataStoreFactory(com.thoughtworks.gauge.datastore.DataStoreFactory) TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 2 with PrivacyFlag

use of com.quorum.gauge.common.PrivacyFlag in project quorum-acceptance-tests by ConsenSys.

the class MultiTenancy method notAuthorizedToExtendContract.

@Step("`<sourceClientName>` <expectedErr> to extend <contractName> on `<sourceNode>` private from `<sourceParty>` using `<sourceEthAccount>` to `<targetClientName>`'s `<targetParty>` on `<targetNode>` with acceptance by `<targetEthAccount>`")
public void notAuthorizedToExtendContract(String sourceClientName, String expectedErr, String contractName, Node sourceNode, String sourceParty, String sourceEthAccount, String targetClientName, String targetParty, Node targetNode, String targetEthAccount) {
    Contract existingContract = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName, Contract.class);
    PrivacyFlag privacyFlag = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName + "_privacyFlag", PrivacyFlag.class);
    Optional<String> accessToken = haveValue(DataStoreFactory.getScenarioDataStore(), "access_token", String.class);
    accessToken.ifPresent(Context::storeAccessToken);
    extensionService.initiateContractExtension(sourceNode, sourceEthAccount, sourceParty, existingContract.getContractAddress(), targetNode, targetEthAccount, targetParty, privacyFlag).doOnNext(res -> {
        assertThat(res.getError()).as("expected error to return").isNotNull();
        assertThat(res.getError().getMessage()).contains(expectedErr);
    }).doOnTerminate(Context::removeAccessToken).blockingSubscribe();
}
Also used : Context(com.quorum.gauge.common.Context) PrivacyFlag(com.quorum.gauge.common.PrivacyFlag) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 3 with PrivacyFlag

use of com.quorum.gauge.common.PrivacyFlag in project quorum-acceptance-tests by ConsenSys.

the class ContractExtension method createInavlidContractExtension.

@Step("Initiating extension of <contractName> to <newNode> with its default account as recipient from <creator> should fail with error <expErrMsg>")
public void createInavlidContractExtension(final String contractName, final QuorumNetworkProperty.Node newNode, final QuorumNetworkProperty.Node creator, final String expErrMsg) {
    PrivacyFlag privacyFlag = PrivacyFlag.StandardPrivate;
    DataStoreFactory.getScenarioDataStore().put("privacyFlag", privacyFlag);
    final Set<QuorumNetworkProperty.Node> allNodes = Stream.of(newNode, creator).collect(Collectors.toSet());
    DataStoreFactory.getScenarioDataStore().put("extensionAllNodes", allNodes);
    final Contract existingContract = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName, Contract.class);
    final QuorumExtendContract result = extensionService.initiateContractExtension(creator, existingContract.getContractAddress(), newNode, privacyFlag).blockingFirst();
    assertThat(result.getError().getMessage()).isEqualTo(expErrMsg);
}
Also used : PrivacyFlag(com.quorum.gauge.common.PrivacyFlag) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 4 with PrivacyFlag

use of com.quorum.gauge.common.PrivacyFlag in project quorum-acceptance-tests by ConsenSys.

the class ContractExtension method createInvalidExtensionProposition.

@Step("Initiate <contractName> extension from non creating node <fromNode> to <newNode> should fail with error message <errMsg>")
public void createInvalidExtensionProposition(final String contractName, final QuorumNetworkProperty.Node fromNode, final QuorumNetworkProperty.Node newNode, final String errMsg) throws InterruptedException {
    PrivacyFlag privacyFlag = PrivacyFlag.StandardPrivate;
    DataStoreFactory.getScenarioDataStore().put("privacyFlag", privacyFlag);
    final Set<QuorumNetworkProperty.Node> allNodes = Stream.of(fromNode, newNode).collect(Collectors.toSet());
    DataStoreFactory.getScenarioDataStore().put("extensionAllNodes", allNodes);
    final Contract existingContract = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName, Contract.class);
    final QuorumExtendContract result = extensionService.initiateContractExtension(fromNode, existingContract.getContractAddress(), newNode, privacyFlag).blockingFirst();
    assertThat(result.getError().getMessage()).isEqualTo(errMsg);
}
Also used : PrivacyFlag(com.quorum.gauge.common.PrivacyFlag) Contract(org.web3j.tx.Contract) Step(com.thoughtworks.gauge.Step)

Example 5 with PrivacyFlag

use of com.quorum.gauge.common.PrivacyFlag in project quorum-acceptance-tests by ConsenSys.

the class ContractExtension method acceptExtension.

@Step("<newNode> accepts the offer to extend the contract <contractName>")
public void acceptExtension(final QuorumNetworkProperty.Node newNode, final String contractName) {
    final DataStore store = DataStoreFactory.getScenarioDataStore();
    final PrivacyFlag privacyFlag = mustHaveValue(store, "privacyFlag", PrivacyFlag.class);
    final String contractAddress = mustHaveValue(store, contractName + "extensionAddress", String.class);
    final Set<QuorumNetworkProperty.Node> allNodes = mustHaveValue(store, "extensionAllNodes", Set.class);
    final QuorumVoteOnContract result = this.extensionService.acceptExtension(newNode, true, contractAddress, allNodes, privacyFlag).blockingFirst();
    if (result.getError() != null) {
        logger.error(result.getError().toString());
    }
    assertThat(result.getError()).isNull();
    final Optional<TransactionReceipt> transactionReceipt = transactionService.pollTransactionReceipt(newNode, result.getResult());
    assertThat(transactionReceipt.isPresent()).isTrue();
    assertThat(transactionReceipt.get().getStatus()).isEqualTo("0x1");
}
Also used : DataStore(com.thoughtworks.gauge.datastore.DataStore) TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt) PrivacyFlag(com.quorum.gauge.common.PrivacyFlag) Step(com.thoughtworks.gauge.Step)

Aggregations

PrivacyFlag (com.quorum.gauge.common.PrivacyFlag)33 Contract (org.web3j.tx.Contract)23 Step (com.thoughtworks.gauge.Step)22 Collectors (java.util.stream.Collectors)22 Service (org.springframework.stereotype.Service)22 TransactionReceipt (org.web3j.protocol.core.methods.response.TransactionReceipt)19 Logger (org.slf4j.Logger)17 LoggerFactory (org.slf4j.LoggerFactory)17 Observable (io.reactivex.Observable)16 BigInteger (java.math.BigInteger)16 QuorumNetworkProperty (com.quorum.gauge.common.QuorumNetworkProperty)15 QuorumNode (com.quorum.gauge.common.QuorumNode)15 List (java.util.List)13 AbstractSpecImplementation (com.quorum.gauge.core.AbstractSpecImplementation)12 DataStoreFactory (com.thoughtworks.gauge.datastore.DataStoreFactory)12 Arrays (java.util.Arrays)12 Autowired (org.springframework.beans.factory.annotation.Autowired)12 AbstractService (com.quorum.gauge.services.AbstractService)9 EthChainId (com.quorum.gauge.ext.EthChainId)8 PrivateClientTransactionManager (com.quorum.gauge.ext.PrivateClientTransactionManager)8