use of com.quorum.gauge.common.RetryWithDelay in project quorum-acceptance-tests by ConsenSys.
the class PublicSmartContract method verifyLogEvents.
@Step("<node> has received <expectedTxCount> transactions which contain <expectedEventCount> log events in total")
public void verifyLogEvents(QuorumNode node, int expectedTxCount, int expectedEventCount) {
List<TransactionReceipt> originalReceipts = (List<TransactionReceipt>) DataStoreFactory.getScenarioDataStore().get("receipts");
List<Observable<TransactionReceipt>> receiptsInNode = new ArrayList<>();
Scheduler scheduler = threadLocalDelegateScheduler(expectedTxCount);
for (TransactionReceipt r : originalReceipts) {
receiptsInNode.add(transactionService.getTransactionReceipt(node, r.getTransactionHash()).map(tr -> {
if (tr.getTransactionReceipt().isPresent()) {
return tr.getTransactionReceipt().get();
} else {
throw new RuntimeException("retry");
}
}).retryWhen(new RetryWithDelay(20, 3000)).subscribeOn(scheduler));
}
AtomicInteger actualTxCount = new AtomicInteger();
AtomicInteger actualEventCount = new AtomicInteger();
Observable.zip(receiptsInNode, args -> {
for (Object o : args) {
TransactionReceipt r = (TransactionReceipt) o;
assertThat(r.isStatusOK()).isTrue();
assertThat(r.getBlockNumber()).isNotEqualTo(BigInteger.ZERO);
actualTxCount.getAndIncrement();
actualEventCount.addAndGet(r.getLogs().size());
}
// but we dont care about the real result so return a dummy instead
return new Object();
}).blockingFirst();
assertThat(actualTxCount.get()).as("Transaction Count").isEqualTo(expectedTxCount);
assertThat(actualEventCount.get()).as("Log Event Count").isEqualTo(expectedEventCount);
}
use of com.quorum.gauge.common.RetryWithDelay 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.RetryWithDelay in project quorum-acceptance-tests by ConsenSys.
the class RawContractService method updateRawSimplePrivateContractUsingEthApi.
public Observable<EthGetTransactionReceipt> updateRawSimplePrivateContractUsingEthApi(String apiMethod, int newValue, String contractAddress, QuorumNode source, QuorumNode target) {
Quorum client = connectionFactory().getConnection(source);
Enclave enclave = buildEnclave(source, client);
String payload = base64SimpleStorageSetBytecode(newValue);
SendResponse storeRawResponse = enclave.storeRawRequest(payload, privacyService.id(source), Collections.emptyList());
String tmHash = base64ToHex(storeRawResponse.getKey());
EthSendTransaction sendTransactionResponse = transactionService.sendSignedPrivateTransaction(apiMethod, tmHash, source, target, contractAddress).blockingFirst();
Optional<String> responseError = Optional.ofNullable(sendTransactionResponse.getError()).map(Response.Error::getMessage);
responseError.ifPresent(e -> logger.error("EthSendTransaction error: {}", e));
logger.debug("sent tx: {}", sendTransactionResponse.getTransactionHash());
return transactionService.getTransactionReceipt(source, sendTransactionResponse.getTransactionHash()).map(ethGetTransactionReceipt -> {
if (ethGetTransactionReceipt.getTransactionReceipt().isPresent()) {
return ethGetTransactionReceipt;
} else {
throw new RuntimeException("retry");
}
}).retryWhen(new RetryWithDelay(20, 3000));
}
use of com.quorum.gauge.common.RetryWithDelay in project quorum-acceptance-tests by ConsenSys.
the class AccumulatorSmartContract method getTransactionReceipt.
private TransactionReceipt getTransactionReceipt(QuorumNetworkProperty.Node node, String txReference) {
String transactionHash = mustHaveValue(DataStoreFactory.getScenarioDataStore(), txReference, 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();
return receipt.get();
}
use of com.quorum.gauge.common.RetryWithDelay in project quorum-acceptance-tests by ConsenSys.
the class TransactionService method waitForTransactionReceipt.
public TransactionReceipt waitForTransactionReceipt(QuorumNode node, String transactionHash) {
Optional<TransactionReceipt> receipt = 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();
return receipt.get();
}
Aggregations