use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY 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);
}
};
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY in project hedera-services by hashgraph.
the class FileContractMemoPerfSuite method RunMixedFileContractMemoOps.
// perform cryptoCreate, cryptoUpdate, TokenCreate, TokenUpdate, FileCreate, FileUpdate txs with entity memo set.
protected HapiApiSpec RunMixedFileContractMemoOps() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
final AtomicInteger createdSoFar = new AtomicInteger(0);
Supplier<HapiSpecOperation[]> mixedOpsBurst = () -> new HapiSpecOperation[] { fileCreate("testFile" + createdSoFar.getAndIncrement()).payingWith(GENESIS).entityMemo(new String(TxnUtils.randomUtf8Bytes(memoLength.getAsInt()), StandardCharsets.UTF_8)).noLogging().hasPrecheckFrom(OK, BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution(), getFileInfo(TARGET_FILE + "Info").hasMemo(FILE_MEMO), fileUpdate(TARGET_FILE).payingWith(GENESIS).entityMemo(new String(TxnUtils.randomUtf8Bytes(memoLength.getAsInt()), StandardCharsets.UTF_8)).noLogging().hasPrecheckFrom(OK, BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution(), contractCreate("testContract" + createdSoFar.getAndIncrement()).payingWith(GENESIS).bytecode(TARGET_FILE).entityMemo(new String(TxnUtils.randomUtf8Bytes(memoLength.getAsInt()), StandardCharsets.UTF_8)).noLogging().hasPrecheckFrom(OK, BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution(), getContractInfo(CONTRACT + "Info").hasExpectedInfo(), contractUpdate(CONTRACT).payingWith(GENESIS).newMemo(new String(TxnUtils.randomUtf8Bytes(memoLength.getAsInt()), StandardCharsets.UTF_8)).noLogging().hasPrecheckFrom(OK, BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution() };
return defaultHapiSpec("RunMixedFileContractMemoOps").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when(fileCreate(TARGET_FILE).payingWith(GENESIS).path(ContractResources.VALID_BYTECODE_PATH).entityMemo(FILE_MEMO).logged(), fileCreate(TARGET_FILE + "Info").payingWith(GENESIS).entityMemo(FILE_MEMO).logged(), contractCreate(CONTRACT).payingWith(GENESIS).bytecode(TARGET_FILE).entityMemo(CONTRACT_MEMO).logged(), contractCreate(CONTRACT + "Info").payingWith(GENESIS).bytecode(TARGET_FILE).entityMemo(CONTRACT_MEMO).logged()).then(defaultLoadTest(mixedOpsBurst, settings));
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY in project hedera-services by hashgraph.
the class CryptoTransferLoadTest method runCryptoTransfers.
protected HapiApiSpec runCryptoTransfers() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
Supplier<HapiSpecOperation[]> transferBurst = () -> {
String sender = "sender";
String receiver = "receiver";
if (settings.getTotalAccounts() > 2) {
int s = r.nextInt(settings.getTotalAccounts());
int re = 0;
do {
re = r.nextInt(settings.getTotalAccounts());
} while (re == s);
sender = String.format("0.0.%d", TEST_ACCOUNT_STARTS_FROM + s);
receiver = String.format("0.0.%d", TEST_ACCOUNT_STARTS_FROM + re);
}
return new HapiSpecOperation[] { cryptoTransfer(tinyBarsFromTo(sender, receiver, 1L)).noLogging().payingWith(sender).signedBy(GENESIS).suppressStats(true).fee(100_000_000L).hasKnownStatusFrom(SUCCESS, OK, INSUFFICIENT_PAYER_BALANCE, UNKNOWN, TRANSACTION_EXPIRED, INSUFFICIENT_ACCOUNT_BALANCE).hasRetryPrecheckFrom(BUSY, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution() };
};
return defaultHapiSpec("RunCryptoTransfers").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when(cryptoCreate("sender").balance(ignore -> settings.getInitialBalance()).payingWith(GENESIS).withRecharging().key(GENESIS).rechargeWindow(3).logging().hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED), cryptoCreate("receiver").payingWith(GENESIS).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).key(GENESIS).logging()).then(defaultLoadTest(transferBurst, settings), getAccountBalance("sender").logged());
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY 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);
}
};
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY in project hedera-services by hashgraph.
the class HCSChunkingRealisticPerfSuite method fragmentLongMessageIntoChunks.
private static HapiApiSpec fragmentLongMessageIntoChunks() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
Supplier<HapiSpecOperation[]> submitBurst = () -> new HapiSpecOperation[] { chunkAFile(LARGE_FILE, CHUNK_SIZE, PAYER, TOPIC, totalMsgSubmitted) };
return defaultHapiSpec("fragmentLongMessageIntoChunks").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), newKeyNamed("submitKey"), logIt(ignore -> settings.toString())).when(cryptoCreate(PAYER).balance(initialBalance.getAsLong()).withRecharging().rechargeWindow(30).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED), withOpContext((spec, ignore) -> {
int factor = settings.getIntProperty("collisionAvoidanceFactor", DEFAULT_COLLISION_AVOIDANCE_FACTOR);
List<HapiSpecOperation> opsList = new ArrayList<HapiSpecOperation>();
for (int i = 0; i < settings.getThreads() * factor; i++) {
var op = createTopic(TOPIC + i).submitKeyName("submitKey").hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED);
opsList.add(op);
}
CustomSpecAssert.allRunFor(spec, inParallel(flattened(opsList)));
}), // wait all other thread ready
sleepFor(5000)).then(defaultLoadTest(submitBurst, settings));
}
Aggregations