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();
}
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");
}
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();
}
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);
}
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);
}
Aggregations