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>
  • Loading branch information
Nana-EC authored Jul 8, 2021
1 parent 50c046b commit dce4163
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 @@ -305,7 +305,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 @@ -329,7 +329,7 @@ private void transferTokens(TokenId tokenId, int amount, ExpandedAccountId sende
}

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 @@ -357,7 +357,7 @@ private MirrorTokenResponse verifyToken() {
}

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 dce4163

Please sign in to comment.