Search in sources :

Example 26 with Context

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

the class MultiTenancy method notAuthorizedToAcceptContractExtension.

@Step("From `<targetNode>` `<targetClientName>` <expectedErr> to accept `<contractName>` extension, private from `<targetParty>` using `<targetEthAccount>` and private for `<sourceParty>`")
public void notAuthorizedToAcceptContractExtension(Node targetNode, String targetClientName, String expectedErr, String contractName, String targetParty, String targetEthAccount, String sourceParty) {
    DataStore store = DataStoreFactory.getScenarioDataStore();
    PrivacyFlag privacyFlag = mustHaveValue(store, contractName + "_privacyFlag", PrivacyFlag.class);
    String contractAddress = mustHaveValue(store, contractName + "extensionAddress", String.class);
    obtainAccessToken(targetClientName);
    Optional<String> accessToken = haveValue(DataStoreFactory.getScenarioDataStore(), "access_token", String.class);
    accessToken.ifPresent(Context::storeAccessToken);
    extensionService.acceptExtension(targetNode, true, targetEthAccount, privacyService.id(targetParty), contractAddress, List.of(privacyService.id(sourceParty)), 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) DataStore(com.thoughtworks.gauge.datastore.DataStore) PrivacyFlag(com.quorum.gauge.common.PrivacyFlag) Step(com.thoughtworks.gauge.Step)

Example 27 with Context

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

the class MultiTenancy method getCodeSizeWithAssertion.

private void getCodeSizeWithAssertion(String clientName, String contractName, String targetContractName, Node source, Consumer<BigInteger> assertFunc) {
    Contract reader = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName, Contract.class);
    Contract target = mustHaveValue(DataStoreFactory.getScenarioDataStore(), targetContractName, Contract.class);
    obtainAccessToken(clientName);
    Optional<String> accessToken = haveValue(DataStoreFactory.getScenarioDataStore(), "access_token", String.class);
    accessToken.ifPresent(Context::storeAccessToken);
    BigInteger actual = contractCodeReaderService.getCodeSize(source, reader.getContractAddress(), target.getContractAddress()).doOnTerminate(Context::removeAccessToken).blockingFirst();
    assertFunc.accept(actual);
}
Also used : Context(com.quorum.gauge.common.Context) BigInteger(java.math.BigInteger) Contract(org.web3j.tx.Contract)

Example 28 with Context

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

the class ContractExtension method getListedStatus.

public Optional<Map<Object, Object>> getListedStatus(final QuorumNetworkProperty.Node node, final String contractName) {
    final Optional<String> accessToken = haveValue(DataStoreFactory.getScenarioDataStore(), "access_token", String.class);
    accessToken.ifPresent(Context::storeAccessToken);
    final Contract contract = mustHaveValue(contractName, Contract.class);
    final QuorumActiveExtensionContracts result = this.extensionService.getExtensionContracts(node).blockingFirst();
    Context.removeAccessToken();
    return result.getResult().stream().filter(contractStatus -> contractStatus.containsValue(contract.getContractAddress())).findFirst();
}
Also used : Context(com.quorum.gauge.common.Context) Contract(org.web3j.tx.Contract) AbstractSpecImplementation(com.quorum.gauge.core.AbstractSpecImplementation) Step(com.thoughtworks.gauge.Step) Logger(org.slf4j.Logger) PrivacyFlag(com.quorum.gauge.common.PrivacyFlag) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) QuorumNetworkProperty(com.quorum.gauge.common.QuorumNetworkProperty) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) ExtensionService(com.quorum.gauge.services.ExtensionService) TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt) Stream(java.util.stream.Stream) DataStore(com.thoughtworks.gauge.datastore.DataStore) Context(com.quorum.gauge.common.Context) Service(org.springframework.stereotype.Service) com.quorum.gauge.ext.contractextension(com.quorum.gauge.ext.contractextension) Map(java.util.Map) Optional(java.util.Optional) DataStoreFactory(com.thoughtworks.gauge.datastore.DataStoreFactory) Contract(org.web3j.tx.Contract)

Aggregations

Context (com.quorum.gauge.common.Context)28 Contract (org.web3j.tx.Contract)26 Step (com.thoughtworks.gauge.Step)23 PrivacyFlag (com.quorum.gauge.common.PrivacyFlag)18 DataStore (com.thoughtworks.gauge.datastore.DataStore)17 BigInteger (java.math.BigInteger)17 Collectors (java.util.stream.Collectors)17 Logger (org.slf4j.Logger)17 LoggerFactory (org.slf4j.LoggerFactory)17 Autowired (org.springframework.beans.factory.annotation.Autowired)17 Service (org.springframework.stereotype.Service)17 QuorumNetworkProperty (com.quorum.gauge.common.QuorumNetworkProperty)16 AbstractSpecImplementation (com.quorum.gauge.core.AbstractSpecImplementation)16 ExtensionService (com.quorum.gauge.services.ExtensionService)16 DataStoreFactory (com.thoughtworks.gauge.datastore.DataStoreFactory)16 Stream (java.util.stream.Stream)16 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)16 Observable (io.reactivex.Observable)15 StringUtils (org.apache.commons.lang.StringUtils)15 Ints (com.google.common.primitives.Ints)14