Search in sources :

Example 1 with HapiSpecOperation

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

the class DynamicGasCostSuite method inlineCreateCanFailSafely.

private HapiApiSpec inlineCreateCanFailSafely() {
    final var tcValue = 1_234L;
    final var creation = "creation";
    final var initcode = "initcode";
    final var inlineCreateFactory = "inlineCreateFactory";
    final int foo = 22;
    final int timesToFail = 7;
    final AtomicLong factoryEntityNum = new AtomicLong();
    final AtomicReference<String> factoryEvmAddress = new AtomicReference<>();
    final AtomicReference<byte[]> testContractInitcode = new AtomicReference<>();
    return defaultHapiSpec("InlineCreateCanFailSafely").given(overriding("contracts.throttle.throttleByGas", "false"), fileCreate(initcode).path(REVERTING_CREATE_FACTORY_PATH), contractCreate(inlineCreateFactory).payingWith(GENESIS).bytecode(initcode).via(creation).exposingNumTo(num -> {
        factoryEntityNum.set(num);
        factoryEvmAddress.set(asHexedSolidityAddress(0, 0, num));
    })).when(sourcing(() -> contractCallLocal(inlineCreateFactory, CREATE_FACTORY_GET_BYTECODE_ABI, factoryEvmAddress.get(), foo).exposingTypedResultsTo(results -> {
        final var tcInitcode = (byte[]) results[0];
        testContractInitcode.set(tcInitcode);
        log.info("Contract reported TestContract initcode is {} bytes", tcInitcode.length);
    }).payingWith(GENESIS).nodePayment(ONE_HBAR))).then(inParallel(IntStream.range(0, timesToFail).mapToObj(i -> sourcing(() -> contractCall(inlineCreateFactory, NORMAL_DEPLOY_ABI, testContractInitcode.get()).payingWith(GENESIS).gas(4_000_000L).sending(tcValue).via(creation))).toArray(HapiSpecOperation[]::new)), sourcing(() -> cryptoCreate("nextUp").exposingCreatedIdTo(id -> log.info("Next entity num was {} instead of expected {}", id.getAccountNum(), factoryEntityNum.get() + 1))));
}
Also used : START_CHAIN_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.START_CHAIN_ABI) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) PC2_USER_MINT_NFT_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_USER_MINT_NFT_ABI) TxnVerbs.contractDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractDelete) NftTransfer(com.hederahashgraph.api.proto.java.NftTransfer) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) OBTAINER_SAME_CONTRACT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OBTAINER_SAME_CONTRACT_ID) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) PC2_DISSOCIATE_BOTH_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_DISSOCIATE_BOTH_ABI) QueryVerbs.contractCallLocal(com.hedera.services.bdd.spec.queries.QueryVerbs.contractCallLocal) REVERTING_CREATE_FACTORY_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.REVERTING_CREATE_FACTORY_PATH) BigInteger(java.math.BigInteger) ADDRESS_VAL_RETURNER_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADDRESS_VAL_RETURNER_PATH) CREATE2_FACTORY_GET_ADDRESS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE2_FACTORY_GET_ADDRESS_ABI) SAFE_MINT_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_MINT_ABI) CONTRACT_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_DELETED) ACCOUNT_STILL_OWNS_NFTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_STILL_OWNS_NFTS) ADDRESS_VAL_CALL_RETURNER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADDRESS_VAL_CALL_RETURNER_ABI) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) ContractFnResultAsserts.resultWith(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith) TEST_CONTRACT_VACATE_ADDRESS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.TEST_CONTRACT_VACATE_ADDRESS_ABI) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) Logger(org.apache.logging.log4j.Logger) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) QueryVerbs.getContractBytecode(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractBytecode) TxnVerbs.tokenDissociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenDissociate) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) SALTING_CREATOR_FACTORY_BUILD_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SALTING_CREATOR_FACTORY_BUILD_ABI) UtilVerbs.overriding(com.hedera.services.bdd.spec.utilops.UtilVerbs.overriding) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) SAFE_DISSOCIATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_DISSOCIATE_ABI) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) CommonUtils.hex(com.swirlds.common.CommonUtils.hex) TxnVerbs.cryptoUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoUpdate) HapiPropertySource.contractIdFromHexedMirrorAddress(com.hedera.services.bdd.spec.HapiPropertySource.contractIdFromHexedMirrorAddress) ADDRESS_VAL_CREATE_RETURNER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADDRESS_VAL_CREATE_RETURNER_ABI) WHAT_IS_FOO_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.WHAT_IS_FOO_ABI) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) BUILD_THEN_REVERT_THEN_BUILD_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BUILD_THEN_REVERT_THEN_BUILD_ABI) AccountID(com.hederahashgraph.api.proto.java.AccountID) SAFE_TOKEN_TRANSFER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_TOKEN_TRANSFER_ABI) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) UtilVerbs.updateLargeFile(com.hedera.services.bdd.spec.utilops.UtilVerbs.updateLargeFile) CREATE2_FACTORY_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE2_FACTORY_PATH) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) HapiPropertySource.asSolidityAddress(com.hedera.services.bdd.spec.HapiPropertySource.asSolidityAddress) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) AtomicLong(java.util.concurrent.atomic.AtomicLong) PC2_CREATE_USER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_CREATE_USER_ABI) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) TokenID(com.hederahashgraph.api.proto.java.TokenID) PC2_FT_SEND_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_FT_SEND_ABI) Utils.asAddress(com.hedera.services.bdd.suites.contract.Utils.asAddress) PC2_ASSOCIATE_BOTH_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_ASSOCIATE_BOTH_ABI) CONTRACT_REVERT_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_REVERT_EXECUTED) INVALID_SOLIDITY_ADDRESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SOLIDITY_ADDRESS) ContractInfoAsserts.contractWith(com.hedera.services.bdd.spec.assertions.ContractInfoAsserts.contractWith) RETURN_THIS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.RETURN_THIS_ABI) SAFE_ASSOCIATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_ASSOCIATE_ABI) HapiPropertySource.asContractString(com.hedera.services.bdd.spec.HapiPropertySource.asContractString) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) CREATE2_FACTORY_GET_BYTECODE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE2_FACTORY_GET_BYTECODE_ABI) TxnVerbs.contractUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractUpdate) TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) ContractLogAsserts.logWith(com.hedera.services.bdd.spec.assertions.ContractLogAsserts.logWith) QueryVerbs.getContractInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo) ContractID(com.hederahashgraph.api.proto.java.ContractID) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) CREATE_PLACEHOLDER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_PLACEHOLDER_ABI) UtilVerbs.inParallel(com.hedera.services.bdd.spec.utilops.UtilVerbs.inParallel) HapiPropertySource.literalIdFromHexedMirrorAddress(com.hedera.services.bdd.spec.HapiPropertySource.literalIdFromHexedMirrorAddress) WRONG_REPEATED_CREATE2_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.WRONG_REPEATED_CREATE2_ABI) HapiPropertySource.asHexedSolidityAddress(com.hedera.services.bdd.spec.HapiPropertySource.asHexedSolidityAddress) REVERTING_CREATE2_FACTORY_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.REVERTING_CREATE2_FACTORY_PATH) SALTING_CREATOR_FACTORY_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SALTING_CREATOR_FACTORY_PATH) SALTING_CREATOR_CALL_CREATOR_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SALTING_CREATOR_CALL_CREATOR_ABI) RELINQUISH_FUNDS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.RELINQUISH_FUNDS_ABI) SAFE_MULTIPLE_ASSOCIATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_MULTIPLE_ASSOCIATE_ABI) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) Utils.extractByteCode(com.hedera.services.bdd.suites.contract.Utils.extractByteCode) ByteString(com.google.protobuf.ByteString) List(java.util.List) REVERTED_SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.REVERTED_SUCCESS) CREATE_DONOR_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_DONOR_ABI) TxnVerbs.tokenUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUpdate) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) CREATE_AND_RECREATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_AND_RECREATE_ABI) IntStream(java.util.stream.IntStream) CONTRACT_EXECUTION_EXCEPTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_EXECUTION_EXCEPTION) Utils(com.hedera.services.bdd.suites.contract.Utils) MiscEETUtils.metadata(com.hedera.services.bdd.suites.utils.MiscEETUtils.metadata) CREATE2_FACTORY_DEPLOY_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE2_FACTORY_DEPLOY_ABI) SALTING_CREATOR_CREATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SALTING_CREATOR_CREATE_ABI) AtomicReference(java.util.concurrent.atomic.AtomicReference) INVALID_SIGNATURE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) TEST_CONTRACT_GET_BALANCE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.TEST_CONTRACT_GET_BALANCE_ABI) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) UtilVerbs.childRecordsCheck(com.hedera.services.bdd.spec.utilops.UtilVerbs.childRecordsCheck) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) CREATE_FACTORY_GET_BYTECODE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_FACTORY_GET_BYTECODE_ABI) PRECOMPILE_CREATE2_USER_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PRECOMPILE_CREATE2_USER_PATH) SAFE_NFT_TRANSFER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_NFT_TRANSFER_ABI) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) TransferList(com.hederahashgraph.api.proto.java.TransferList) NORMAL_DEPLOY_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.NORMAL_DEPLOY_ABI) SAFE_MULTIPLE_DISSOCIATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_MULTIPLE_DISSOCIATE_ABI) SAFE_BURN_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_BURN_ABI) OUTER_CREATOR_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.OUTER_CREATOR_PATH) PC2_USER_HELPER_MINT_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_USER_HELPER_MINT_ABI) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) VANILLA_TOKEN(com.hedera.services.bdd.suites.token.TokenAssociationSpecs.VANILLA_TOKEN) ContractFnResultAsserts.isLiteralResult(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isLiteralResult) PC2_NFT_SEND_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_NFT_SEND_ABI) KNOWABLE_TOKEN(com.hedera.services.bdd.suites.token.TokenAssociationSpecs.KNOWABLE_TOKEN) UtilVerbs(com.hedera.services.bdd.spec.utilops.UtilVerbs) SAFE_NFTS_TRANSFER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_NFTS_TRANSFER_ABI) CREATE_DONOR_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_DONOR_PATH) SAFE_TOKENS_TRANSFER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_TOKENS_TRANSFER_ABI) INVALID_CONTRACT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CONTRACT_ID) NON_FUNGIBLE_UNIQUE(com.hederahashgraph.api.proto.java.TokenType.NON_FUNGIBLE_UNIQUE) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) FUNGIBLE_COMMON(com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON) AssertUtils.inOrder(com.hedera.services.bdd.spec.assertions.AssertUtils.inOrder) CommonUtils.unhex(com.swirlds.common.CommonUtils.unhex) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) TokenMovement.movingUnique(com.hedera.services.bdd.spec.transactions.token.TokenMovement.movingUnique) AtomicLong(java.util.concurrent.atomic.AtomicLong) AtomicReference(java.util.concurrent.atomic.AtomicReference) HapiPropertySource.asContractString(com.hedera.services.bdd.spec.HapiPropertySource.asContractString) ByteString(com.google.protobuf.ByteString)

Example 2 with HapiSpecOperation

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

the class DynamicGasCostSuite method inlineCreate2CanFailSafely.

// https://github.com/hashgraph/hedera-services/issues/2868
private HapiApiSpec inlineCreate2CanFailSafely() {
    final var tcValue = 1_234L;
    final var creation = "creation";
    final var initcode = "initcode";
    final var inlineCreate2Factory = "inlineCreate2Factory";
    final int foo = 22;
    final int salt = 23;
    final int timesToFail = 7;
    final AtomicLong factoryEntityNum = new AtomicLong();
    final AtomicReference<String> factoryEvmAddress = new AtomicReference<>();
    final AtomicReference<byte[]> testContractInitcode = new AtomicReference<>();
    return defaultHapiSpec("InlineCreate2CanFailSafely").given(overriding("contracts.throttle.throttleByGas", "false"), fileCreate(initcode).path(REVERTING_CREATE2_FACTORY_PATH), contractCreate(inlineCreate2Factory).payingWith(GENESIS).bytecode(initcode).via(creation).exposingNumTo(num -> {
        factoryEntityNum.set(num);
        factoryEvmAddress.set(asHexedSolidityAddress(0, 0, num));
    })).when(sourcing(() -> contractCallLocal(inlineCreate2Factory, CREATE2_FACTORY_GET_BYTECODE_ABI, factoryEvmAddress.get(), foo).exposingTypedResultsTo(results -> {
        final var tcInitcode = (byte[]) results[0];
        testContractInitcode.set(tcInitcode);
        log.info("Contract reported TestContract initcode is {} bytes", tcInitcode.length);
    }).payingWith(GENESIS).nodePayment(ONE_HBAR))).then(inParallel(IntStream.range(0, timesToFail).mapToObj(i -> sourcing(() -> contractCall(inlineCreate2Factory, CREATE2_FACTORY_DEPLOY_ABI, testContractInitcode.get(), salt).payingWith(GENESIS).gas(4_000_000L).sending(tcValue).via(creation))).toArray(HapiSpecOperation[]::new)), sourcing(() -> cryptoCreate("nextUp").exposingCreatedIdTo(id -> log.info("Next entity num was {} instead of expected {}", id.getAccountNum(), factoryEntityNum.get() + 1))));
}
Also used : START_CHAIN_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.START_CHAIN_ABI) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) PC2_USER_MINT_NFT_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_USER_MINT_NFT_ABI) TxnVerbs.contractDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractDelete) NftTransfer(com.hederahashgraph.api.proto.java.NftTransfer) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) OBTAINER_SAME_CONTRACT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OBTAINER_SAME_CONTRACT_ID) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) PC2_DISSOCIATE_BOTH_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_DISSOCIATE_BOTH_ABI) QueryVerbs.contractCallLocal(com.hedera.services.bdd.spec.queries.QueryVerbs.contractCallLocal) REVERTING_CREATE_FACTORY_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.REVERTING_CREATE_FACTORY_PATH) BigInteger(java.math.BigInteger) ADDRESS_VAL_RETURNER_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADDRESS_VAL_RETURNER_PATH) CREATE2_FACTORY_GET_ADDRESS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE2_FACTORY_GET_ADDRESS_ABI) SAFE_MINT_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_MINT_ABI) CONTRACT_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_DELETED) ACCOUNT_STILL_OWNS_NFTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_STILL_OWNS_NFTS) ADDRESS_VAL_CALL_RETURNER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADDRESS_VAL_CALL_RETURNER_ABI) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) ContractFnResultAsserts.resultWith(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith) TEST_CONTRACT_VACATE_ADDRESS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.TEST_CONTRACT_VACATE_ADDRESS_ABI) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) Logger(org.apache.logging.log4j.Logger) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) QueryVerbs.getContractBytecode(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractBytecode) TxnVerbs.tokenDissociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenDissociate) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) SALTING_CREATOR_FACTORY_BUILD_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SALTING_CREATOR_FACTORY_BUILD_ABI) UtilVerbs.overriding(com.hedera.services.bdd.spec.utilops.UtilVerbs.overriding) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) SAFE_DISSOCIATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_DISSOCIATE_ABI) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) CommonUtils.hex(com.swirlds.common.CommonUtils.hex) TxnVerbs.cryptoUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoUpdate) HapiPropertySource.contractIdFromHexedMirrorAddress(com.hedera.services.bdd.spec.HapiPropertySource.contractIdFromHexedMirrorAddress) ADDRESS_VAL_CREATE_RETURNER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADDRESS_VAL_CREATE_RETURNER_ABI) WHAT_IS_FOO_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.WHAT_IS_FOO_ABI) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) BUILD_THEN_REVERT_THEN_BUILD_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BUILD_THEN_REVERT_THEN_BUILD_ABI) AccountID(com.hederahashgraph.api.proto.java.AccountID) SAFE_TOKEN_TRANSFER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_TOKEN_TRANSFER_ABI) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) UtilVerbs.updateLargeFile(com.hedera.services.bdd.spec.utilops.UtilVerbs.updateLargeFile) CREATE2_FACTORY_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE2_FACTORY_PATH) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) HapiPropertySource.asSolidityAddress(com.hedera.services.bdd.spec.HapiPropertySource.asSolidityAddress) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) AtomicLong(java.util.concurrent.atomic.AtomicLong) PC2_CREATE_USER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_CREATE_USER_ABI) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) TokenID(com.hederahashgraph.api.proto.java.TokenID) PC2_FT_SEND_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_FT_SEND_ABI) Utils.asAddress(com.hedera.services.bdd.suites.contract.Utils.asAddress) PC2_ASSOCIATE_BOTH_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_ASSOCIATE_BOTH_ABI) CONTRACT_REVERT_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_REVERT_EXECUTED) INVALID_SOLIDITY_ADDRESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SOLIDITY_ADDRESS) ContractInfoAsserts.contractWith(com.hedera.services.bdd.spec.assertions.ContractInfoAsserts.contractWith) RETURN_THIS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.RETURN_THIS_ABI) SAFE_ASSOCIATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_ASSOCIATE_ABI) HapiPropertySource.asContractString(com.hedera.services.bdd.spec.HapiPropertySource.asContractString) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) CREATE2_FACTORY_GET_BYTECODE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE2_FACTORY_GET_BYTECODE_ABI) TxnVerbs.contractUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractUpdate) TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) ContractLogAsserts.logWith(com.hedera.services.bdd.spec.assertions.ContractLogAsserts.logWith) QueryVerbs.getContractInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo) ContractID(com.hederahashgraph.api.proto.java.ContractID) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) CREATE_PLACEHOLDER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_PLACEHOLDER_ABI) UtilVerbs.inParallel(com.hedera.services.bdd.spec.utilops.UtilVerbs.inParallel) HapiPropertySource.literalIdFromHexedMirrorAddress(com.hedera.services.bdd.spec.HapiPropertySource.literalIdFromHexedMirrorAddress) WRONG_REPEATED_CREATE2_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.WRONG_REPEATED_CREATE2_ABI) HapiPropertySource.asHexedSolidityAddress(com.hedera.services.bdd.spec.HapiPropertySource.asHexedSolidityAddress) REVERTING_CREATE2_FACTORY_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.REVERTING_CREATE2_FACTORY_PATH) SALTING_CREATOR_FACTORY_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SALTING_CREATOR_FACTORY_PATH) SALTING_CREATOR_CALL_CREATOR_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SALTING_CREATOR_CALL_CREATOR_ABI) RELINQUISH_FUNDS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.RELINQUISH_FUNDS_ABI) SAFE_MULTIPLE_ASSOCIATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_MULTIPLE_ASSOCIATE_ABI) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) Utils.extractByteCode(com.hedera.services.bdd.suites.contract.Utils.extractByteCode) ByteString(com.google.protobuf.ByteString) List(java.util.List) REVERTED_SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.REVERTED_SUCCESS) CREATE_DONOR_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_DONOR_ABI) TxnVerbs.tokenUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUpdate) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) CREATE_AND_RECREATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_AND_RECREATE_ABI) IntStream(java.util.stream.IntStream) CONTRACT_EXECUTION_EXCEPTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_EXECUTION_EXCEPTION) Utils(com.hedera.services.bdd.suites.contract.Utils) MiscEETUtils.metadata(com.hedera.services.bdd.suites.utils.MiscEETUtils.metadata) CREATE2_FACTORY_DEPLOY_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE2_FACTORY_DEPLOY_ABI) SALTING_CREATOR_CREATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SALTING_CREATOR_CREATE_ABI) AtomicReference(java.util.concurrent.atomic.AtomicReference) INVALID_SIGNATURE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) TEST_CONTRACT_GET_BALANCE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.TEST_CONTRACT_GET_BALANCE_ABI) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) UtilVerbs.childRecordsCheck(com.hedera.services.bdd.spec.utilops.UtilVerbs.childRecordsCheck) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) CREATE_FACTORY_GET_BYTECODE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_FACTORY_GET_BYTECODE_ABI) PRECOMPILE_CREATE2_USER_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PRECOMPILE_CREATE2_USER_PATH) SAFE_NFT_TRANSFER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_NFT_TRANSFER_ABI) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) TransferList(com.hederahashgraph.api.proto.java.TransferList) NORMAL_DEPLOY_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.NORMAL_DEPLOY_ABI) SAFE_MULTIPLE_DISSOCIATE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_MULTIPLE_DISSOCIATE_ABI) SAFE_BURN_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_BURN_ABI) OUTER_CREATOR_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.OUTER_CREATOR_PATH) PC2_USER_HELPER_MINT_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_USER_HELPER_MINT_ABI) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) VANILLA_TOKEN(com.hedera.services.bdd.suites.token.TokenAssociationSpecs.VANILLA_TOKEN) ContractFnResultAsserts.isLiteralResult(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isLiteralResult) PC2_NFT_SEND_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PC2_NFT_SEND_ABI) KNOWABLE_TOKEN(com.hedera.services.bdd.suites.token.TokenAssociationSpecs.KNOWABLE_TOKEN) UtilVerbs(com.hedera.services.bdd.spec.utilops.UtilVerbs) SAFE_NFTS_TRANSFER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_NFTS_TRANSFER_ABI) CREATE_DONOR_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_DONOR_PATH) SAFE_TOKENS_TRANSFER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SAFE_TOKENS_TRANSFER_ABI) INVALID_CONTRACT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CONTRACT_ID) NON_FUNGIBLE_UNIQUE(com.hederahashgraph.api.proto.java.TokenType.NON_FUNGIBLE_UNIQUE) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) FUNGIBLE_COMMON(com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON) AssertUtils.inOrder(com.hedera.services.bdd.spec.assertions.AssertUtils.inOrder) CommonUtils.unhex(com.swirlds.common.CommonUtils.unhex) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) TokenMovement.movingUnique(com.hedera.services.bdd.spec.transactions.token.TokenMovement.movingUnique) AtomicLong(java.util.concurrent.atomic.AtomicLong) AtomicReference(java.util.concurrent.atomic.AtomicReference) HapiPropertySource.asContractString(com.hedera.services.bdd.spec.HapiPropertySource.asContractString) ByteString(com.google.protobuf.ByteString)

Example 3 with HapiSpecOperation

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

the class ContractCreateSuite method canCallPendingContractSafely.

private HapiApiSpec canCallPendingContractSafely() {
    final int numSlots = 64;
    final int createBurstSize = 500;
    final int[] targets = { 19, 24 };
    final AtomicLong createdFileNum = new AtomicLong();
    final var callTxn = "callTxn";
    final var initcode = "initcode";
    return defaultHapiSpec("CanCallPendingContractSafely").given(UtilVerbs.overriding("contracts.throttle.throttleByGas", "false"), fileCreate(initcode).path(FIBONACCI_PLUS_PATH).payingWith(GENESIS).exposingNumTo(createdFileNum::set), inParallel(IntStream.range(0, createBurstSize).mapToObj(i -> contractCreate("contract" + i, FIBONACCI_PLUS_CONSTRUCTOR_ABI, numSlots).fee(ONE_HUNDRED_HBARS).gas(300_000L).payingWith(GENESIS).noLogging().deferStatusResolution().bytecode(initcode).adminKey(THRESHOLD)).toArray(HapiSpecOperation[]::new))).when().then(sourcing(() -> contractCall("0.0." + (createdFileNum.get() + createBurstSize), ADD_NTH_FIB_ABI, targets, 12).payingWith(GENESIS).gas(300_000L).via(callTxn)), UtilVerbs.resetAppPropertiesTo("src/main/resource/bootstrap.properties"));
}
Also used : Arrays(java.util.Arrays) ContractFnResultAsserts.isContractWith(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isContractWith) SEND_REPEATEDLY_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SEND_REPEATEDLY_ABI) SigControl(com.hedera.services.bdd.spec.keys.SigControl) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) ON(com.hedera.services.bdd.spec.keys.SigControl.ON) QueryVerbs.getContractInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) ContractID(com.hederahashgraph.api.proto.java.ContractID) EMPTY_CONSTRUCTOR(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.EMPTY_CONSTRUCTOR) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) FIBONACCI_PLUS_CONSTRUCTOR_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.FIBONACCI_PLUS_CONSTRUCTOR_ABI) CONTRACT(com.hedera.services.bdd.spec.keys.KeyShape.CONTRACT) UtilVerbs.inParallel(com.hedera.services.bdd.spec.utilops.UtilVerbs.inParallel) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) BigInteger(java.math.BigInteger) Bytes32(org.apache.tuweni.bytes.Bytes32) Path(java.nio.file.Path) Longs(com.google.common.primitives.Longs) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) ContractFnResultAsserts.resultWith(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TRANSACTION_OVERSIZE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_OVERSIZE) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) KeyShape.threshOf(com.hedera.services.bdd.spec.keys.KeyShape.threshOf) ByteString(com.google.protobuf.ByteString) UncheckedIOException(java.io.UncheckedIOException) MEMO_TOO_LONG(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MEMO_TOO_LONG) List(java.util.List) ControlForKey.forKey(com.hedera.services.bdd.spec.keys.ControlForKey.forKey) Logger(org.apache.logging.log4j.Logger) CONSPICUOUS_DONATION_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CONSPICUOUS_DONATION_ABI) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) IntStream(java.util.stream.IntStream) KeyShape.sigs(com.hedera.services.bdd.spec.keys.KeyShape.sigs) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) SEND_THEN_REVERT_NESTED_SENDS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SEND_THEN_REVERT_NESTED_SENDS_ABI) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) AtomicReference(java.util.concurrent.atomic.AtomicReference) DELEGATE_CONTRACT(com.hedera.services.bdd.spec.keys.KeyShape.DELEGATE_CONTRACT) INVALID_SIGNATURE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) KeyShape.listOf(com.hedera.services.bdd.spec.keys.KeyShape.listOf) TxnVerbs.cryptoUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoUpdate) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) UtilVerbs.childRecordsCheck(com.hedera.services.bdd.spec.utilops.UtilVerbs.childRecordsCheck) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) MAX_GAS_LIMIT_EXCEEDED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MAX_GAS_LIMIT_EXCEEDED) MULTIPURPOSE_BYTECODE_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MULTIPURPOSE_BYTECODE_PATH) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) UtilVerbs.newKeyListNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyListNamed) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PROPAGATE_NESTED_CREATIONS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PROPAGATE_NESTED_CREATIONS_ABI) FIBONACCI_PLUS_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.FIBONACCI_PLUS_PATH) Files(java.nio.file.Files) ERROR_DECODING_BYTESTRING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ERROR_DECODING_BYTESTRING) INVALID_ZERO_BYTE_IN_STRING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ZERO_BYTE_IN_STRING) IOException(java.io.IOException) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) UtilVerbs.contractListWithPropertiesInheritedFrom(com.hedera.services.bdd.spec.utilops.UtilVerbs.contractListWithPropertiesInheritedFrom) ContractFnResultAsserts.isLiteralResult(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isLiteralResult) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) HapiPropertySource.asSolidityAddress(com.hedera.services.bdd.spec.HapiPropertySource.asSolidityAddress) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) AtomicLong(java.util.concurrent.atomic.AtomicLong) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) INSUFFICIENT_GAS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_GAS) OFF(com.hedera.services.bdd.spec.keys.SigControl.OFF) UtilVerbs(com.hedera.services.bdd.spec.utilops.UtilVerbs) THRESHOLD(com.hedera.services.bdd.spec.keys.KeyFactory.KeyType.THRESHOLD) Assertions(org.junit.jupiter.api.Assertions) CONTRACT_REVERT_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_REVERT_EXECUTED) INVALID_SOLIDITY_ADDRESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SOLIDITY_ADDRESS) ADD_NTH_FIB_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADD_NTH_FIB_ABI) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) AssertUtils.inOrder(com.hedera.services.bdd.spec.assertions.AssertUtils.inOrder) ContractInfoAsserts.contractWith(com.hedera.services.bdd.spec.assertions.ContractInfoAsserts.contractWith) INSUFFICIENT_TX_FEE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE) LogManager(org.apache.logging.log4j.LogManager) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 4 with HapiSpecOperation

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

the class RandomTokenTransfer method get.

@Override
public Optional<HapiSpecOperation> get() {
    var xferRel = tokenRels.getQualifying();
    if (xferRel.isEmpty()) {
        return Optional.empty();
    }
    HapiSpecOperation op;
    var rel = explicit(xferRel.get());
    var token = rel.getRight();
    if (BASE_RANDOM.nextBoolean()) {
        op = cryptoTransfer(moving(1, token).between(spec -> spec.registry().getTreasury(token), ignore -> rel.getLeft())).hasPrecheckFrom(STANDARD_PERMISSIBLE_PRECHECKS).hasKnownStatusFrom(permissibleOutcomes);
    } else {
        op = cryptoTransfer(moving(1, token).between(ignore -> rel.getLeft(), spec -> spec.registry().getTreasury(token))).hasPrecheckFrom(STANDARD_PERMISSIBLE_PRECHECKS).hasKnownStatusFrom(permissibleOutcomes).showingResolvedStatus();
    }
    return Optional.of(op);
}
Also used : RandomTokenDissociation.explicit(com.hedera.services.bdd.spec.infrastructure.providers.ops.token.RandomTokenDissociation.explicit) RegistrySourcedNameProvider(com.hedera.services.bdd.spec.infrastructure.providers.names.RegistrySourcedNameProvider) ACCOUNT_FROZEN_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_FROZEN_FOR_TOKEN) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) TOKEN_WAS_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_WAS_DELETED) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) TokenAccountRegistryRel(com.hedera.services.bdd.spec.infrastructure.listeners.TokenAccountRegistryRel) Logger(org.apache.logging.log4j.Logger) INSUFFICIENT_TOKEN_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TOKEN_BALANCE) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN) Optional(java.util.Optional) OpProvider(com.hedera.services.bdd.spec.infrastructure.OpProvider) LogManager(org.apache.logging.log4j.LogManager) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

Example 5 with HapiSpecOperation

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

the class RandomContract method suggestedInitializers.

@Override
public List<HapiSpecOperation> suggestedInitializers() {
    List<HapiSpecOperation> ops = new ArrayList<>();
    for (SupportedContract choice : choices) {
        HapiFileCreate op = fileCreate(fileFor(choice)).noLogging().path(choice.getPathToBytecode());
        ops.add(op);
    }
    return ops;
}
Also used : SupportedContract(com.hedera.services.bdd.spec.infrastructure.meta.SupportedContract) ArrayList(java.util.ArrayList) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) HapiFileCreate(com.hedera.services.bdd.spec.transactions.file.HapiFileCreate)

Aggregations

HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)57 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)48 List (java.util.List)47 LogManager (org.apache.logging.log4j.LogManager)47 Logger (org.apache.logging.log4j.Logger)47 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)37 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)36 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)33 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)29 Supplier (java.util.function.Supplier)29 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)28 UtilVerbs.logIt (com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt)27 BUSY (com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY)27 PLATFORM_TRANSACTION_NOT_CREATED (com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED)27 PerfTestLoadSettings (com.hedera.services.bdd.suites.perf.PerfTestLoadSettings)26 DUPLICATE_TRANSACTION (com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION)26 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)24 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)23 AtomicLong (java.util.concurrent.atomic.AtomicLong)21 TxnVerbs.fileCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate)20