use of com.quorum.gauge.common.Context in project quorum-acceptance-tests by ConsenSys.
the class MultiTenancy method setSimpleContractValue.
@Step("`<clientName>` writes a new value <newValue> to <contractName> successfully by sending a transaction to `<node>`")
public void setSimpleContractValue(String clientName, int newValue, String contractName, QuorumNetworkProperty.Node node) {
long chainId = rpcService.call(node, "eth_chainId", Collections.emptyList(), EthChainId.class).blockingFirst().getChainId();
Contract contract = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName, Contract.class);
assertThat(requestAccessToken(clientName).flatMap(t -> rawContractService.updateRawSimplePublicContract(node, networkProperty.getWallets().get("Wallet1"), contract.getContractAddress(), newValue, chainId)).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 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();
}
use of com.quorum.gauge.common.Context in project quorum-acceptance-tests by ConsenSys.
the class MultiTenancy method getCodeWithAssertion.
private void getCodeWithAssertion(String clientName, String contractName, String targetContractName, Node source, Consumer<byte[]> 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);
byte[] actual = contractCodeReaderService.getCode(source, reader.getContractAddress(), target.getContractAddress()).doOnTerminate(Context::removeAccessToken).blockingFirst();
assertFunc.accept(actual);
}
use of com.quorum.gauge.common.Context in project quorum-acceptance-tests by ConsenSys.
the class MultiTenancy method canReadContract.
@Step("`<clientNames>` can read <contractName> on `<node>`")
public void canReadContract(String clientNames, String contractName, Node node) {
Contract existingContract = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName, Contract.class);
Observable.fromIterable(Arrays.stream(clientNames.split(",")).map(String::trim).collect(Collectors.toList())).forEach(clientName -> {
obtainAccessToken(clientName);
Optional<String> accessToken = haveValue(DataStoreFactory.getScenarioDataStore(), "access_token", String.class);
accessToken.ifPresent(Context::storeAccessToken);
BigInteger actualValue = contractService.readSimpleContractValue(node, existingContract.getContractAddress()).doOnTerminate(Context::removeAccessToken).blockingFirst();
assertThat(actualValue).as(clientName).isNotZero();
});
}
use of com.quorum.gauge.common.Context in project quorum-acceptance-tests by ConsenSys.
the class MultiTenancy method setLastCodeSizeFails.
@Step("`<clientName>` fails to invoke 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 setLastCodeSizeFails(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);
assertThatThrownBy(() -> contractCodeReaderService.setLastCodeSize(source, reader.getContractAddress(), target.getContractAddress(), ethAccountAlias, privateFromAlias, List.of(privateForAlias)).doOnTerminate(Context::removeAccessToken).blockingSubscribe()).hasMessageContaining("not authorized");
}
Aggregations