Skip to content

Commit

Permalink
Add resilience and account checksum support (#2253)
Browse files Browse the repository at this point in the history
Acceptance tests occasionally get tripped up on receipt issues. e.g.

`AbstractNetworkClient Executed transaction 0.0.950-gdccm@1625765044.706778777 with 1 signatures`
Additionally the SDK has support for checksum but the Mirrornode does not

Add receipt status exception to retry list
Add support for removing checksum from transaction id prior to calling mirror node

Signed-off-by: Nana-EC <nana.essilfie-conduah@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
  • Loading branch information
Nana-EC authored and Ian Jungmann committed Jul 16, 2021
1 parent dee2ab0 commit 1a5d6f2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import reactor.netty.tcp.TcpClient;

import com.hedera.hashgraph.sdk.PrecheckStatusException;
import com.hedera.hashgraph.sdk.ReceiptStatusException;

@Configuration
@RequiredArgsConstructor
Expand All @@ -63,7 +64,8 @@ RetryTemplate retryTemplate() {
Map retryableExceptionMap = Map.of(
PrecheckStatusException.class, true,
TimeoutException.class, true,
RuntimeException.class, true); // make configurable
RuntimeException.class, true,
ReceiptStatusException.class, true); // make configurable
SimpleRetryPolicy simpleRetryPolicy = new SimpleRetryPolicy(
acceptanceTestProperties.getMaxRetries(),
retryableExceptionMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public String getTransactionIdString() {
.getEpochSecond() + "-" + getPaddedNanos();
}

// interim function until mirror node supports checksum
public String getTransactionIdStringNoCheckSum() {
String accountIdString = transactionId.accountId.toString().split("-")[0];
return accountIdString + "-" + transactionId.validStart
.getEpochSecond() + "-" + getPaddedNanos();
}

public String getValidStartString() {

// left pad nanos with zeros where applicable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public void verifyPartialScheduleFromNetwork() throws Exception {
@Then("the mirror node REST API should return status {int} for the schedule transaction")
public void verifyMirrorAPIResponses(int status) {
log.info("Verify schedule transaction");
String transactionId = networkTransactionResponse.getTransactionIdString();
String transactionId = networkTransactionResponse.getTransactionIdStringNoCheckSum();
MirrorTransactionsResponse mirrorTransactionsResponse = mirrorClient.getTransactions(transactionId);

MirrorTransaction mirrorTransaction = verifyMirrorTransactionsResponse(mirrorTransactionsResponse, status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ private void transferNfts(TokenId tokenId, ExpandedAccountId sender, AccountId r
}

private MirrorTransaction verifyTransactions(int status) {
String transactionId = networkTransactionResponse.getTransactionIdString();
String transactionId = networkTransactionResponse.getTransactionIdStringNoCheckSum();
MirrorTransactionsResponse mirrorTransactionsResponse = mirrorClient.getTransactions(transactionId);

List<MirrorTransaction> transactions = mirrorTransactionsResponse.getTransactions();
Expand Down Expand Up @@ -476,7 +476,7 @@ private MirrorNftResponse verifyNft() {
}

private void verifyTokenTransfers() {
String transactionId = networkTransactionResponse.getTransactionIdString();
String transactionId = networkTransactionResponse.getTransactionIdStringNoCheckSum();
MirrorTransactionsResponse mirrorTransactionsResponse = mirrorClient.getTransactions(transactionId);

List<MirrorTransaction> transactions = mirrorTransactionsResponse.getTransactions();
Expand Down

0 comments on commit 1a5d6f2

Please sign in to comment.