use of com.hederahashgraph.api.proto.java.AccountID 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)));
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class ScheduleExecutionSpecs method scheduledSubmitFailedWithInvalidChunkTxnIdStillPaysServiceFeeButHasNoImpact.
private HapiApiSpec scheduledSubmitFailedWithInvalidChunkTxnIdStillPaysServiceFeeButHasNoImpact() {
String immutableTopic = "XXX";
String validSchedule = "withValidChunkTxnId";
String invalidSchedule = "withInvalidChunkTxnId";
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<>();
AtomicReference<TransactionID> irrelevantTxnId = new AtomicReference<>();
return defaultHapiSpec("ScheduledSubmitFailedWithInvalidChunkTxnIdStillPaysServiceFeeButHasNoImpact").given(createTopic(immutableTopic), cryptoCreate(schedulePayer)).when(withOpContext((spec, opLog) -> {
var subOp = usableTxnIdNamed(successTxn).payerId(schedulePayer);
var secondSubOp = usableTxnIdNamed("wontWork").payerId(schedulePayer);
allRunFor(spec, subOp, secondSubOp);
initialTxnId.set(spec.registry().getTxnId(successTxn));
irrelevantTxnId.set(spec.registry().getTxnId("wontWork"));
}), 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), sourcing(() -> scheduleCreate(invalidSchedule, submitMessageTo(immutableTopic).chunkInfo(3, 1, scheduledVersionOf(irrelevantTxnId.get()))).designatingPayer(schedulePayer).via(failedTxn).logged().signedBy(DEFAULT_PAYER, schedulePayer))).then(getTopicInfo(immutableTopic).hasSeqNo(1L), getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(INVALID_CHUNK_TRANSACTION_ID)).revealingDebitsTo(failureFeesObs::set), assertionsHold((spec, opLog) -> Assertions.assertEquals(successFeesObs.get(), failureFeesObs.get())));
}
use of com.hederahashgraph.api.proto.java.AccountID 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)));
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class CryptoAdjustAllowanceTransitionLogic method doStateTransition.
@Override
public void doStateTransition() {
/* --- Extract gRPC --- */
final TransactionBody cryptoAdjustAllowanceTxn = txnCtx.accessor().getTxn();
final AccountID payer = cryptoAdjustAllowanceTxn.getTransactionID().getAccountID();
final var op = cryptoAdjustAllowanceTxn.getCryptoAdjustAllowance();
entitiesChanged.clear();
/* --- Use models --- */
final Id payerId = Id.fromGrpcAccount(payer);
final var payerAccount = accountStore.loadAccount(payerId);
/* --- Do the business logic --- */
adjustCryptoAllowances(op.getCryptoAllowancesList(), payerAccount);
adjustFungibleTokenAllowances(op.getTokenAllowancesList(), payerAccount);
adjustNftAllowances(op.getNftAllowancesList(), payerAccount);
/* --- Persist the owner account --- */
for (final var entry : entitiesChanged.entrySet()) {
accountStore.commitAccount(entry.getValue());
}
txnCtx.setStatus(SUCCESS);
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class CryptoAdjustAllowanceTransitionLogic method validate.
private ResponseCodeEnum validate(TransactionBody cryptoAllowanceTxn) {
final AccountID payer = cryptoAllowanceTxn.getTransactionID().getAccountID();
final var op = cryptoAllowanceTxn.getCryptoAdjustAllowance();
final var payerAccount = accountStore.loadAccount(Id.fromGrpcAccount(payer));
return adjustAllowanceChecks.allowancesValidation(op.getCryptoAllowancesList(), op.getTokenAllowancesList(), op.getNftAllowancesList(), payerAccount, dynamicProperties.maxAllowanceLimitPerTransaction());
}
Aggregations