Search in sources :

Example 56 with HapiApiSpec

use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.

the class UpdateAllProtectedFilesDuringReconnect method updateAllProtectedFilesDuringReconnect.

private HapiApiSpec updateAllProtectedFilesDuringReconnect() {
    final String fileInfoRegistry = "apiPermissionsReconnect";
    final String nonUpdatableFile = "nonUpdatableFile";
    return customHapiSpec("UpdateAllProtectedFilesDuringReconnect").withProperties(Map.of("txn.start.offset.secs", "-5")).given(saveFileToRegistry(APP_PROPERTIES, APP_FILE_REGISTRY), saveFileToRegistry(API_PERMISSIONS, API_FILE_REGISTRY), saveFileToRegistry(EXCHANGE_RATES, RATES_FILE_REGISTRY), saveFileToRegistry(FEE_SCHEDULE, FEES_FILE_REGISTRY), sleepFor(Duration.ofSeconds(25).toMillis()), getAccountBalance(GENESIS).setNode("0.0.8").unavailableNode()).when(fileUpdate(APP_PROPERTIES).payingWith(GENESIS).overridingProps(Map.of("ledger.autoRenewPeriod.minDuration", "20")).erasingProps(Set.of("minimumAutoRenewDuration")), fileUpdate(API_PERMISSIONS).payingWith(GENESIS).overridingProps(Map.of("updateFile", "2-50")), fileCreate(nonUpdatableFile).contents("Cannot update file because of the new api permissions"), fileUpdate(EXCHANGE_RATES).contents(spec -> {
        ByteString newRates = spec.ratesProvider().rateSetWith(100, 1).toByteString();
        spec.registry().saveBytes("newRates", newRates);
        return newRates;
    }).payingWith(GENESIS), makeFree(CryptoGetInfo), getAccountBalance(GENESIS).setNode("0.0.8").unavailableNode()).then(withLiveNode("0.0.8").within(5 * 60, TimeUnit.SECONDS).loggingAvailabilityEvery(30).sleepingBetweenRetriesFor(10), UtilVerbs.sleepFor(30 * 1000), withLiveNode("0.0.8").within(5 * 60, TimeUnit.SECONDS).loggingAvailabilityEvery(30).sleepingBetweenRetriesFor(10), getFileContents(API_PERMISSIONS).logged().setNode("0.0.3").payingWith(GENESIS).saveToRegistry(fileInfoRegistry), getFileContents(API_PERMISSIONS).logged().setNode("0.0.8").payingWith(GENESIS).hasContents(fileInfoRegistry), fileUpdate(nonUpdatableFile).setNode("0.0.8").fee(ONE_MILLION_HBARS).hasPrecheck(NOT_SUPPORTED), fileCreate("contractFile").setNode("0.0.8").payingWith(GENESIS).path(ContractResources.VALID_BYTECODE_PATH), contractCreate("testContract").bytecode("contractFile").autoRenewSecs(15).setNode("0.0.8").hasPrecheck(AUTORENEW_DURATION_NOT_IN_RANGE), cryptoCreate("civilian").setNode("0.0.8").fee(ONE_HUNDRED_HBARS).hasPrecheck(INSUFFICIENT_TX_FEE), cryptoCreate("civilian").setNode("0.0.8"), getAccountInfo("0.0.2").payingWith("civilian").nodePayment(0L).setNode("0.0.8").hasAnswerOnlyPrecheck(OK), restoreFileFromRegistry(APP_PROPERTIES, APP_FILE_REGISTRY), restoreFileFromRegistry(API_PERMISSIONS, API_FILE_REGISTRY), restoreFileFromRegistry(EXCHANGE_RATES, RATES_FILE_REGISTRY), restoreFileFromRegistry(FEE_SCHEDULE, FEES_FILE_REGISTRY));
}
Also used : OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) UtilVerbs.restoreFileFromRegistry(com.hedera.services.bdd.spec.utilops.UtilVerbs.restoreFileFromRegistry) UtilVerbs.sleepFor(com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) Duration(java.time.Duration) Map(java.util.Map) UtilVerbs.withLiveNode(com.hedera.services.bdd.spec.utilops.UtilVerbs.withLiveNode) NOT_SUPPORTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.NOT_SUPPORTED) UtilVerbs.makeFree(com.hedera.services.bdd.spec.utilops.UtilVerbs.makeFree) QueryVerbs.getFileContents(com.hedera.services.bdd.spec.queries.QueryVerbs.getFileContents) CryptoGetInfo(com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoGetInfo) Set(java.util.Set) HapiApiSpec.customHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.customHapiSpec) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) ByteString(com.google.protobuf.ByteString) TimeUnit(java.util.concurrent.TimeUnit) UtilVerbs.saveFileToRegistry(com.hedera.services.bdd.spec.utilops.UtilVerbs.saveFileToRegistry) List(java.util.List) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) Logger(org.apache.logging.log4j.Logger) UtilVerbs(com.hedera.services.bdd.spec.utilops.UtilVerbs) AUTORENEW_DURATION_NOT_IN_RANGE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.AUTORENEW_DURATION_NOT_IN_RANGE) AutoRenewEntitiesForReconnect.runTransfersBeforeReconnect(com.hedera.services.bdd.suites.reconnect.AutoRenewEntitiesForReconnect.runTransfersBeforeReconnect) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) INSUFFICIENT_TX_FEE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString)

Example 57 with HapiApiSpec

use of com.hedera.services.bdd.spec.HapiApiSpec 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())));
}
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) TransactionID(com.hederahashgraph.api.proto.java.TransactionID)

Example 58 with HapiApiSpec

use of com.hedera.services.bdd.spec.HapiApiSpec 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)));
}
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 59 with HapiApiSpec

use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.

the class TokenAssociationSpecs method expiredAndDeletedTokensStillAppearInContractInfo.

public HapiApiSpec expiredAndDeletedTokensStillAppearInContractInfo() {
    final String contract = "nothingMattersAnymore";
    final String treasury = "something";
    final String expiringToken = "expiringToken";
    final long lifetimeSecs = 10;
    final long xfer = 123L;
    AtomicLong now = new AtomicLong();
    return defaultHapiSpec("ExpiredAndDeletedTokensStillAppearInContractInfo").given(newKeyNamed("admin"), cryptoCreate(treasury), fileCreate("bytecode").path(ContractResources.FUSE_BYTECODE_PATH), contractCreate(contract).bytecode("bytecode").gas(300_000).via("creation"), withOpContext((spec, opLog) -> {
        var subOp = getTxnRecord("creation");
        allRunFor(spec, subOp);
        var record = subOp.getResponseRecord();
        now.set(record.getConsensusTimestamp().getSeconds());
    }), sourcing(() -> tokenCreate(expiringToken).decimals(666).adminKey("admin").treasury(treasury).expiry(now.get() + lifetimeSecs))).when(tokenAssociate(contract, expiringToken), cryptoTransfer(moving(xfer, expiringToken).between(treasury, contract))).then(getAccountBalance(contract).hasTokenBalance(expiringToken, xfer), getContractInfo(contract).hasToken(relationshipWith(expiringToken).freeze(FreezeNotApplicable)), sleepFor(lifetimeSecs * 1_000L), getAccountBalance(contract).hasTokenBalance(expiringToken, xfer, 666), getContractInfo(contract).hasToken(relationshipWith(expiringToken).freeze(FreezeNotApplicable)), tokenDelete(expiringToken), getAccountBalance(contract).hasTokenBalance(expiringToken, xfer), getContractInfo(contract).hasToken(relationshipWith(expiringToken).decimals(666).freeze(FreezeNotApplicable)));
}
Also used : TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) QueryVerbs.getContractInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo) TxnVerbs.tokenDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenDelete) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) UtilVerbs.sleepFor(com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) ACCOUNT_IS_TREASURY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_IS_TREASURY) ExpectedTokenRel.relationshipWith(com.hedera.services.bdd.spec.queries.crypto.ExpectedTokenRel.relationshipWith) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) Frozen(com.hederahashgraph.api.proto.java.TokenFreezeStatus.Frozen) SomeFungibleTransfers.changingFungibleBalances(com.hedera.services.bdd.spec.assertions.SomeFungibleTransfers.changingFungibleBalances) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) TokenMovement(com.hedera.services.bdd.spec.transactions.token.TokenMovement) StandardCharsets(java.nio.charset.StandardCharsets) NoTokenTransfers.emptyTokenTransfers(com.hedera.services.bdd.spec.assertions.NoTokenTransfers.emptyTokenTransfers) ByteString(com.google.protobuf.ByteString) BaseErroringAssertsProvider(com.hedera.services.bdd.spec.assertions.BaseErroringAssertsProvider) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) List(java.util.List) Logger(org.apache.logging.log4j.Logger) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) TxnVerbs.tokenDissociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenDissociate) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) KycNotApplicable(com.hederahashgraph.api.proto.java.TokenKycStatus.KycNotApplicable) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) Granted(com.hederahashgraph.api.proto.java.TokenKycStatus.Granted) ErroringAsserts(com.hedera.services.bdd.spec.assertions.ErroringAsserts) Unfrozen(com.hederahashgraph.api.proto.java.TokenFreezeStatus.Unfrozen) INVALID_SIGNATURE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FreezeNotApplicable(com.hederahashgraph.api.proto.java.TokenFreezeStatus.FreezeNotApplicable) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) ACCOUNT_FROZEN_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_FROZEN_FOR_TOKEN) TxnVerbs.tokenFreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenFreeze) INVALID_TOKEN_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_ID) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) TokenType(com.hederahashgraph.api.proto.java.TokenType) AtomicLong(java.util.concurrent.atomic.AtomicLong) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) TxnVerbs.tokenUnfreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUnfreeze) AtomicLong(java.util.concurrent.atomic.AtomicLong) ByteString(com.google.protobuf.ByteString)

Example 60 with HapiApiSpec

use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.

the class CreateTopicPerfSuite method createTopicPerf.

private HapiApiSpec createTopicPerf() {
    final int NUM_TOPICS = 100000;
    KeyShape submitKeyShape = threshOf(2, SIMPLE, SIMPLE, listOf(2));
    return defaultHapiSpec("createTopicPerf").given().when(startThroughputObs("createTopicThroughput").msToSaturateQueues(50L), inParallel(// only ask for record for the last transaction
    asOpArray(NUM_TOPICS, i -> (i == (NUM_TOPICS - 1)) ? createTopic("testTopic" + i).submitKeyShape(submitKeyShape) : createTopic("testTopic" + i).submitKeyShape(submitKeyShape).deferStatusResolution()))).then(// wait until the record of the last transaction are ready
    finishThroughputObs("createTopicThroughput").gatedByQuery(() -> getTopicInfo("testTopic" + (NUM_TOPICS - 1))).sleepMs(1_000L).expiryMs(300_000L));
}
Also used : Arrays(java.util.Arrays) QueryVerbs.getTopicInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTopicInfo) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) KeyShape.listOf(com.hedera.services.bdd.spec.keys.KeyShape.listOf) KeyShape.threshOf(com.hedera.services.bdd.spec.keys.KeyShape.threshOf) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) UtilVerbs.startThroughputObs(com.hedera.services.bdd.spec.utilops.UtilVerbs.startThroughputObs) List(java.util.List) Logger(org.apache.logging.log4j.Logger) UtilVerbs.inParallel(com.hedera.services.bdd.spec.utilops.UtilVerbs.inParallel) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) UtilVerbs.finishThroughputObs(com.hedera.services.bdd.spec.utilops.UtilVerbs.finishThroughputObs) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Aggregations

HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)140 List (java.util.List)134 LogManager (org.apache.logging.log4j.LogManager)125 Logger (org.apache.logging.log4j.Logger)125 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)84 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)78 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)76 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)69 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)65 Function (java.util.function.Function)63 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)58 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)56 ByteString (com.google.protobuf.ByteString)53 Key (com.hederahashgraph.api.proto.java.Key)52 CustomSpecAssert.allRunFor (com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor)51 Optional (java.util.Optional)50 UtilVerbs.newKeyNamed (com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed)49 Consumer (java.util.function.Consumer)49 QueryVerbs.getAccountBalance (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance)47 TxnVerbs.fileCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate)46