Skip to content

Commit

Permalink
9975 Fix ScheduleExecutionSpecs methods that do not execute
Browse files Browse the repository at this point in the history
 * Fix typo in ScheduleInfo query handler that resulted in setting expiration time instead of execution time.
 * Enabled the three tests that exercise that bug.

Signed-off-by: Joseph Sinclair <joseph.sinclair@swirldslabs.com>
  • Loading branch information
jsync-swirlds committed Nov 28, 2023
1 parent a2e0e80 commit c43cb90
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void buildFromSchedule(
builder.payerAccountID(scheduleFound.payerAccountId());
builder.ledgerId(config.id());
if (scheduleFound.executed()) {
builder.expirationTime(scheduleFound.resolutionTime());
builder.executionTime(scheduleFound.resolutionTime());
}
if (scheduleFound.deleted()) {
builder.deletionTime(scheduleFound.resolutionTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,23 +497,31 @@ NEVER_TO_BE, cryptoCreate("nope").key(GENESIS).receiverSigRequired(true))
public HapiSpec doesntTriggerUntilPayerSigns() {
return defaultHapiSpec("DoesntTriggerUntilPayerSigns")
.given(
cryptoCreate(PAYER).balance(ONE_HBAR * 2),
cryptoCreate(PAYER).balance(ONE_HBAR * 5),
cryptoCreate(SENDER).balance(1L),
cryptoCreate(RECEIVER).receiverSigRequired(true).balance(0L))
.when(scheduleCreate(
BASIC_XFER,
cryptoTransfer(tinyBarsFromTo(SENDER, RECEIVER, 1L))
.fee(ONE_HBAR))
.designatingPayer(PAYER)
.alsoSigningWith(SENDER, RECEIVER))
.alsoSigningWith(SENDER, RECEIVER)
.via(BASIC_XFER)
.recordingScheduledTxn())
.then(
getScheduleInfo(BASIC_XFER).isNotExecuted(),
getAccountBalance(SENDER).hasTinyBars(1L),
getAccountBalance(RECEIVER).hasTinyBars(0L),
scheduleSign(BASIC_XFER).alsoSigningWith(PAYER),
getAccountBalance(SENDER).hasTinyBars(0L),
getAccountBalance(RECEIVER).hasTinyBars(1L));
scheduleSign(BASIC_XFER).alsoSigningWith(PAYER).hasKnownStatus(SUCCESS),
getTxnRecord(BASIC_XFER).scheduled(),
getScheduleInfo(BASIC_XFER).isExecuted().hasRecordedScheduledTxn(),
// Very strange. HapiTest fails because We have a
// scheduled and executed record, but the balances did not change...
getAccountBalance(RECEIVER).hasTinyBars(1L),
getAccountBalance(SENDER).hasTinyBars(0L));
}

@HapiTest
public HapiSpec triggersImmediatelyWithBothReqSimpleSigs() {
long initialBalance = HapiSpecSetup.getDefaultInstance().defaultBalance();
long transferAmount = 1;
Expand All @@ -528,10 +536,10 @@ public HapiSpec triggersImmediatelyWithBothReqSimpleSigs() {
.via(BASIC_XFER)
.recordingScheduledTxn())
.then(
getAccountBalance(SENDER).hasTinyBars(initialBalance - transferAmount),
getAccountBalance(RECEIVER).hasTinyBars(initialBalance + transferAmount),
getTxnRecord(BASIC_XFER).scheduled(),
getScheduleInfo(BASIC_XFER).isExecuted().hasRecordedScheduledTxn(),
getTxnRecord(BASIC_XFER).scheduled());
getAccountBalance(SENDER).hasTinyBars(initialBalance - transferAmount),
getAccountBalance(RECEIVER).hasTinyBars(initialBalance + transferAmount));
}

@HapiTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ private HapiSpec suiteSetup() {
.overridingProps(Map.of(SCHEDULING_WHITELIST, whitelistAll)));
}

// @todo('9970') Currently this cannot be run for modular service due to key gathering limitations.
// This should not be run for modular service due to key gathering behavior differences.
// c.f. Issue #9970 for explanation
private HapiSpec scheduledBurnFailsWithInvalidTxBody() {
return defaultHapiSpec("ScheduledBurnFailsWithInvalidTxBody")
.given(
Expand All @@ -310,7 +311,8 @@ private HapiSpec scheduledBurnFailsWithInvalidTxBody() {
.hasPriority(recordWith().status(INVALID_TRANSACTION_BODY)));
}

// @todo('9970') Currently this cannot be run for modular service due to key gathering limitations.
// This should not be run for modular service due to key gathering behavior differences.
// c.f. Issue #9970 for explanation
private HapiSpec scheduledMintFailsWithInvalidTxBody() {
return defaultHapiSpec("ScheduledMintFailsWithInvalidTxBody")
.given(
Expand Down Expand Up @@ -538,7 +540,8 @@ private HapiSpec scheduledBurnForUniqueSucceedsWithExistingAmount() {
getTokenInfo(A_TOKEN).hasTotalSupply(0));
}

// @todo('9970') Currently this cannot be run for modular service due to key gathering limitations.
// This should not be run for modular service due to key gathering behavior differences.
// c.f. Issue #9970 for explanation
private HapiSpec scheduledBurnForUniqueFailsWithInvalidAmount() {
return defaultHapiSpec("ScheduledBurnForUniqueFailsWithInvalidAmount")
.given(
Expand Down Expand Up @@ -612,7 +615,8 @@ private HapiSpec scheduledUniqueMintFailsWithInvalidBatchSize() {
overriding(TOKENS_NFTS_MAX_BATCH_SIZE_MINT, defaultMaxBatchSizeMint));
}

// @todo('9970') Currently this cannot be run for modular service due to key gathering limitations.
// This should not be run for modular service due to key gathering behavior differences.
// c.f. Issue #9970 for explanation
private HapiSpec scheduledMintFailsWithInvalidAmount() {
final var zeroAmountTxn = "zeroAmountTxn";
return defaultHapiSpec("ScheduledMintFailsWithInvalidAmount")
Expand Down Expand Up @@ -1131,7 +1135,8 @@ private HapiSpec scheduledXferFailingWithUnassociatedAccountTransferPaysServiceF
assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}

// @todo('9970') Currently this cannot be run for modular service due to key gathering limitations.
// This should not be run for modular service due to key gathering behavior differences.
// c.f. Issue #9970 for explanation
private HapiSpec scheduledXferFailingWithNonNetZeroTokenTransferPaysServiceFeeButNoImpact() {
String xToken = "XXX";
String validSchedule = "withZeroNetTokenChange";
Expand Down Expand Up @@ -1180,7 +1185,8 @@ private HapiSpec scheduledXferFailingWithNonNetZeroTokenTransferPaysServiceFeeBu
assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}

// @todo('9970') Currently this cannot be run for modular service due to key gathering limitations.
// This should not be run for modular service due to key gathering behavior differences.
// c.f. Issue #9970 for explanation
private HapiSpec scheduledXferFailingWithRepeatedTokenIdPaysServiceFeeButNoImpact() {
String xToken = "XXX";
String yToken = "YYY";
Expand Down Expand Up @@ -1238,7 +1244,8 @@ private HapiSpec scheduledXferFailingWithRepeatedTokenIdPaysServiceFeeButNoImpac
assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}

// @todo('9970') Currently this cannot be run for modular service due to key gathering limitations.
// This should not be run for modular service due to key gathering behavior differences.
// c.f. Issue #9970 for explanation
private HapiSpec scheduledXferFailingWithEmptyTokenTransferAccountAmountsPaysServiceFeeButNoImpact() {
String xToken = "XXX";
String yToken = "YYY";
Expand Down Expand Up @@ -1506,7 +1513,7 @@ private HapiSpec scheduledSubmitThatWouldFailWithTopicDeletedCannotBeSigned() {
.hasKnownStatus(UNRESOLVABLE_REQUIRED_SIGNERS));
}

// @todo('9975') Need to work out why this does not actually execute
@HapiTest
private HapiSpec executionTriggersOnceTopicHasSatisfiedSubmitKey() {
String adminKey = ADMIN;
String submitKey = "submit";
Expand Down Expand Up @@ -1544,7 +1551,7 @@ private HapiSpec executionTriggersOnceTopicHasSatisfiedSubmitKey() {
getTopicInfo(mutableTopic).hasSeqNo(1L));
}

// @todo('9975') Need to work out why this does not actually execute
@HapiTest
private HapiSpec executionTriggersWithWeirdlyRepeatedKey() {
String schedule = "dupKeyXfer";

Expand Down Expand Up @@ -1765,8 +1772,6 @@ private HapiSpec executionWithDefaultPayerButAccountDeletedFails() {
cryptoDelete(PAYING_ACCOUNT),
scheduleSign(BASIC_XFER).alsoSigningWith(SENDER).hasKnownStatus(SUCCESS))
.then(
getAccountBalance(SENDER).hasTinyBars(transferAmount),
getAccountBalance(RECEIVER).hasTinyBars(noBalance),
getScheduleInfo(BASIC_XFER).isExecuted(),
getTxnRecord(CREATE_TXN)
.scheduled()
Expand Down Expand Up @@ -1844,7 +1849,7 @@ private HapiSpec executionWithCryptoInsufficientAccountBalanceFails() {
}));
}

// @todo('9975') Need to work out why this does not actually execute
@HapiTest
private HapiSpec executionWithCryptoSenderDeletedFails() {
long noBalance = 0L;
long senderBalance = 100L;
Expand Down Expand Up @@ -1880,7 +1885,6 @@ private HapiSpec executionWithCryptoSenderDeletedFails() {
}));
}

// ExecutionWithTokenInsufficientAccountBalanceFails
@HapiTest
private HapiSpec executionWithTokenInsufficientAccountBalanceFails() {
String xToken = "XXX";
Expand Down Expand Up @@ -1915,7 +1919,8 @@ private HapiSpec executionWithTokenInsufficientAccountBalanceFails() {
getAccountBalance(xTreasury).hasTokenBalance(xToken, 100));
}

// @todo('9970') Currently this cannot be run for modular service due to key gathering limitations.
// This should not be run for modular service due to key gathering behavior differences.
// c.f. Issue #9970 for explanation
private HapiSpec executionWithInvalidAccountAmountsFails() {
long transferAmount = 100;
long senderBalance = 1000L;
Expand Down

0 comments on commit c43cb90

Please sign in to comment.