Search in sources :

Example 1 with INVALID_SIGNATURE

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

the class ContractKeysHTSSuite method burnTokenWithFullPrefixAndPartialPrefixKeys.

private HapiApiSpec burnTokenWithFullPrefixAndPartialPrefixKeys() {
    final var theAccount = "anybody";
    final var burnContractByteCode = "burnContractByteCode";
    final var amount = 99L;
    final var fungibleToken = "fungibleToken";
    final var theContract = "mintContract";
    final var firstBurnTxn = "firstBurnTxn";
    final var secondBurnTxn = "secondBurnTxn";
    final AtomicLong fungibleNum = new AtomicLong();
    return defaultHapiSpec("burnTokenWithFullPrefixAndPartialPrefixKeys").given(newKeyNamed(MULTI_KEY), cryptoCreate(theAccount).balance(10 * ONE_HUNDRED_HBARS), cryptoCreate(TOKEN_TREASURY), fileCreate(burnContractByteCode).payingWith(theAccount), updateLargeFile(theAccount, burnContractByteCode, extractByteCode(ContractResources.ORDINARY_CALLS_CONTRACT)), tokenCreate(fungibleToken).tokenType(TokenType.FUNGIBLE_COMMON).initialSupply(100).treasury(TOKEN_TREASURY).adminKey(MULTI_KEY).supplyKey(MULTI_KEY).exposingCreatedIdTo(idLit -> fungibleNum.set(asDotDelimitedLongArray(idLit)[2]))).when(sourcing(() -> contractCreate(theContract).bytecode(burnContractByteCode).payingWith(theAccount).gas(GAS_TO_OFFER))).then(withOpContext((spec, opLog) -> allRunFor(spec, contractCall(theContract, BURN_TOKEN_ORDINARY_CALL, asAddress(spec.registry().getTokenID(fungibleToken)), 1, new ArrayList<Long>()).via(firstBurnTxn).payingWith(theAccount).signedBy(MULTI_KEY).signedBy(theAccount).hasKnownStatus(SUCCESS), contractCall(theContract, BURN_TOKEN_ORDINARY_CALL, asAddress(spec.registry().getTokenID(fungibleToken)), 1, new ArrayList<Long>()).via(secondBurnTxn).payingWith(theAccount).alsoSigningWithFullPrefix(MULTI_KEY).hasKnownStatus(SUCCESS))), childRecordsCheck(firstBurnTxn, SUCCESS, recordWith().status(INVALID_SIGNATURE)), childRecordsCheck(secondBurnTxn, SUCCESS, recordWith().status(SUCCESS).newTotalSupply(99)), getTokenInfo(fungibleToken).hasTotalSupply(amount), getAccountBalance(TOKEN_TREASURY).hasTokenBalance(fungibleToken, amount));
}
Also used : SINGLE_TOKEN_DISSOCIATE(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SINGLE_TOKEN_DISSOCIATE) 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) ON(com.hedera.services.bdd.spec.keys.SigControl.ON) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) BURN_TOKEN_ORDINARY_CALL(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BURN_TOKEN_ORDINARY_CALL) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) ACCOUNT_IS_TREASURY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_IS_TREASURY) DELEGATE_BURN_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_BURN_CALL_ABI) ExpectedTokenRel.relationshipWith(com.hedera.services.bdd.spec.queries.crypto.ExpectedTokenRel.relationshipWith) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) STATIC_ASSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_ASSOCIATE_CALL_ABI) Frozen(com.hederahashgraph.api.proto.java.TokenFreezeStatus.Frozen) SomeFungibleTransfers.changingFungibleBalances(com.hedera.services.bdd.spec.assertions.SomeFungibleTransfers.changingFungibleBalances) DELEGATE_ASSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_ASSOCIATE_CALL_ABI) ACCOUNT_STILL_OWNS_NFTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_STILL_OWNS_NFTS) STATIC_DISSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_DISSOCIATE_CALL_ABI) STATIC_MINT_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_MINT_CALL_ABI) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) 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) TRANSFER_NFT_ORDINARY_CALL(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.TRANSFER_NFT_ORDINARY_CALL) Utils.extractByteCode(com.hedera.services.bdd.suites.contract.Utils.extractByteCode) NonFungibleTransfers(com.hedera.services.bdd.spec.assertions.NonFungibleTransfers) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TxnVerbs.tokenUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUpdate) NotNull(org.jetbrains.annotations.NotNull) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) STATIC_TRANSFER_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_TRANSFER_CALL_ABI) KeyShape.sigs(com.hedera.services.bdd.spec.keys.KeyShape.sigs) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) MiscEETUtils.metadata(com.hedera.services.bdd.suites.utils.MiscEETUtils.metadata) ByteString.copyFromUtf8(com.google.protobuf.ByteString.copyFromUtf8) DELEGATE_MINT_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_MINT_CALL_ABI) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) QueryVerbs.getTokenInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo) Revoked(com.hederahashgraph.api.proto.java.TokenKycStatus.Revoked) HapiPropertySource.asToken(com.hedera.services.bdd.spec.HapiPropertySource.asToken) SINGLE_TOKEN_ASSOCIATE(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SINGLE_TOKEN_ASSOCIATE) 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) ArrayList(java.util.ArrayList) UtilVerbs.emptyChildRecordsCheck(com.hedera.services.bdd.spec.utilops.UtilVerbs.emptyChildRecordsCheck) TxnVerbs.cryptoUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoUpdate) 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) HapiPropertySource.asDotDelimitedLongArray(com.hedera.services.bdd.spec.HapiPropertySource.asDotDelimitedLongArray) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) AccountID(com.hederahashgraph.api.proto.java.AccountID) MINT_TOKEN_ORDINARY_CALL(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MINT_TOKEN_ORDINARY_CALL) 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) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) DELEGATE_DISSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_DISSOCIATE_CALL_ABI) UtilVerbs.updateLargeFile(com.hedera.services.bdd.spec.utilops.UtilVerbs.updateLargeFile) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) VANILLA_TOKEN(com.hedera.services.bdd.suites.token.TokenAssociationSpecs.VANILLA_TOKEN) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) BURN_TOKEN_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BURN_TOKEN_ABI) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) TokenType(com.hederahashgraph.api.proto.java.TokenType) AtomicLong(java.util.concurrent.atomic.AtomicLong) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) TokenID(com.hederahashgraph.api.proto.java.TokenID) STATIC_BURN_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_BURN_CALL_ABI) Utils.asAddress(com.hedera.services.bdd.suites.contract.Utils.asAddress) CONTRACT_REVERT_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_REVERT_EXECUTED) 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) LogManager(org.apache.logging.log4j.LogManager) DELEGATE_TRANSFER_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_TRANSFER_CALL_ABI) TokenMovement.movingUnique(com.hedera.services.bdd.spec.transactions.token.TokenMovement.movingUnique) TokenSupplyType(com.hederahashgraph.api.proto.java.TokenSupplyType) TxnVerbs.tokenUnfreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUnfreeze) AtomicLong(java.util.concurrent.atomic.AtomicLong) AtomicLong(java.util.concurrent.atomic.AtomicLong) ArrayList(java.util.ArrayList)

Example 2 with INVALID_SIGNATURE

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

the class ContractCreateSuite method receiverSigReqTransferRecipientMustSignWithFullPubKeyPrefix.

private HapiApiSpec receiverSigReqTransferRecipientMustSignWithFullPubKeyPrefix() {
    final var justSendInitcode = "justSendInitcode";
    final var sendInternalAndDelegateInitcode = "sendInternalAndDelegateInitcode";
    final var justSend = "justSend";
    final var sendInternalAndDelegate = "sendInternalAndDelegate";
    final var beneficiary = "civilian";
    final var balanceToDistribute = 1_000L;
    final AtomicLong justSendContractNum = new AtomicLong();
    final AtomicLong beneficiaryAccountNum = new AtomicLong();
    return defaultHapiSpec("ReceiverSigReqTransferRecipientMustSignWithFullPubKeyPrefix").given(cryptoCreate(beneficiary).balance(0L).receiverSigRequired(true).exposingCreatedIdTo(id -> beneficiaryAccountNum.set(id.getAccountNum())), fileCreate(justSendInitcode).path(ContractResources.JUST_SEND_BYTECODE_PATH), fileCreate(sendInternalAndDelegateInitcode).path(ContractResources.SEND_INTERNAL_AND_DELEGATE_BYTECODE_PATH)).when(contractCreate(justSend).bytecode(justSendInitcode).gas(300_000L).exposingNumTo(justSendContractNum::set), contractCreate(sendInternalAndDelegate).bytecode(sendInternalAndDelegateInitcode).gas(300_000L).balance(balanceToDistribute)).then(/* Sending requires receiver signature */
    sourcing(() -> contractCall(sendInternalAndDelegate, SEND_REPEATEDLY_ABI, justSendContractNum.get(), beneficiaryAccountNum.get(), balanceToDistribute / 2).hasKnownStatus(INVALID_SIGNATURE)), /* But it's not enough to just sign using an incomplete prefix */
    sourcing(() -> contractCall(sendInternalAndDelegate, SEND_REPEATEDLY_ABI, justSendContractNum.get(), beneficiaryAccountNum.get(), balanceToDistribute / 2).signedBy(DEFAULT_PAYER, beneficiary).hasKnownStatus(INVALID_SIGNATURE)), /* We have to specify the full prefix so the sig can be verified async */
    getAccountInfo(beneficiary).logged(), sourcing(() -> contractCall(sendInternalAndDelegate, SEND_REPEATEDLY_ABI, justSendContractNum.get(), beneficiaryAccountNum.get(), balanceToDistribute / 2).alsoSigningWithFullPrefix(beneficiary)), getAccountBalance(beneficiary).logged());
}
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 3 with INVALID_SIGNATURE

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

the class AccountBalancesClientSaveLoadTest method accountsCreate.

private Function<HapiApiSpec, OpProvider> accountsCreate(PerfTestLoadSettings settings) {
    totalTestTokens = settings.getTotalTokens() > 10 ? settings.getTotalTokens() : TOTAL_TEST_TOKENS;
    totalTreasureAccounts = totalTestTokens;
    totalAccounts = settings.getTotalAccounts() > 100 ? settings.getTotalAccounts() : TOTAL_ACCOUNT;
    log.info("Total accounts: {}", totalAccounts);
    log.info("Total tokens: {}", totalTestTokens);
    AtomicInteger moreToCreate = new AtomicInteger(totalAccounts);
    return spec -> new OpProvider() {

        @Override
        public List<HapiSpecOperation> suggestedInitializers() {
            log.info("Now running accountsCreate initializer");
            return Collections.emptyList();
        }

        @Override
        public Optional<HapiSpecOperation> get() {
            int next;
            next = moreToCreate.getAndDecrement();
            if (next <= 0) {
                return Optional.empty();
            }
            var op = cryptoCreate(String.format("%s%d", ACCT_NAME_PREFIX, next)).balance((long) (r.nextInt((int) ONE_HBAR) + MIN_ACCOUNT_BALANCE)).key(GENESIS).fee(ONE_HUNDRED_HBARS).withRecharging().rechargeWindow(30).hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS).hasPrecheckFrom(DUPLICATE_TRANSACTION, OK, INSUFFICIENT_TX_FEE).hasKnownStatusFrom(SUCCESS, INVALID_SIGNATURE).noLogging().deferStatusResolution();
            return Optional.of(op);
        }
    };
}
Also used : ACCOUNT_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_DELETED) UtilVerbs.runWithProvider(com.hedera.services.bdd.spec.utilops.UtilVerbs.runWithProvider) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) Random(java.util.Random) TRANSACTION_EXPIRED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_EXPIRED) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) UtilVerbs.sleepFor(com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) Pair(org.apache.commons.lang3.tuple.Pair) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) ACCOUNT_ID_DOES_NOT_EXIST(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_ID_DOES_NOT_EXIST) OpProvider(com.hedera.services.bdd.spec.infrastructure.OpProvider) RegistryNotFound(com.hedera.services.bdd.spec.infrastructure.RegistryNotFound) TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT) Set(java.util.Set) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) List(java.util.List) Logger(org.apache.logging.log4j.Logger) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) Optional(java.util.Optional) BUSY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) Function(java.util.function.Function) PerfUtilOps.tokenOpsEnablement(com.hedera.services.bdd.suites.perf.PerfUtilOps.tokenOpsEnablement) INVALID_SIGNATURE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE) ArrayList(java.util.ArrayList) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) DUPLICATE_TRANSACTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION) INSUFFICIENT_TOKEN_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TOKEN_BALANCE) AccountID(com.hederahashgraph.api.proto.java.AccountID) NOISY_RETRY_PRECHECKS(com.hedera.services.bdd.spec.transactions.TxnUtils.NOISY_RETRY_PRECHECKS) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) TOKENS_PER_ACCOUNT_LIMIT_EXCEEDED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKENS_PER_ACCOUNT_LIMIT_EXCEEDED) LoadTest(com.hedera.services.bdd.spec.utilops.LoadTest) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) ThrottleDefsLoader.protoDefsFromResource(com.hedera.services.bdd.suites.utils.sysfiles.serdes.ThrottleDefsLoader.protoDefsFromResource) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) TimeUnit(java.util.concurrent.TimeUnit) ACCOUNT_REPEATED_IN_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_REPEATED_IN_ACCOUNT_AMOUNTS) UtilVerbs.freezeOnly(com.hedera.services.bdd.spec.utilops.UtilVerbs.freezeOnly) UtilVerbs.exportAccountBalances(com.hedera.services.bdd.spec.utilops.UtilVerbs.exportAccountBalances) INSUFFICIENT_TX_FEE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) OpProvider(com.hedera.services.bdd.spec.infrastructure.OpProvider)

Example 4 with INVALID_SIGNATURE

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

the class R5BugChecks method enforcesSigRequirements.

private HapiApiSpec enforcesSigRequirements() {
    KeyShape complexSrShape = listOf(SIMPLE, threshOf(1, 3));
    SigControl activeSig = complexSrShape.signedWith(sigs(ON, sigs(OFF, OFF, ON)));
    SigControl inactiveSig = complexSrShape.signedWith(sigs(OFF, sigs(ON, ON, ON)));
    return defaultHapiSpec("EnforcesSigRequirements").given(newKeyNamed("srKey").shape(complexSrShape), fileCreate("bytecode").path(ContractResources.LAST_TRACKING_SENDER_BYTECODE_PATH), contractCreate("sponsor").bytecode("bytecode").balance(10), cryptoCreate("noSr").balance(0L), cryptoCreate("sr").key("srKey").balance(0L).receiverSigRequired(true)).when(contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).hasKnownStatus(INVALID_SIGNATURE), contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).signedBy(GENESIS, "sr").sigControl(ControlForKey.forKey("sr", inactiveSig)).hasKnownStatus(INVALID_SIGNATURE), contractCallLocal("sponsor", ContractResources.HOW_MUCH_ABI).has(resultWith().resultThruAbi(ContractResources.HOW_MUCH_ABI, isLiteralResult(new Object[] { BigInteger.valueOf(0) }))), getAccountBalance("sr").hasTinyBars(0L)).then(contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("noSr").getAccountNum(), 1 }), contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).signedBy(GENESIS, "sr").sigControl(ControlForKey.forKey("sr", activeSig)), contractCallLocal("sponsor", ContractResources.HOW_MUCH_ABI).has(resultWith().resultThruAbi(ContractResources.HOW_MUCH_ABI, isLiteralResult(new Object[] { BigInteger.valueOf(5) }))), getAccountBalance("sr").hasTinyBars(5L), getAccountBalance("noSr").hasTinyBars(1L));
}
Also used : OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) SigControl(com.hedera.services.bdd.spec.keys.SigControl) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) ON(com.hedera.services.bdd.spec.keys.SigControl.ON) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) AccountInfoAsserts.changeFromSnapshot(com.hedera.services.bdd.spec.assertions.AccountInfoAsserts.changeFromSnapshot) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) QueryVerbs.contractCallLocal(com.hedera.services.bdd.spec.queries.QueryVerbs.contractCallLocal) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) BigInteger(java.math.BigInteger) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) ControlForKey(com.hedera.services.bdd.spec.keys.ControlForKey) ContractFnResultAsserts.resultWith(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) KeyShape.threshOf(com.hedera.services.bdd.spec.keys.KeyShape.threshOf) ByteString(com.google.protobuf.ByteString) INVALID_ACCOUNT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ACCOUNT_ID) List(java.util.List) Logger(org.apache.logging.log4j.Logger) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) KeyShape.sigs(com.hedera.services.bdd.spec.keys.KeyShape.sigs) TxnVerbs.fileDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileDelete) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) UtilVerbs.balanceSnapshot(com.hedera.services.bdd.spec.utilops.UtilVerbs.balanceSnapshot) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) 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) KeyShape.listOf(com.hedera.services.bdd.spec.keys.KeyShape.listOf) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) TxnVerbs.cryptoDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoDelete) TxnVerbs.fileAppend(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileAppend) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) TransferList(com.hederahashgraph.api.proto.java.TransferList) QueryVerbs.getFileContents(com.hedera.services.bdd.spec.queries.QueryVerbs.getFileContents) FEE_SCHEDULE_FILE_PART_UPLOADED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.FEE_SCHEDULE_FILE_PART_UPLOADED) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) QueryVerbs.getFileInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getFileInfo) ContractFnResultAsserts.isLiteralResult(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isLiteralResult) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) Collectors.toList(java.util.stream.Collectors.toList) UtilVerbs.freezeOnly(com.hedera.services.bdd.spec.utilops.UtilVerbs.freezeOnly) OFF(com.hedera.services.bdd.spec.keys.SigControl.OFF) BAD_ENCODING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BAD_ENCODING) INVALID_SOLIDITY_ADDRESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SOLIDITY_ADDRESS) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) LogManager(org.apache.logging.log4j.LogManager) SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Aggregations

HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)4 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)4 QueryVerbs.getAccountBalance (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance)4 QueryVerbs.getAccountInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo)4 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)4 CustomSpecAssert.allRunFor (com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor)4 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)4 INVALID_SIGNATURE (com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE)4 List (java.util.List)4 LogManager (org.apache.logging.log4j.LogManager)4 Logger (org.apache.logging.log4j.Logger)4 HapiPropertySource (com.hedera.services.bdd.spec.HapiPropertySource)3 ContractResources (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources)3 KeyShape (com.hedera.services.bdd.spec.keys.KeyShape)3 SIMPLE (com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE)3 KeyShape.sigs (com.hedera.services.bdd.spec.keys.KeyShape.sigs)3 ON (com.hedera.services.bdd.spec.keys.SigControl.ON)3 TxnVerbs.contractCall (com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall)3 TxnVerbs.contractCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate)3 ByteString (com.google.protobuf.ByteString)2