Search in sources :

Example 1 with FAIL_INVALID

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

the class TokenTransferBasicLoadTest method activeTokenAssociatesFactory.

private Function<HapiApiSpec, OpProvider> activeTokenAssociatesFactory(PerfTestLoadSettings settings) {
    int numTotalTokens = settings.getTotalTokens();
    int numActiveTokenAccounts = settings.getTotalTestTokenAccounts();
    int totalClients = settings.getTotalClients();
    int numActiveTokens = (totalClients >= 1) ? numTotalTokens / totalClients : numTotalTokens;
    AtomicLong remainingAssociations = new AtomicLong(numActiveTokens * numActiveTokenAccounts - 1);
    if (log.isDebugEnabled()) {
        log.debug("Total active token accounts {}, total test tokens {}, my portion of tokens {}", numActiveTokenAccounts, numTotalTokens, numActiveTokens);
    }
    long startAccountId = settings.getTestTreasureStartAccount();
    return spec -> new OpProvider() {

        @Override
        public List<HapiSpecOperation> suggestedInitializers() {
            return Collections.emptyList();
        }

        @Override
        public Optional<HapiSpecOperation> get() {
            long nextAssocId;
            if ((nextAssocId = remainingAssociations.getAndDecrement()) < 0) {
                return Optional.empty();
            }
            int curToken = (int) nextAssocId / numActiveTokenAccounts;
            long curAccount = nextAssocId % numActiveTokenAccounts;
            var accountId = "0.0." + (startAccountId + curAccount);
            var op = tokenAssociate(accountId, tokenRegistryName(curToken)).payingWith(DEFAULT_PAYER).signedBy(DEFAULT_PAYER).hasRetryPrecheckFrom(BUSY, PLATFORM_TRANSACTION_NOT_CREATED, DUPLICATE_TRANSACTION, INSUFFICIENT_PAYER_BALANCE).hasPrecheckFrom(DUPLICATE_TRANSACTION, OK).hasKnownStatusFrom(SUCCESS, TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT, INVALID_TOKEN_ID, TRANSACTION_EXPIRED, TOKENS_PER_ACCOUNT_LIMIT_EXCEEDED, FAIL_INVALID, OK).fee(ONE_HUNDRED_HBARS).noLogging().suppressStats(true).deferStatusResolution();
            return Optional.of(op);
        }
    };
}
Also used : TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) UtilVerbs.runWithProvider(com.hedera.services.bdd.spec.utilops.UtilVerbs.runWithProvider) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) Random(java.util.Random) TRANSACTION_EXPIRED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_EXPIRED) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) Function(java.util.function.Function) Supplier(java.util.function.Supplier) EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS) UtilVerbs.sleepFor(com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) DUPLICATE_TRANSACTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) INSUFFICIENT_TOKEN_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TOKEN_BALANCE) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) OpProvider(com.hedera.services.bdd.spec.infrastructure.OpProvider) 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) UNKNOWN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNKNOWN) TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT) FAIL_INVALID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.FAIL_INVALID) INVALID_TOKEN_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_ID) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) 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) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) AtomicLong(java.util.concurrent.atomic.AtomicLong) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) OpProvider(com.hedera.services.bdd.spec.infrastructure.OpProvider)

Example 2 with FAIL_INVALID

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

the class TokenTransferBasicLoadTest method tokenCreatesFactory.

private Function<HapiApiSpec, OpProvider> tokenCreatesFactory(PerfTestLoadSettings settings) {
    int numTotalTokens = settings.getTotalTokens();
    int totalClients = settings.getTotalClients();
    int numActiveTokens = (totalClients >= 1) ? numTotalTokens / totalClients : numTotalTokens;
    AtomicInteger remaining = new AtomicInteger(numActiveTokens - 1);
    return spec -> new OpProvider() {

        @Override
        public List<HapiSpecOperation> suggestedInitializers() {
            return Collections.emptyList();
        }

        @Override
        public Optional<HapiSpecOperation> get() {
            int next;
            if ((next = remaining.getAndDecrement()) < 0) {
                return Optional.empty();
            }
            var payingTreasury = String.format("0.0.%d", settings.getTestTreasureStartAccount() + next);
            var op = tokenCreate(tokenRegistryName(next)).payingWith(DEFAULT_PAYER).signedBy(DEFAULT_PAYER).fee(ONE_HUNDRED_HBARS).initialSupply(100_000_000_000L).treasury(payingTreasury).hasRetryPrecheckFrom(BUSY, PLATFORM_TRANSACTION_NOT_CREATED, DUPLICATE_TRANSACTION, INSUFFICIENT_PAYER_BALANCE).hasPrecheckFrom(DUPLICATE_TRANSACTION, OK).hasKnownStatusFrom(SUCCESS, TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT, TOKENS_PER_ACCOUNT_LIMIT_EXCEEDED, FAIL_INVALID).suppressStats(true).noLogging();
            return Optional.of(op);
        }
    };
}
Also used : TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) UtilVerbs.runWithProvider(com.hedera.services.bdd.spec.utilops.UtilVerbs.runWithProvider) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) Random(java.util.Random) TRANSACTION_EXPIRED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_EXPIRED) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) Function(java.util.function.Function) Supplier(java.util.function.Supplier) EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS) UtilVerbs.sleepFor(com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) DUPLICATE_TRANSACTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) INSUFFICIENT_TOKEN_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TOKEN_BALANCE) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) OpProvider(com.hedera.services.bdd.spec.infrastructure.OpProvider) 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) UNKNOWN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNKNOWN) TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT) FAIL_INVALID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.FAIL_INVALID) INVALID_TOKEN_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_ID) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) 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) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) OpProvider(com.hedera.services.bdd.spec.infrastructure.OpProvider)

Aggregations

HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)2 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)2 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)2 OpProvider (com.hedera.services.bdd.spec.infrastructure.OpProvider)2 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)2 TxnVerbs.tokenAssociate (com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate)2 TxnVerbs.tokenCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate)2 TokenMovement.moving (com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving)2 LoadTest (com.hedera.services.bdd.spec.utilops.LoadTest)2 UtilVerbs.runWithProvider (com.hedera.services.bdd.spec.utilops.UtilVerbs.runWithProvider)2 UtilVerbs.sleepFor (com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor)2 UtilVerbs.sourcing (com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing)2 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)2 PerfTestLoadSettings (com.hedera.services.bdd.suites.perf.PerfTestLoadSettings)2 BUSY (com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY)2 DUPLICATE_TRANSACTION (com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION)2 EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS)2 FAIL_INVALID (com.hederahashgraph.api.proto.java.ResponseCodeEnum.FAIL_INVALID)2 INSUFFICIENT_PAYER_BALANCE (com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE)2 INSUFFICIENT_TOKEN_BALANCE (com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TOKEN_BALANCE)2