use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class ScheduleExecutionSpecs method scheduledXferFailingWithNonKycedAccountTransferPaysServiceFeeButNoImpact.
private HapiApiSpec scheduledXferFailingWithNonKycedAccountTransferPaysServiceFeeButNoImpact() {
String xToken = "XXX";
String validSchedule = "withKycedToken";
String invalidSchedule = "withNonKycedToken";
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("ScheduledXferFailingWithNonKycedAccountTransferPaysServiceFeeButNoImpact").given(newKeyNamed("kyc"), cryptoCreate(schedulePayer), cryptoCreate(xTreasury), cryptoCreate(xCivilian), tokenCreate(xToken).treasury(xTreasury).initialSupply(101).kycKey("kyc"), tokenAssociate(xCivilian, xToken), grantTokenKyc(xToken, xCivilian)).when(scheduleCreate(validSchedule, cryptoTransfer(moving(1, xToken).between(xTreasury, xCivilian)).memo(randomUppercase(100))).via(successTxn).alsoSigningWith(xTreasury, schedulePayer).designatingPayer(schedulePayer), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), getAccountBalance(xCivilian).hasTokenBalance(xToken, 1), getTxnRecord(successTxn).scheduled().logged().revealingDebitsTo(successFeesObs::set), revokeTokenKyc(xToken, xCivilian), scheduleCreate(invalidSchedule, cryptoTransfer(moving(1, xToken).between(xTreasury, xCivilian)).memo(randomUppercase(100))).via(failedTxn).alsoSigningWith(xTreasury, schedulePayer).designatingPayer(schedulePayer)).then(getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN)).revealingDebitsTo(failureFeesObs::set), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), assertionsHold((spec, opLog) -> assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class ScheduleExecutionSpecs method scheduledSubmitFailedWithMsgSizeTooLargeStillPaysServiceFeeButHasNoImpact.
private HapiApiSpec scheduledSubmitFailedWithMsgSizeTooLargeStillPaysServiceFeeButHasNoImpact() {
String immutableTopic = "XXX";
String validSchedule = "withValidSize";
String invalidSchedule = "withInvalidSize";
String schedulePayer = "somebody";
String successTxn = "good", failedTxn = "bad";
AtomicReference<Map<AccountID, Long>> successFeesObs = new AtomicReference<>();
AtomicReference<Map<AccountID, Long>> failureFeesObs = new AtomicReference<>();
var maxValidLen = HapiSpecSetup.getDefaultNodeProps().getInteger("consensus.message.maxBytesAllowed");
return defaultHapiSpec("ScheduledSubmitFailedWithMsgSizeTooLargeStillPaysServiceFeeButHasNoImpact").given(createTopic(immutableTopic), cryptoCreate(schedulePayer)).when(scheduleCreate(validSchedule, submitMessageTo(immutableTopic).message(randomUppercase(maxValidLen))).designatingPayer(schedulePayer).via(successTxn).signedBy(DEFAULT_PAYER, schedulePayer), getTopicInfo(immutableTopic).hasSeqNo(1L), getTxnRecord(successTxn).scheduled().logged().revealingDebitsTo(successFeesObs::set), scheduleCreate(invalidSchedule, submitMessageTo(immutableTopic).message(randomUppercase(maxValidLen + 1))).designatingPayer(schedulePayer).via(failedTxn).signedBy(DEFAULT_PAYER, schedulePayer)).then(getTopicInfo(immutableTopic).hasSeqNo(1L), getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(MESSAGE_SIZE_TOO_LARGE)).revealingDebitsTo(failureFeesObs::set), assertionsHold((spec, opLog) -> assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class ScheduleExecutionSpecs method scheduledSubmitThatWouldFailWithInvalidTopicIdCannotBeScheduled.
private HapiApiSpec scheduledSubmitThatWouldFailWithInvalidTopicIdCannotBeScheduled() {
String civilianPayer = "somebody";
AtomicReference<Map<AccountID, Long>> successFeesObs = new AtomicReference<>();
AtomicReference<Map<AccountID, Long>> failureFeesObs = new AtomicReference<>();
return defaultHapiSpec("ScheduledSubmitThatWouldFailWithInvalidTopicIdCannotBeScheduled").given(cryptoCreate(civilianPayer), createTopic("fascinating")).when(scheduleCreate("yup", submitMessageTo("fascinating").message("Little did they care who danced between / " + "And little she by whom her dance was seen")).payingWith(civilianPayer).via("creation"), scheduleCreate("nope", submitMessageTo("1.2.3").message("Little did they care who danced between / " + "And little she by whom her dance was seen")).payingWith(civilianPayer).via("nothingShouldBeCreated").hasKnownStatus(UNRESOLVABLE_REQUIRED_SIGNERS)).then(getTxnRecord("creation").revealingDebitsTo(successFeesObs::set), getTxnRecord("nothingShouldBeCreated").revealingDebitsTo(failureFeesObs::set).logged(), assertionsHold((spec, opLog) -> assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class ScheduleExecutionSpecs method scheduledSubmitFailedWithInvalidChunkNumberStillPaysServiceFeeButHasNoImpact.
private HapiApiSpec scheduledSubmitFailedWithInvalidChunkNumberStillPaysServiceFeeButHasNoImpact() {
String immutableTopic = "XXX";
String validSchedule = "withValidChunkNumber";
String invalidSchedule = "withInvalidChunkNumber";
String schedulePayer = "somebody";
String successTxn = "good", failedTxn = "bad";
AtomicReference<Map<AccountID, Long>> successFeesObs = new AtomicReference<>();
AtomicReference<Map<AccountID, Long>> failureFeesObs = new AtomicReference<>();
AtomicReference<TransactionID> initialTxnId = new AtomicReference<>();
return defaultHapiSpec("ScheduledSubmitFailedWithInvalidChunkNumberStillPaysServiceFeeButHasNoImpact").given(createTopic(immutableTopic), cryptoCreate(schedulePayer)).when(withOpContext((spec, opLog) -> {
var subOp = usableTxnIdNamed(successTxn).payerId(schedulePayer);
allRunFor(spec, subOp);
initialTxnId.set(spec.registry().getTxnId(successTxn));
}), sourcing(() -> scheduleCreate(validSchedule, submitMessageTo(immutableTopic).chunkInfo(3, 1, scheduledVersionOf(initialTxnId.get()))).txnId(successTxn).logged().signedBy(schedulePayer)), getTopicInfo(immutableTopic).hasSeqNo(1L), getTxnRecord(successTxn).scheduled().logged().revealingDebitsTo(successFeesObs::set), scheduleCreate(invalidSchedule, submitMessageTo(immutableTopic).chunkInfo(3, 111, schedulePayer)).via(failedTxn).logged().payingWith(schedulePayer)).then(getTopicInfo(immutableTopic).hasSeqNo(1L), getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(INVALID_CHUNK_NUMBER)).revealingDebitsTo(failureFeesObs::set), assertionsHold((spec, opLog) -> Assertions.assertEquals(successFeesObs.get(), failureFeesObs.get())));
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class ScheduleExecutionSpecs method scheduledXferFailingWithDeletedAccountPaysServiceFeeButNoImpact.
private HapiApiSpec scheduledXferFailingWithDeletedAccountPaysServiceFeeButNoImpact() {
String xToken = "XXX";
String validSchedule = "withLiveAccount";
String invalidSchedule = "withDeletedAccount";
String schedulePayer = "somebody", xTreasury = "xt", xCivilian = "xc", deadXCivilian = "deadxc";
String successTxn = "good", failedTxn = "bad";
AtomicReference<Map<AccountID, Long>> successFeesObs = new AtomicReference<>();
AtomicReference<Map<AccountID, Long>> failureFeesObs = new AtomicReference<>();
return defaultHapiSpec("ScheduledXferFailingWithDeletedTokenPaysServiceFeeButNoImpact").given(cryptoCreate(schedulePayer), cryptoCreate(xTreasury), cryptoCreate(xCivilian), cryptoCreate(deadXCivilian), tokenCreate(xToken).treasury(xTreasury).initialSupply(101), tokenAssociate(xCivilian, xToken), tokenAssociate(deadXCivilian, 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), cryptoDelete(deadXCivilian), scheduleCreate(invalidSchedule, cryptoTransfer(moving(1, xToken).between(xTreasury, deadXCivilian))).via(failedTxn).alsoSigningWith(xTreasury, schedulePayer).designatingPayer(schedulePayer)).then(getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(ACCOUNT_DELETED)).revealingDebitsTo(failureFeesObs::set), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), assertionsHold((spec, opLog) -> assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}
Aggregations