Search in sources :

Example 11 with OpProvider

use of com.hedera.services.bdd.spec.infrastructure.OpProvider 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 12 with OpProvider

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

the class AccountBalancesClientSaveLoadTest method tokensCreate.

private Function<HapiApiSpec, OpProvider> tokensCreate(PerfTestLoadSettings settings) {
    AtomicInteger createdSofar = new AtomicInteger(0);
    return spec -> new OpProvider() {

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

        @Override
        public Optional<HapiSpecOperation> get() {
            int next;
            next = createdSofar.getAndIncrement();
            if (next >= totalTestTokens) {
                return Optional.empty();
            }
            var payingTreasury = String.format(ACCT_NAME_PREFIX + next);
            var op = tokenCreate(TOKEN_NAME_PREFIX + next).signedBy(GENESIS).fee(ONE_HUNDRED_HBARS).initialSupply(MIN_TOKEN_SUPPLY + r.nextInt(MAX_TOKEN_SUPPLY)).treasury(payingTreasury).hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS).hasPrecheckFrom(DUPLICATE_TRANSACTION, OK).hasKnownStatusFrom(SUCCESS, TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT, TOKENS_PER_ACCOUNT_LIMIT_EXCEEDED).suppressStats(true).noLogging();
            if (next > 0) {
                op.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 13 with OpProvider

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

the class SplittingThrottlesWorks method cryptoCreateOps.

private Function<HapiApiSpec, OpProvider> cryptoCreateOps() {
    var i = new AtomicInteger(0);
    return spec -> new OpProvider() {

        @Override
        public List<HapiSpecOperation> suggestedInitializers() {
            return List.of(cryptoCreate("civilian").payingWith(GENESIS).balance(ONE_MILLION_HBARS).withRecharging());
        }

        @Override
        public Optional<HapiSpecOperation> get() {
            HapiSpecOperation op;
            final var nextI = i.getAndIncrement();
            if (nextI % (scheduleCreatesPerCryptoCreate + 1) == 0) {
                op = cryptoCreate("w/e" + nextI).noLogging().deferStatusResolution().payingWith("civilian").hasPrecheckFrom(OK, BUSY);
            } else {
                op = scheduleCreate("scheduleW/e" + nextI, cryptoTransfer(tinyBarsFromTo("civilian", FUNDING, 1)).memo(TxnUtils.randomAlphaNumeric(32)).hasPrecheckFrom(STANDARD_PERMISSIBLE_PRECHECKS)).noLogging().deferStatusResolution().payingWith("civilian").hasPrecheckFrom(OK, BUSY);
            }
            return Optional.of(op);
        }
    };
}
Also used : 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.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) OpProvider(com.hedera.services.bdd.spec.infrastructure.OpProvider) TxnVerbs.scheduleCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleCreate) ThrottleDefsLoader.protoDefsFromResource(com.hedera.services.bdd.suites.utils.sysfiles.serdes.ThrottleDefsLoader.protoDefsFromResource) 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) SECONDS(java.util.concurrent.TimeUnit.SECONDS) 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)13 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)13 OpProvider (com.hedera.services.bdd.spec.infrastructure.OpProvider)13 Optional (java.util.Optional)13 TimeUnit (java.util.concurrent.TimeUnit)13 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 Function (java.util.function.Function)13 LogManager (org.apache.logging.log4j.LogManager)13 Logger (org.apache.logging.log4j.Logger)13 UtilVerbs.runWithProvider (com.hedera.services.bdd.spec.utilops.UtilVerbs.runWithProvider)12 List (java.util.List)12 AtomicLong (java.util.concurrent.atomic.AtomicLong)11 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)9 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)9 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)9 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)8 TxnVerbs.tokenCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate)8 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)8 ArrayList (java.util.ArrayList)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8