Skip to content

Commit

Permalink
- increase the expiration time from 8 to 16 seconds for the last test…
Browse files Browse the repository at this point in the history
… and added some additional checks
  • Loading branch information
nickeynikolovv committed Feb 6, 2025
1 parent b94461e commit 66610b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,19 @@ public class ScheduleFeature extends AbstractFeature {
"I successfully schedule a HBAR transfer from treasury to {account} with expiration time {string} and wait for expiry {string}")
public void createNewHBarTransferSchedule(
AccountNameEnum accountName, String expirationTimeInSeconds, String waitForExpiry) {
Instant expirationTime = null;

if (expirationTimeInSeconds != null && !expirationTimeInSeconds.equals("null")) {
Duration expirationOffset = DurationStyle.detectAndParse(expirationTimeInSeconds);
expirationTime = Instant.now().plus(expirationOffset);
}

currentSignersCount = SIGNATORY_COUNT_OFFSET;
currentSignersCount = SIGNATORY_COUNT_OFFSET;
var recipient = accountClient.getAccount(accountName);
var scheduledTransaction = accountClient.getCryptoTransferTransaction(
accountClient.getTokenTreasuryAccount().getAccountId(),
recipient.getAccountId(),
Hbar.fromTinybars(DEFAULT_TINY_HBAR));

Instant expirationTime = null;
if (expirationTimeInSeconds != null && !expirationTimeInSeconds.equals("null")) {
Duration expirationOffset = DurationStyle.detectAndParse(expirationTimeInSeconds);
expirationTime = Instant.now().plus(expirationOffset);
}

createNewSchedule(scheduledTransaction, expirationTime, Boolean.parseBoolean(waitForExpiry));
}

Expand All @@ -103,6 +102,12 @@ public void waitForScheduleToExpire() {
} catch (Exception e) {
log.info("Dummy transaction fails but triggers the schedule execution");
}

//Wait until the transaction is executed and has a valid executed timestamp
await().atMost(Duration.ofSeconds(30))
.pollDelay(Duration.ofMillis(100))
.pollInterval(Duration.ofMillis(100))
.untilAsserted(() -> assertThat(mirrorClient.getScheduleInfo(scheduleId.toString()).getExecutedTimestamp()).isNotNull());
}

private void createNewSchedule(Transaction<?> transaction, Instant expirationTime, boolean waitForExpiry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Feature: Schedule Base Coverage Feature
When the scheduled transaction is signed by treasuryAccount
And the mirror node REST API should return status <httpStatusCode> for the schedule transaction
And the mirror node REST API should verify the "EXECUTED" schedule entity with expiration time "60s" and wait for expiry "false"
Given I successfully schedule a HBAR transfer from treasury to ALICE with expiration time "8s" and wait for expiry "true"
Given I successfully schedule a HBAR transfer from treasury to ALICE with expiration time "16s" and wait for expiry "true"
Then the mirror node REST API should return status <httpStatusCode> for the schedule transaction
And the mirror node REST API should verify the "NON_EXECUTED" schedule entity with expiration time "8s" and wait for expiry "true"
And the mirror node REST API should verify the "NON_EXECUTED" schedule entity with expiration time "16s" and wait for expiry "true"
When the scheduled transaction is signed by treasuryAccount
And the mirror node REST API should return status <httpStatusCode> for the schedule transaction
Then I wait until the schedule's expiration time
And the mirror node REST API should verify the "EXECUTED" schedule entity with expiration time "8s" and wait for expiry "true"
And the mirror node REST API should verify the "EXECUTED" schedule entity with expiration time "16s" and wait for expiry "true"

Examples:
| httpStatusCode |
Expand Down

0 comments on commit 66610b9

Please sign in to comment.