use of com.quorum.gauge.common.config.WalletData in project quorum-acceptance-tests by ConsenSys.
the class PrivateRawSmartContract method verifyTransactionReceipt.
@Step("Transaction Receipt is present in <node> for <contractName> from external wallet <wallet>")
public void verifyTransactionReceipt(QuorumNode node, String contractName, WalletData wallet) {
String transactionHash = mustHaveValue(DataStoreFactory.getScenarioDataStore(), contractName + "_transactionHash", String.class);
Optional<TransactionReceipt> receipt = transactionService.getTransactionReceipt(node, transactionHash).map(ethGetTransactionReceipt -> {
if (ethGetTransactionReceipt.getTransactionReceipt().isPresent()) {
return ethGetTransactionReceipt;
} else {
throw new RuntimeException("retry");
}
}).retryWhen(new RetryWithDelay(20, 3000)).blockingFirst().getTransactionReceipt();
assertThat(receipt.isPresent()).isTrue();
assertThat(receipt.get().getBlockNumber()).isNotEqualTo(currentBlockNumber());
final Credentials[] credentials = new Credentials[1];
assertThatCode(() -> credentials[0] = WalletUtils.loadCredentials(wallet.getWalletPass(), wallet.getWalletPath())).doesNotThrowAnyException();
assertThat(receipt.get().getFrom()).isEqualTo(credentials[0].getAddress());
}
use of com.quorum.gauge.common.config.WalletData in project quorum-acceptance-tests by ConsenSys.
the class RawContractService method updateRawSimplePrivateContract.
public Observable<TransactionReceipt> updateRawSimplePrivateContract(int newValue, String contractAddress, WalletData wallet, QuorumNode source, String sourceNamedKey, List<String> targetNamedKeys) {
Quorum client = connectionFactory().getConnection(source);
Enclave enclave = buildEnclave(source, client);
return Observable.fromCallable(() -> wallet).flatMap(walletData -> Observable.fromCallable(() -> WalletUtils.loadCredentials(walletData.getWalletPass(), walletData.getWalletPath()))).flatMap(cred -> Observable.just(quorumTransactionManager(client, cred, privacyService.id(source, sourceNamedKey), privacyService.ids(targetNamedKeys), enclave))).flatMap(qrtxm -> SimpleStorage.load(contractAddress, client, qrtxm, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).set(BigInteger.valueOf(newValue)).flowable().toObservable());
}
use of com.quorum.gauge.common.config.WalletData in project quorum-acceptance-tests by ConsenSys.
the class RawContractService method createNRawSimplePrivateContract.
public List<Observable<RawDeployedContractTarget>> createNRawSimplePrivateContract(int count, WalletData wallet, QuorumNode source, QuorumNode[] targetNodes) throws IOException, CipherException {
try {
Quorum client = connectionFactory().getConnection(source);
Credentials credentials = WalletUtils.loadCredentials(wallet.getWalletPass(), wallet.getWalletPath());
String fromAddress = credentials.getAddress();
BigInteger transactionCount = client.ethGetTransactionCount(fromAddress, DefaultBlockParameterName.LATEST).flowable().toObservable().blockingFirst().getTransactionCount();
Enclave enclave = buildEnclave(source, client);
List<Observable<RawDeployedContractTarget>> allObservableContracts = new ArrayList<>();
int counter = 0;
for (QuorumNode targetNode : targetNodes) {
RawPrivateContract[] rawPrivateContracts = new RawPrivateContract[count];
for (int j = 0; j < count; j++) {
int arbitraryValue = new Random().nextInt(50) + 1;
String payload = base64SimpleStorageConstructorBytecode(arbitraryValue);
SendResponse storeRawResponse = enclave.storeRawRequest(payload, privacyService.id(source), Collections.emptyList());
String tmHash = base64ToHex(storeRawResponse.getKey());
RawTransaction tx = RawTransaction.createContractTransaction(transactionCount.add(BigInteger.valueOf(counter)), BigInteger.ZERO, DEFAULT_GAS_LIMIT, BigInteger.ZERO, tmHash);
counter++;
rawPrivateContracts[j] = new RawPrivateContract(sign(tx, credentials), arbitraryValue, targetNode);
}
allObservableContracts.add(Observable.fromArray(rawPrivateContracts).flatMap(raw -> sendRawPrivateTransaction(source, raw.rawTransaction, targetNode).map(b -> transactionService.waitForTransactionReceipt(targetNode, b.getTransactionHash())).map(receipt -> new RawDeployedContractTarget(raw.value, raw.node, receipt)).subscribeOn(Schedulers.io())));
}
return allObservableContracts;
} catch (IOException e) {
logger.error("RawTransaction - private", e);
throw e;
} catch (CipherException e) {
logger.error("RawTransaction - private - bad credentials", e);
throw e;
}
}
use of com.quorum.gauge.common.config.WalletData in project quorum-acceptance-tests by ConsenSys.
the class RawContractService method updateRawClientReceiptPrivateContract.
public Observable<TransactionReceipt> updateRawClientReceiptPrivateContract(String contractAddress, WalletData wallet, QuorumNode source, String sourceNamedKey, List<String> targetNamedKeys) {
Quorum client = connectionFactory().getConnection(source);
Enclave enclave = buildEnclave(source, client);
return Observable.fromCallable(() -> wallet).flatMap(walletData -> Observable.fromCallable(() -> WalletUtils.loadCredentials(walletData.getWalletPass(), walletData.getWalletPath()))).flatMap(cred -> Observable.just(quorumTransactionManager(client, cred, privacyService.id(source, sourceNamedKey), privacyService.ids(targetNamedKeys), enclave))).flatMap(qrtxm -> ClientReceipt.load(contractAddress, client, qrtxm, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).deposit(new byte[32], BigInteger.ZERO).flowable().toObservable());
}
use of com.quorum.gauge.common.config.WalletData in project quorum-acceptance-tests by ConsenSys.
the class RawContractService method invokeGetFromDelegateInSneakyWrapper.
public Observable<TransactionReceipt> invokeGetFromDelegateInSneakyWrapper(int nonceShift, String contractAddress, WalletData wallet, QuorumNode source, String sourceNamedKey, List<String> targetNamedKeys) {
logger.debug("Update SimpleStorageDelegateContract@{} via a private raw transaction", contractAddress);
Quorum client = connectionFactory().getConnection(source);
Enclave enclave = buildEnclave(source, client);
return Observable.fromCallable(() -> wallet).flatMap(walletData -> Observable.fromCallable(() -> WalletUtils.loadCredentials(walletData.getWalletPass(), walletData.getWalletPath()))).flatMap(cred -> Observable.just(new PrivateClientTransactionManager(client, cred.getAddress(), privacyService.id(source, sourceNamedKey), targetNamedKeys.stream().map(privacyService::id).collect(Collectors.toList())))).flatMap(qrtxm -> SneakyWrapper.load(contractAddress, client, qrtxm, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).getFromDelegate().flowable().toObservable());
}
Aggregations