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);
}
};
}
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);
}
};
}
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);
}
};
}
Aggregations