Search in sources :

Example 31 with HapiApiSpec

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

the class SysDelSysUndelSpec method systemDeleteThenUndeleteRestoresContentsAndExpiry.

private HapiApiSpec systemDeleteThenUndeleteRestoresContentsAndExpiry() {
    var now = Instant.now().getEpochSecond();
    var lifetime = THREE_MONTHS_IN_SECONDS;
    AtomicLong initExpiry = new AtomicLong();
    return defaultHapiSpec("happyPathFlows").given(fileCreate("misc").lifetime(lifetime).contents(ORIG_FILE), UtilVerbs.withOpContext((spec, opLog) -> {
        initExpiry.set(spec.registry().getTimestamp("misc").getSeconds());
    })).when(systemFileDelete("misc").payingWith(SYSTEM_DELETE_ADMIN).fee(0L).updatingExpiry(now + lifetime - 1_000), getFileInfo("misc").nodePayment(1_234L).hasAnswerOnlyPrecheck(OK).hasDeleted(true), systemFileUndelete("misc").payingWith(SYSTEM_UNDELETE_ADMIN).fee(0L)).then(getFileContents("misc").hasContents(ignore -> ORIG_FILE), getFileInfo("misc").hasExpiry(initExpiry::get));
}
Also used : QueryVerbs.getFileContents(com.hedera.services.bdd.spec.queries.QueryVerbs.getFileContents) TxnVerbs.systemFileDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.systemFileDelete) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) TxnVerbs.systemFileUndelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.systemFileUndelete) ENTITY_NOT_ALLOWED_TO_DELETE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ENTITY_NOT_ALLOWED_TO_DELETE) AUTHORIZATION_FAILED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.AUTHORIZATION_FAILED) QueryVerbs.getFileInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getFileInfo) Instant(java.time.Instant) AtomicLong(java.util.concurrent.atomic.AtomicLong) 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) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) INVALID_FILE_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_FILE_ID) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) NOT_SUPPORTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.NOT_SUPPORTED) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 32 with HapiApiSpec

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

the class HapiTokenFreeze method opBodyDef.

@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
    var aId = TxnUtils.asId(account, spec);
    var tId = TxnUtils.asTokenId(token, spec);
    TokenFreezeAccountTransactionBody opBody = spec.txns().<TokenFreezeAccountTransactionBody, TokenFreezeAccountTransactionBody.Builder>body(TokenFreezeAccountTransactionBody.class, b -> {
        b.setAccount(aId);
        b.setToken(tId);
    });
    return b -> b.setTokenFreeze(opBody);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) TokenOpsUsage(com.hedera.services.usage.token.TokenOpsUsage) TOKEN_OPS_USAGE_UTILS(com.hedera.services.usage.token.TokenOpsUsageUtils.TOKEN_OPS_USAGE_UTILS) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) FeeData(com.hederahashgraph.api.proto.java.FeeData) MoreObjects(com.google.common.base.MoreObjects) Function(java.util.function.Function) Consumer(java.util.function.Consumer) BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) AdapterUtils(com.hedera.services.bdd.spec.fees.AdapterUtils) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) SigValueObj(com.hederahashgraph.fee.SigValueObj) TokenFreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenFreezeAccountTransactionBody) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) TokenFreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenFreezeAccountTransactionBody)

Example 33 with HapiApiSpec

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

the class HapiTokenMint method opBodyDef.

@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
    var tId = TxnUtils.asTokenId(token, spec);
    TokenMintTransactionBody opBody = spec.txns().<TokenMintTransactionBody, TokenMintTransactionBody.Builder>body(TokenMintTransactionBody.class, b -> {
        b.setToken(tId);
        b.setAmount(amount);
        b.addAllMetadata(metadata);
    });
    return b -> b.setTokenMint(opBody);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) Function(java.util.function.Function) TokenInfo(com.hederahashgraph.api.proto.java.TokenInfo) BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HapiTokenFeeScheduleUpdate.lookupInfo(com.hedera.services.bdd.spec.transactions.token.HapiTokenFeeScheduleUpdate.lookupInfo) SubType(com.hederahashgraph.api.proto.java.SubType) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) SigValueObj(com.hederahashgraph.fee.SigValueObj) TokenOpsUsage(com.hedera.services.usage.token.TokenOpsUsage) TOKEN_OPS_USAGE_UTILS(com.hedera.services.usage.token.TokenOpsUsageUtils.TOKEN_OPS_USAGE_UTILS) FeeData(com.hederahashgraph.api.proto.java.FeeData) MoreObjects(com.google.common.base.MoreObjects) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) ByteString(com.google.protobuf.ByteString) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) AdapterUtils(com.hedera.services.bdd.spec.fees.AdapterUtils) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody)

Example 34 with HapiApiSpec

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

the class HapiTokenPause method opBodyDef.

@Override
protected Consumer<TransactionBody.Builder> opBodyDef(final HapiApiSpec spec) throws Throwable {
    var tId = TxnUtils.asTokenId(token, spec);
    TokenPauseTransactionBody opBody = spec.txns().<TokenPauseTransactionBody, TokenPauseTransactionBody.Builder>body(TokenPauseTransactionBody.class, b -> {
        b.setToken(tId);
    });
    return b -> b.setTokenPause(opBody);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) TokenOpsUsage(com.hedera.services.usage.token.TokenOpsUsage) TOKEN_OPS_USAGE_UTILS(com.hedera.services.usage.token.TokenOpsUsageUtils.TOKEN_OPS_USAGE_UTILS) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) TokenPauseTransactionBody(com.hederahashgraph.api.proto.java.TokenPauseTransactionBody) FeeData(com.hederahashgraph.api.proto.java.FeeData) MoreObjects(com.google.common.base.MoreObjects) Function(java.util.function.Function) Consumer(java.util.function.Consumer) BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) AdapterUtils(com.hedera.services.bdd.spec.fees.AdapterUtils) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) SigValueObj(com.hederahashgraph.fee.SigValueObj) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) TokenPauseTransactionBody(com.hederahashgraph.api.proto.java.TokenPauseTransactionBody)

Example 35 with HapiApiSpec

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

the class HapiTokenUnfreeze method opBodyDef.

@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
    var aId = TxnUtils.asId(account, spec);
    var tId = TxnUtils.asTokenId(token, spec);
    TokenUnfreezeAccountTransactionBody opBody = spec.txns().<TokenUnfreezeAccountTransactionBody, TokenUnfreezeAccountTransactionBody.Builder>body(TokenUnfreezeAccountTransactionBody.class, b -> {
        b.setAccount(aId);
        b.setToken(tId);
    });
    return b -> b.setTokenUnfreeze(opBody);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) TokenOpsUsage(com.hedera.services.usage.token.TokenOpsUsage) TOKEN_OPS_USAGE_UTILS(com.hedera.services.usage.token.TokenOpsUsageUtils.TOKEN_OPS_USAGE_UTILS) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) FeeData(com.hederahashgraph.api.proto.java.FeeData) MoreObjects(com.google.common.base.MoreObjects) Function(java.util.function.Function) Consumer(java.util.function.Consumer) BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) AdapterUtils(com.hedera.services.bdd.spec.fees.AdapterUtils) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) TokenUnfreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenUnfreezeAccountTransactionBody) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) SigValueObj(com.hederahashgraph.fee.SigValueObj) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) TokenUnfreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenUnfreezeAccountTransactionBody)

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