use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN in project hedera-services by hashgraph.
the class ScheduleExecutionSpecs method scheduledXferFailingWithNonNetZeroTokenTransferPaysServiceFeeButNoImpact.
private HapiApiSpec scheduledXferFailingWithNonNetZeroTokenTransferPaysServiceFeeButNoImpact() {
String xToken = "XXX", yToken = "YYY";
String validSchedule = "withZeroNetTokenChange";
String invalidSchedule = "withNonZeroNetTokenChange";
String schedulePayer = "somebody", xTreasury = "xt", xCivilian = "xc";
String successTxn = "good", failedTxn = "bad";
AtomicReference<Map<AccountID, Long>> successFeesObs = new AtomicReference<>();
AtomicReference<Map<AccountID, Long>> failureFeesObs = new AtomicReference<>();
return defaultHapiSpec("ScheduledXferFailingWithRepeatedTokenIdPaysServiceFeeButNoImpact").given(cryptoCreate(schedulePayer), cryptoCreate(xTreasury), cryptoCreate(xCivilian), tokenCreate(xToken).treasury(xTreasury).initialSupply(101), tokenAssociate(xCivilian, xToken)).when(scheduleCreate(validSchedule, cryptoTransfer(moving(1, xToken).between(xTreasury, xCivilian))).via(successTxn).alsoSigningWith(xTreasury, schedulePayer).designatingPayer(schedulePayer), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), getAccountBalance(xCivilian).hasTokenBalance(xToken, 1), getTxnRecord(successTxn).scheduled().logged().revealingDebitsTo(successFeesObs::set), scheduleCreate(invalidSchedule, cryptoTransfer(moving(1, xToken).between(xTreasury, xCivilian)).breakingNetZeroInvariant()).via(failedTxn).alsoSigningWith(xTreasury, schedulePayer).designatingPayer(schedulePayer)).then(getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN)).revealingDebitsTo(failureFeesObs::set), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), getAccountBalance(xCivilian).hasTokenBalance(xToken, 1), assertionsHold((spec, opLog) -> assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}
Aggregations