Search in sources :

Example 1 with CREATE_FACTORY_GET_BYTECODE_ABI

use of com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE_FACTORY_GET_BYTECODE_ABI 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)

Aggregations

ByteString (com.google.protobuf.ByteString)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)1 HapiPropertySource.asContractString (com.hedera.services.bdd.spec.HapiPropertySource.asContractString)1 HapiPropertySource.asHexedSolidityAddress (com.hedera.services.bdd.spec.HapiPropertySource.asHexedSolidityAddress)1 HapiPropertySource.asSolidityAddress (com.hedera.services.bdd.spec.HapiPropertySource.asSolidityAddress)1 HapiPropertySource.contractIdFromHexedMirrorAddress (com.hedera.services.bdd.spec.HapiPropertySource.contractIdFromHexedMirrorAddress)1 HapiPropertySource.literalIdFromHexedMirrorAddress (com.hedera.services.bdd.spec.HapiPropertySource.literalIdFromHexedMirrorAddress)1 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)1 AssertUtils.inOrder (com.hedera.services.bdd.spec.assertions.AssertUtils.inOrder)1 ContractFnResultAsserts.isLiteralResult (com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isLiteralResult)1 ContractFnResultAsserts.resultWith (com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith)1 ContractInfoAsserts.contractWith (com.hedera.services.bdd.spec.assertions.ContractInfoAsserts.contractWith)1 ContractLogAsserts.logWith (com.hedera.services.bdd.spec.assertions.ContractLogAsserts.logWith)1 TransactionRecordAsserts.recordWith (com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith)1 ContractResources (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources)1 ADDRESS_VAL_CALL_RETURNER_ABI (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADDRESS_VAL_CALL_RETURNER_ABI)1 ADDRESS_VAL_CREATE_RETURNER_ABI (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADDRESS_VAL_CREATE_RETURNER_ABI)1 ADDRESS_VAL_RETURNER_PATH (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADDRESS_VAL_RETURNER_PATH)1 BUILD_THEN_REVERT_THEN_BUILD_ABI (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BUILD_THEN_REVERT_THEN_BUILD_ABI)1