Search in sources :

Example 61 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.

the class ScheduleExecutionSpecs method scheduledXferFailingWithFrozenAccountTransferPaysServiceFeeButNoImpact.

private HapiApiSpec scheduledXferFailingWithFrozenAccountTransferPaysServiceFeeButNoImpact() {
    String xToken = "XXX";
    String validSchedule = "withUnfrozenAccount";
    String invalidSchedule = "withFrozenAccount";
    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("ScheduledXferFailingWithFrozenAccountTransferPaysServiceFeeButNoImpact").given(newKeyNamed("freeze"), cryptoCreate(schedulePayer), cryptoCreate(xTreasury), cryptoCreate(xCivilian), tokenCreate(xToken).treasury(xTreasury).initialSupply(101).freezeKey("freeze").freezeDefault(true), tokenAssociate(xCivilian, xToken), tokenUnfreeze(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), tokenFreeze(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_FROZEN_FOR_TOKEN)).revealingDebitsTo(failureFeesObs::set), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), assertionsHold((spec, opLog) -> assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}
Also used : ACCOUNT_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_DELETED) INVALID_NFT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_NFT_ID) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) INVALID_TRANSACTION_BODY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TRANSACTION_BODY) Random(java.util.Random) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) TxnVerbs.tokenDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenDelete) HapiGetTxnRecord(com.hedera.services.bdd.spec.queries.meta.HapiGetTxnRecord) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) TxnUtils.asId(com.hedera.services.bdd.spec.transactions.TxnUtils.asId) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) NO_NEW_VALID_SIGNATURES(com.hederahashgraph.api.proto.java.ResponseCodeEnum.NO_NEW_VALID_SIGNATURES) INVALID_TOKEN_MINT_AMOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_MINT_AMOUNT) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) INVALID_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ACCOUNT_AMOUNTS) SCHEDULE_ALREADY_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SCHEDULE_ALREADY_EXECUTED) BATCH_SIZE_LIMIT_EXCEEDED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BATCH_SIZE_LIMIT_EXCEEDED) MESSAGE_SIZE_TOO_LARGE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MESSAGE_SIZE_TOO_LARGE) TxnVerbs.scheduleCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleCreate) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TxnVerbs.deleteTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.deleteTopic) TxnVerbs.submitMessageTo(com.hedera.services.bdd.spec.transactions.TxnVerbs.submitMessageTo) INVALID_TOKEN_BURN_AMOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_BURN_AMOUNT) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) ByteString(com.google.protobuf.ByteString) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) List(java.util.List) Logger(org.apache.logging.log4j.Logger) UtilVerbs.assertionsHold(com.hedera.services.bdd.spec.utilops.UtilVerbs.assertionsHold) TxnVerbs.grantTokenKyc(com.hedera.services.bdd.spec.transactions.TxnVerbs.grantTokenKyc) UNRESOLVABLE_REQUIRED_SIGNERS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNRESOLVABLE_REQUIRED_SIGNERS) TxnUtils.randomUppercase(com.hedera.services.bdd.spec.transactions.TxnUtils.randomUppercase) UtilVerbs.usableTxnIdNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.usableTxnIdNamed) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) METADATA_TOO_LONG(com.hederahashgraph.api.proto.java.ResponseCodeEnum.METADATA_TOO_LONG) TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) INSUFFICIENT_ACCOUNT_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) QueryVerbs.getTokenInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo) QueryVerbs.getTopicInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTopicInfo) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) AtomicReference(java.util.concurrent.atomic.AtomicReference) EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS) TOKEN_WAS_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_WAS_DELETED) TOKEN_HAS_NO_SUPPLY_KEY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_HAS_NO_SUPPLY_KEY) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) TxnVerbs.cryptoDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoDelete) TxnVerbs.invalidBurnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.invalidBurnToken) INSUFFICIENT_TOKEN_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TOKEN_BALANCE) ScheduleRecordSpecs.scheduledVersionOf(com.hedera.services.bdd.suites.schedule.ScheduleRecordSpecs.scheduledVersionOf) ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN) TxnVerbs.revokeTokenKyc(com.hedera.services.bdd.spec.transactions.TxnVerbs.revokeTokenKyc) AccountID(com.hederahashgraph.api.proto.java.AccountID) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) SOME_SIGNATURES_WERE_INVALID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SOME_SIGNATURES_WERE_INVALID) INVALID_CHUNK_NUMBER(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CHUNK_NUMBER) TxnVerbs.updateTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.updateTopic) ACCOUNT_FROZEN_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_FROZEN_FOR_TOKEN) TxnVerbs.tokenFreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenFreeze) UtilVerbs.recordFeeAmount(com.hedera.services.bdd.spec.utilops.UtilVerbs.recordFeeAmount) INVALID_TOKEN_BURN_METADATA(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_BURN_METADATA) TOKEN_ID_REPEATED_IN_TOKEN_LIST(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ID_REPEATED_IN_TOKEN_LIST) TxnVerbs.scheduleSign(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleSign) HapiCryptoTransfer.tinyBarsFromToWithInvalidAmounts(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromToWithInvalidAmounts) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) TxnVerbs.burnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.burnToken) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) QueryVerbs.getScheduleInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getScheduleInfo) TokenType(com.hederahashgraph.api.proto.java.TokenType) TxnVerbs.invalidMintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.invalidMintToken) INVALID_CHUNK_TRANSACTION_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CHUNK_TRANSACTION_ID) Assertions(org.junit.jupiter.api.Assertions) LogManager(org.apache.logging.log4j.LogManager) TxnVerbs.tokenUnfreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUnfreeze) AtomicReference(java.util.concurrent.atomic.AtomicReference) ByteString(com.google.protobuf.ByteString) Map(java.util.Map)

Example 62 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.

the class MigrationValidationPreSteps method migrationPreservesEntitiesPreStep.

/**
 * Builds a spec in which it...
 * 1. create a File with some contents
 * 2. create a couple of crypto accounts and do some transaction between them
 * 3. create a smart contract and call it a few times.
 *
 * @return the spec.
 */
private HapiApiSpec migrationPreservesEntitiesPreStep() {
    return defaultHapiSpec("migrationPreservesEntitiesPreStep").given(UtilVerbs.blockingOrder(doFileActions()), UtilVerbs.blockingOrder(doCryptoActions()), UtilVerbs.blockingOrder(doSmartContractActions())).when().then(QueryVerbs.getFileInfo(MIGRATION_FILE).logged().saveToRegistry("migrationFile"), QueryVerbs.getFileContents(MIGRATION_FILE).logged(), QueryVerbs.getAccountInfo(MIGRATION_ACCOUNT_A).logged().savingSnapshot("migrationAccountA"), QueryVerbs.getAccountInfo(MIGRATION_ACCOUNT_B).logged().savingSnapshot("migrationAccountB"), QueryVerbs.getContractInfo(MIGRATION_SMART_CONTRACT).logged().saveToRegistry("migrationContract"), UtilVerbs.withOpContext((spec, ctxLog) -> {
        FileWriter fw = null;
        try {
            fw = new FileWriter("src/main/resource/migration_config_default.properties");
            AccountID id = spec.setup().genesisAccount();
            String tmpId = asEntityId(id.getRealmNum(), id.getShardNum(), id.getAccountNum());
            fw.write("default.payer=" + tmpId + "\n");
            FileGetInfoResponse.FileInfo fileInfo = spec.registry().getFileInfo("migrationFile");
            tmpId = asEntityId(fileInfo.getFileID().getRealmNum(), fileInfo.getFileID().getShardNum(), fileInfo.getFileID().getFileNum());
            fw.write("migration.file.id=" + tmpId + "\n");
            CryptoGetInfoResponse.AccountInfo accountInfoA = spec.registry().getAccountInfo("migrationAccountA");
            CryptoGetInfoResponse.AccountInfo accountInfoB = spec.registry().getAccountInfo("migrationAccountB");
            tmpId = asEntityId(accountInfoA.getAccountID().getRealmNum(), accountInfoA.getAccountID().getShardNum(), accountInfoA.getAccountID().getAccountNum());
            fw.write("migration.crypto.AccountA.id=" + tmpId + "\n");
            tmpId = asEntityId(accountInfoB.getAccountID().getRealmNum(), accountInfoB.getAccountID().getShardNum(), accountInfoB.getAccountID().getAccountNum());
            fw.write("migration.crypto.AccountB.id=" + tmpId + "\n");
            ContractGetInfoResponse.ContractInfo contractInfo = spec.registry().getContractInfo("migrationContract");
            tmpId = asEntityId(contractInfo.getContractID().getRealmNum(), contractInfo.getContractID().getShardNum(), contractInfo.getContractID().getContractNum());
            fw.write("migration.smartContract.id=" + tmpId + "\n");
            fw.write("nodes=" + spec.setup().nodes().stream().map(NodeConnectInfo::uri).collect(Collectors.joining(" ")));
            fw.flush();
        } catch (IOException e) {
            ctxLog.warn("Something wrong with File operation: {} ", e);
        } catch (Exception e) {
            ctxLog.warn("Unexpected error: {}", e);
        } finally {
            fw.close();
        }
    })).saveContext(true);
}
Also used : CryptoGetInfoResponse(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse) AccountID(com.hederahashgraph.api.proto.java.AccountID) FileGetInfoResponse(com.hederahashgraph.api.proto.java.FileGetInfoResponse) FileWriter(java.io.FileWriter) IOException(java.io.IOException) IOException(java.io.IOException) ContractGetInfoResponse(com.hederahashgraph.api.proto.java.ContractGetInfoResponse)

Example 63 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.

the class ScheduleExecutionSpecs method scheduledXferFailingWithEmptyTokenTransferAccountAmountsPaysServiceFeeButNoImpact.

private HapiApiSpec scheduledXferFailingWithEmptyTokenTransferAccountAmountsPaysServiceFeeButNoImpact() {
    String xToken = "XXX", yToken = "YYY";
    String validSchedule = "withNonEmptyTransfers";
    String invalidSchedule = "withEmptyTransfer";
    String schedulePayer = "somebody", xTreasury = "xt", yTreasury = "yt", xyCivilian = "xyt";
    String successTxn = "good", failedTxn = "bad";
    AtomicReference<Map<AccountID, Long>> successFeesObs = new AtomicReference<>();
    AtomicReference<Map<AccountID, Long>> failureFeesObs = new AtomicReference<>();
    return defaultHapiSpec("ScheduledXferFailingWithEmptyTokenTransferAccountAmountsPaysServiceFeeButNoImpact").given(cryptoCreate(schedulePayer), cryptoCreate(xTreasury), cryptoCreate(yTreasury), cryptoCreate(xyCivilian), tokenCreate(xToken).treasury(xTreasury).initialSupply(101), tokenCreate(yToken).treasury(yTreasury).initialSupply(101), tokenAssociate(xTreasury, yToken), tokenAssociate(yTreasury, xToken)).when(scheduleCreate(validSchedule, cryptoTransfer(moving(1, xToken).between(xTreasury, yTreasury), moving(1, yToken).between(yTreasury, xTreasury))).via(successTxn).alsoSigningWith(xTreasury, yTreasury, schedulePayer).designatingPayer(schedulePayer), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), getAccountBalance(xTreasury).hasTokenBalance(yToken, 1), getAccountBalance(yTreasury).hasTokenBalance(yToken, 100), getAccountBalance(yTreasury).hasTokenBalance(xToken, 1), getTxnRecord(successTxn).scheduled().logged().revealingDebitsTo(successFeesObs::set), scheduleCreate(invalidSchedule, cryptoTransfer(moving(2, xToken).distributing(xTreasury, yTreasury, xyCivilian)).withEmptyTokenTransfers(yToken)).via(failedTxn).alsoSigningWith(xTreasury, yTreasury, schedulePayer).designatingPayer(schedulePayer)).then(getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS)).revealingDebitsTo(failureFeesObs::set), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), getAccountBalance(xTreasury).hasTokenBalance(yToken, 1), getAccountBalance(yTreasury).hasTokenBalance(yToken, 100), getAccountBalance(yTreasury).hasTokenBalance(xToken, 1), assertionsHold((spec, opLog) -> assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}
Also used : ACCOUNT_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_DELETED) INVALID_NFT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_NFT_ID) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) INVALID_TRANSACTION_BODY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TRANSACTION_BODY) Random(java.util.Random) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) TxnVerbs.tokenDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenDelete) HapiGetTxnRecord(com.hedera.services.bdd.spec.queries.meta.HapiGetTxnRecord) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) TxnUtils.asId(com.hedera.services.bdd.spec.transactions.TxnUtils.asId) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) NO_NEW_VALID_SIGNATURES(com.hederahashgraph.api.proto.java.ResponseCodeEnum.NO_NEW_VALID_SIGNATURES) INVALID_TOKEN_MINT_AMOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_MINT_AMOUNT) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) INVALID_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ACCOUNT_AMOUNTS) SCHEDULE_ALREADY_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SCHEDULE_ALREADY_EXECUTED) BATCH_SIZE_LIMIT_EXCEEDED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BATCH_SIZE_LIMIT_EXCEEDED) MESSAGE_SIZE_TOO_LARGE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MESSAGE_SIZE_TOO_LARGE) TxnVerbs.scheduleCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleCreate) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TxnVerbs.deleteTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.deleteTopic) TxnVerbs.submitMessageTo(com.hedera.services.bdd.spec.transactions.TxnVerbs.submitMessageTo) INVALID_TOKEN_BURN_AMOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_BURN_AMOUNT) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) ByteString(com.google.protobuf.ByteString) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) List(java.util.List) Logger(org.apache.logging.log4j.Logger) UtilVerbs.assertionsHold(com.hedera.services.bdd.spec.utilops.UtilVerbs.assertionsHold) TxnVerbs.grantTokenKyc(com.hedera.services.bdd.spec.transactions.TxnVerbs.grantTokenKyc) UNRESOLVABLE_REQUIRED_SIGNERS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNRESOLVABLE_REQUIRED_SIGNERS) TxnUtils.randomUppercase(com.hedera.services.bdd.spec.transactions.TxnUtils.randomUppercase) UtilVerbs.usableTxnIdNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.usableTxnIdNamed) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) METADATA_TOO_LONG(com.hederahashgraph.api.proto.java.ResponseCodeEnum.METADATA_TOO_LONG) TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) INSUFFICIENT_ACCOUNT_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) QueryVerbs.getTokenInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo) QueryVerbs.getTopicInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTopicInfo) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) AtomicReference(java.util.concurrent.atomic.AtomicReference) EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS) TOKEN_WAS_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_WAS_DELETED) TOKEN_HAS_NO_SUPPLY_KEY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_HAS_NO_SUPPLY_KEY) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) TxnVerbs.cryptoDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoDelete) TxnVerbs.invalidBurnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.invalidBurnToken) INSUFFICIENT_TOKEN_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TOKEN_BALANCE) ScheduleRecordSpecs.scheduledVersionOf(com.hedera.services.bdd.suites.schedule.ScheduleRecordSpecs.scheduledVersionOf) ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN) TxnVerbs.revokeTokenKyc(com.hedera.services.bdd.spec.transactions.TxnVerbs.revokeTokenKyc) AccountID(com.hederahashgraph.api.proto.java.AccountID) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) SOME_SIGNATURES_WERE_INVALID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SOME_SIGNATURES_WERE_INVALID) INVALID_CHUNK_NUMBER(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CHUNK_NUMBER) TxnVerbs.updateTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.updateTopic) ACCOUNT_FROZEN_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_FROZEN_FOR_TOKEN) TxnVerbs.tokenFreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenFreeze) UtilVerbs.recordFeeAmount(com.hedera.services.bdd.spec.utilops.UtilVerbs.recordFeeAmount) INVALID_TOKEN_BURN_METADATA(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_BURN_METADATA) TOKEN_ID_REPEATED_IN_TOKEN_LIST(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ID_REPEATED_IN_TOKEN_LIST) TxnVerbs.scheduleSign(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleSign) HapiCryptoTransfer.tinyBarsFromToWithInvalidAmounts(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromToWithInvalidAmounts) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) TxnVerbs.burnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.burnToken) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) QueryVerbs.getScheduleInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getScheduleInfo) TokenType(com.hederahashgraph.api.proto.java.TokenType) TxnVerbs.invalidMintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.invalidMintToken) INVALID_CHUNK_TRANSACTION_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CHUNK_TRANSACTION_ID) Assertions(org.junit.jupiter.api.Assertions) LogManager(org.apache.logging.log4j.LogManager) TxnVerbs.tokenUnfreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUnfreeze) AtomicReference(java.util.concurrent.atomic.AtomicReference) ByteString(com.google.protobuf.ByteString) Map(java.util.Map)

Example 64 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.

the class ScheduleExecutionSpecs method scheduledXferFailingWithDeletedTokenPaysServiceFeeButNoImpact.

private HapiApiSpec scheduledXferFailingWithDeletedTokenPaysServiceFeeButNoImpact() {
    String xToken = "XXX";
    String validSchedule = "withLiveToken";
    String invalidSchedule = "withDeletedToken";
    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("ScheduledXferFailingWithDeletedTokenPaysServiceFeeButNoImpact").given(newKeyNamed("admin"), cryptoCreate(schedulePayer), cryptoCreate(xTreasury), cryptoCreate(xCivilian), tokenCreate(xToken).treasury(xTreasury).initialSupply(101).adminKey("admin"), tokenAssociate(xCivilian, xToken)).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), tokenDelete(xToken), 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(TOKEN_WAS_DELETED)).revealingDebitsTo(failureFeesObs::set), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), assertionsHold((spec, opLog) -> assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}
Also used : ACCOUNT_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_DELETED) INVALID_NFT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_NFT_ID) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) INVALID_TRANSACTION_BODY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TRANSACTION_BODY) Random(java.util.Random) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) TxnVerbs.tokenDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenDelete) HapiGetTxnRecord(com.hedera.services.bdd.spec.queries.meta.HapiGetTxnRecord) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) TxnUtils.asId(com.hedera.services.bdd.spec.transactions.TxnUtils.asId) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) NO_NEW_VALID_SIGNATURES(com.hederahashgraph.api.proto.java.ResponseCodeEnum.NO_NEW_VALID_SIGNATURES) INVALID_TOKEN_MINT_AMOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_MINT_AMOUNT) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) INVALID_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ACCOUNT_AMOUNTS) SCHEDULE_ALREADY_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SCHEDULE_ALREADY_EXECUTED) BATCH_SIZE_LIMIT_EXCEEDED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BATCH_SIZE_LIMIT_EXCEEDED) MESSAGE_SIZE_TOO_LARGE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MESSAGE_SIZE_TOO_LARGE) TxnVerbs.scheduleCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleCreate) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TxnVerbs.deleteTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.deleteTopic) TxnVerbs.submitMessageTo(com.hedera.services.bdd.spec.transactions.TxnVerbs.submitMessageTo) INVALID_TOKEN_BURN_AMOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_BURN_AMOUNT) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) ByteString(com.google.protobuf.ByteString) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) List(java.util.List) Logger(org.apache.logging.log4j.Logger) UtilVerbs.assertionsHold(com.hedera.services.bdd.spec.utilops.UtilVerbs.assertionsHold) TxnVerbs.grantTokenKyc(com.hedera.services.bdd.spec.transactions.TxnVerbs.grantTokenKyc) UNRESOLVABLE_REQUIRED_SIGNERS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNRESOLVABLE_REQUIRED_SIGNERS) TxnUtils.randomUppercase(com.hedera.services.bdd.spec.transactions.TxnUtils.randomUppercase) UtilVerbs.usableTxnIdNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.usableTxnIdNamed) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) METADATA_TOO_LONG(com.hederahashgraph.api.proto.java.ResponseCodeEnum.METADATA_TOO_LONG) TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) INSUFFICIENT_ACCOUNT_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) QueryVerbs.getTokenInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo) QueryVerbs.getTopicInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTopicInfo) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) AtomicReference(java.util.concurrent.atomic.AtomicReference) EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS) TOKEN_WAS_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_WAS_DELETED) TOKEN_HAS_NO_SUPPLY_KEY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_HAS_NO_SUPPLY_KEY) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) TxnVerbs.cryptoDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoDelete) TxnVerbs.invalidBurnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.invalidBurnToken) INSUFFICIENT_TOKEN_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TOKEN_BALANCE) ScheduleRecordSpecs.scheduledVersionOf(com.hedera.services.bdd.suites.schedule.ScheduleRecordSpecs.scheduledVersionOf) ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN) TxnVerbs.revokeTokenKyc(com.hedera.services.bdd.spec.transactions.TxnVerbs.revokeTokenKyc) AccountID(com.hederahashgraph.api.proto.java.AccountID) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) SOME_SIGNATURES_WERE_INVALID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SOME_SIGNATURES_WERE_INVALID) INVALID_CHUNK_NUMBER(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CHUNK_NUMBER) TxnVerbs.updateTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.updateTopic) ACCOUNT_FROZEN_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_FROZEN_FOR_TOKEN) TxnVerbs.tokenFreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenFreeze) UtilVerbs.recordFeeAmount(com.hedera.services.bdd.spec.utilops.UtilVerbs.recordFeeAmount) INVALID_TOKEN_BURN_METADATA(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_BURN_METADATA) TOKEN_ID_REPEATED_IN_TOKEN_LIST(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ID_REPEATED_IN_TOKEN_LIST) TxnVerbs.scheduleSign(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleSign) HapiCryptoTransfer.tinyBarsFromToWithInvalidAmounts(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromToWithInvalidAmounts) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) TxnVerbs.burnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.burnToken) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) QueryVerbs.getScheduleInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getScheduleInfo) TokenType(com.hederahashgraph.api.proto.java.TokenType) TxnVerbs.invalidMintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.invalidMintToken) INVALID_CHUNK_TRANSACTION_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CHUNK_TRANSACTION_ID) Assertions(org.junit.jupiter.api.Assertions) LogManager(org.apache.logging.log4j.LogManager) TxnVerbs.tokenUnfreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUnfreeze) AtomicReference(java.util.concurrent.atomic.AtomicReference) ByteString(com.google.protobuf.ByteString) Map(java.util.Map)

Example 65 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.

the class StateView method infoForAccount.

public Optional<CryptoGetInfoResponse.AccountInfo> infoForAccount(final AccountID id, final AliasManager aliasManager) {
    final var accountEntityNum = id.getAlias().isEmpty() ? fromAccountId(id) : aliasManager.lookupIdBy(id.getAlias());
    final var account = accounts().get(accountEntityNum);
    if (account == null) {
        return Optional.empty();
    }
    final AccountID accountID = id.getAlias().isEmpty() ? id : accountEntityNum.toGrpcAccountId();
    final var info = CryptoGetInfoResponse.AccountInfo.newBuilder().setLedgerId(networkInfo.ledgerId()).setKey(asKeyUnchecked(account.getAccountKey())).setAccountID(accountID).setAlias(account.getAlias()).setReceiverSigRequired(account.isReceiverSigRequired()).setDeleted(account.isDeleted()).setMemo(account.getMemo()).setAutoRenewPeriod(Duration.newBuilder().setSeconds(account.getAutoRenewSecs())).setBalance(account.getBalance()).setExpirationTime(Timestamp.newBuilder().setSeconds(account.getExpiry())).setContractAccountID(asHexedEvmAddress(accountID)).setOwnedNfts(account.getNftsOwned()).setMaxAutomaticTokenAssociations(account.getMaxAutomaticAssociations());
    Optional.ofNullable(account.getProxy()).map(EntityId::toGrpcAccountId).ifPresent(info::setProxyAccountID);
    final var tokenRels = tokenRelsFn.apply(this, accountEntityNum);
    if (!tokenRels.isEmpty()) {
        info.addAllTokenRelationships(tokenRels);
    }
    setAllowancesIfAny(info, account);
    return Optional.of(info.build());
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID)

Aggregations

AccountID (com.hederahashgraph.api.proto.java.AccountID)71 Test (org.junit.jupiter.api.Test)24 List (java.util.List)21 ByteString (com.google.protobuf.ByteString)20 Assertions (org.junit.jupiter.api.Assertions)20 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)17 LogManager (org.apache.logging.log4j.LogManager)17 Logger (org.apache.logging.log4j.Logger)17 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)16 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)15 QueryVerbs.getTxnRecord (com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord)15 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)15 QueryVerbs.getAccountInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo)14 TransactionRecordAsserts.recordWith (com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith)13 QueryVerbs.getAccountBalance (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance)13 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)13 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)13 TxnVerbs.mintToken (com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken)13 HapiSpecSetup (com.hedera.services.bdd.spec.HapiSpecSetup)12 QueryVerbs.getScheduleInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getScheduleInfo)12