use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class SubmitMessageLoadTest method runSubmitMessages.
private static HapiApiSpec runSubmitMessages() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
final AtomicInteger submittedSoFar = new AtomicInteger(0);
Supplier<HapiSpecOperation[]> submitBurst = () -> new HapiSpecOperation[] { opSupplier(settings).get() };
return defaultHapiSpec("RunSubmitMessages").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), // if no pem file defined then create a new submitKey
pemFile == null ? newKeyNamed("submitKey") : keyFromPem(pemFile).name("submitKey").simpleWacl().passphrase(KeyFactory.PEM_PASSPHRASE), // if just created a new key then export spec for later reuse
pemFile == null ? withOpContext((spec, ignore) -> spec.keys().exportSimpleKey("topicSubmitKey.pem", "submitKey")) : sleepFor(100), logIt(ignore -> settings.toString())).when(fileUpdate(APP_PROPERTIES).payingWith(GENESIS).overridingProps(Map.of("hapi.throttling.buckets.fastOpBucket.capacity", "4000", "hapi.throttling.ops.consensusSubmitMessage.capacityRequired", "1.0")), cryptoCreate("sender").balance(ignore -> settings.getInitialBalance()).withRecharging().rechargeWindow(3).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED), topicID == null ? createTopic("topic").submitKeyName("submitKey").hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED) : sleepFor(100), // wait all other thread ready
sleepFor(10000)).then(defaultLoadTest(submitBurst, settings), getAccountBalance("sender").logged());
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class CreateAccountsBeforeReconnect method runCreateAccounts.
private HapiApiSpec runCreateAccounts() {
PerfTestLoadSettings settings = new PerfTestLoadSettings(ACCOUNT_CREATION_RECONNECT_TPS, DEFAULT_MINS_FOR_RECONNECT_TESTS, DEFAULT_THREADS_FOR_RECONNECT_TESTS);
Supplier<HapiSpecOperation[]> createBurst = () -> new HapiSpecOperation[] { generateCreateAccountOperation() };
return defaultHapiSpec("RunCreateAccounts").given(logIt(ignore -> settings.toString())).when().then(defaultLoadTest(createBurst, settings));
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class ValidateCongestionPricingAfterReconnect method validateCongestionPricing.
private HapiApiSpec validateCongestionPricing() {
var artificialLimits = protoDefsFromResource("testSystemFiles/artificial-limits-6N.json");
var defaultThrottles = protoDefsFromResource("testSystemFiles/throttles-dev.json");
String tmpMinCongestionPeriodInSecs = "5";
String civilianAccount = "civilian";
String oneContract = "contract";
AtomicLong normalPrice = new AtomicLong();
AtomicLong tenXPrice = new AtomicLong();
return customHapiSpec("ValidateCongestionPricing").withProperties(Map.of("txn.start.offset.secs", "-5")).given(sleepFor(Duration.ofSeconds(25).toMillis()), cryptoCreate(civilianAccount).payingWith(GENESIS).balance(ONE_MILLION_HBARS), fileCreate("bytecode").path(ContractResources.MULTIPURPOSE_BYTECODE_PATH).payingWith(GENESIS), contractCreate(oneContract).bytecode("bytecode").payingWith(GENESIS).logging(), contractCall(oneContract).payingWith(civilianAccount).fee(ONE_HUNDRED_HBARS).sending(ONE_HBAR).via("cheapCallBeforeCongestionPricing"), getTxnRecord("cheapCallBeforeCongestionPricing").providingFeeTo(normalPrice::set), getAccountBalance(GENESIS).setNode(reconnectingNode).unavailableNode()).when(/* update the multiplier to 10x with a 1% congestion for tmpMinCongestionPeriodInSecs */
fileUpdate(APP_PROPERTIES).fee(ONE_HUNDRED_HBARS).payingWith(EXCHANGE_RATE_CONTROL).overridingProps(Map.of("fees.percentCongestionMultipliers", "1,10x", "fees.minCongestionPeriod", tmpMinCongestionPeriodInSecs)), fileUpdate(THROTTLE_DEFS).fee(ONE_HUNDRED_HBARS).payingWith(EXCHANGE_RATE_CONTROL).contents(artificialLimits.toByteArray()), blockingOrder(IntStream.range(0, 20).mapToObj(i -> contractCall(oneContract).payingWith(GENESIS).fee(ONE_HUNDRED_HBARS).sending(ONE_HBAR)).toArray(HapiSpecOperation[]::new))).then(withLiveNode(reconnectingNode).within(5 * 60, TimeUnit.SECONDS).loggingAvailabilityEvery(30).sleepingBetweenRetriesFor(10), blockingOrder(IntStream.range(0, 10).mapToObj(i -> contractCall(oneContract).payingWith(GENESIS).fee(ONE_HUNDRED_HBARS).sending(ONE_HBAR).setNode(reconnectingNode)).toArray(HapiSpecOperation[]::new)), contractCall(oneContract).payingWith(civilianAccount).fee(ONE_HUNDRED_HBARS).sending(ONE_HBAR).via("pricyCallAfterReconnect").setNode(reconnectingNode), getTxnRecord("pricyCallAfterReconnect").payingWith(GENESIS).providingFeeTo(tenXPrice::set).setNode(reconnectingNode), /* check if the multiplier took effect in the contract call operation */
withOpContext((spec, opLog) -> {
Assertions.assertEquals(10.0, (1.0 * tenXPrice.get()) / normalPrice.get(), 0.1, "~10x multiplier should be in affect!");
}), /* revert the multiplier before test ends */
fileUpdate(THROTTLE_DEFS).fee(ONE_HUNDRED_HBARS).payingWith(EXCHANGE_RATE_CONTROL).contents(defaultThrottles.toByteArray()).setNode(reconnectingNode), fileUpdate(APP_PROPERTIES).fee(ONE_HUNDRED_HBARS).payingWith(EXCHANGE_RATE_CONTROL).overridingProps(Map.of("fees.percentCongestionMultipliers", defaultCongestionMultipliers, "fees.minCongestionPeriod", defaultMinCongestionPeriod)), cryptoTransfer(HapiCryptoTransfer.tinyBarsFromTo(GENESIS, FUNDING, 1)).payingWith(GENESIS));
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class ValidateExchangeRateStateAfterReconnect method validateExchangeRateStateAfterReconnect.
private HapiApiSpec validateExchangeRateStateAfterReconnect() {
final String transactionid = "authorizedTxn";
final long oldFee = 13_299_075L;
final long newFee = 159_588_904;
return customHapiSpec("validateExchangeRateStateAfterReconnect").withProperties(Map.of("txn.start.offset.secs", "-5")).given(sleepFor(Duration.ofSeconds(25).toMillis()), getAccountBalance(GENESIS).setNode("0.0.6").unavailableNode()).when(getAccountBalance(GENESIS).setNode("0.0.6").unavailableNode(), fileUpdate(EXCHANGE_RATES).contents(spec -> {
ByteString newRates = spec.ratesProvider().rateSetWith(1, 1).toByteString();
spec.registry().saveBytes("newRates", newRates);
return newRates;
}).payingWith(SYSTEM_ADMIN), getAccountBalance(GENESIS).setNode("0.0.6").unavailableNode()).then(withLiveNode("0.0.6").within(180, TimeUnit.SECONDS).loggingAvailabilityEvery(30).sleepingBetweenRetriesFor(10), cryptoCreate("civilian").via(transactionid).setNode("0.0.6"), getTxnRecord(transactionid).setNode("0.0.6").hasPriority(recordWith().fee(newFee)));
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class HapiFileDelete method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
file = fileSupplier.isPresent() ? fileSupplier.get().get() : file;
var fid = TxnUtils.asFileId(file, spec);
FileDeleteTransactionBody opBody = spec.txns().<FileDeleteTransactionBody, FileDeleteTransactionBody.Builder>body(FileDeleteTransactionBody.class, builder -> {
builder.setFileID(fid);
});
return builder -> builder.setFileDelete(opBody);
}
Aggregations