use of com.quorum.gauge.common.Context 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);
}
use of com.quorum.gauge.common.Context 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);
}
use of com.quorum.gauge.common.Context in project quorum-acceptance-tests by ConsenSys.
the class MultiTenancy method setRawSimpleContractValue.
@Step("`<clientName>` writes a new arbitrary value to <contractName> successfully by sending a transaction to `<node>` with its TM key `<privateFrom>`, signed by `<wallet>` and private for `<privateFor>`")
public void setRawSimpleContractValue(String clientName, String contractName, QuorumNode node, String privateFrom, String wallet, String privateFor) {
Contract c = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName, Contract.class);
List<String> privateForList = Arrays.stream(privateFor.split(",")).map(String::trim).collect(Collectors.toList());
assertThat(requestAccessToken(clientName).flatMap(t -> rawContractService.updateRawSimplePrivateContract(100, c.getContractAddress(), networkProperty.getWallets().get(wallet), node, privateFrom, privateForList)).map(Optional::of).onErrorResumeNext(o -> {
return Observable.just(Optional.empty());
}).doOnTerminate(Context::removeAccessToken).map(r -> r.isPresent() && r.get().isStatusOK()).blockingFirst()).isTrue();
}
use of com.quorum.gauge.common.Context in project quorum-acceptance-tests by ConsenSys.
the class MultiTenancy method invokeSetDelegate.
@Step("`<clientName>` invokes setDelegate to <value> in <contractName> by sending a transaction to `<node>` with its TM key `<privateFrom>`, signed by `<wallet>` and private for `<privateFor>`")
public void invokeSetDelegate(String clientName, boolean value, String contractName, QuorumNode node, String privateFrom, String wallet, String privateFor) {
Contract c = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName, Contract.class);
List<String> privateForList = Arrays.stream(privateFor.split(",")).map(String::trim).collect(Collectors.toList());
assertThat(requestAccessToken(clientName).flatMap(t -> rawContractService.updateDelegateInSneakyWrapperContract(value, c.getContractAddress(), networkProperty.getWallets().get(wallet), node, privateFrom, privateForList)).map(Optional::of).onErrorResumeNext(o -> {
return Observable.just(Optional.empty());
}).doOnTerminate(Context::removeAccessToken).map(r -> r.isPresent() && r.get().isStatusOK()).blockingFirst()).isTrue();
}
use of com.quorum.gauge.common.Context in project quorum-acceptance-tests by ConsenSys.
the class MultiTenancy method setLastCodeSize.
@Step("`<clientName>` invokes ContractCodeReader(<reader>)'s setLastCodeSize(<target>) by sending a transaction to `<Node1>` with its TM key `<GS_K1>` using `<GS_ACC1>` and private for `<JPM_K1>`")
public void setLastCodeSize(String clientName, String contractName, String targetContractName, Node source, String privateFromAlias, String ethAccountAlias, String privateForAlias) {
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);
contractCodeReaderService.setLastCodeSize(source, reader.getContractAddress(), target.getContractAddress(), ethAccountAlias, privateFromAlias, List.of(privateForAlias)).doOnTerminate(Context::removeAccessToken).blockingSubscribe();
}
Aggregations