Search in sources :

Example 61 with HapiApiSpec

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());
}
Also used : INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) 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) ArrayUtils(org.apache.commons.lang3.ArrayUtils) Random(java.util.Random) TRANSACTION_EXPIRED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_EXPIRED) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) Supplier(java.util.function.Supplier) ByteBuffer(java.nio.ByteBuffer) UtilVerbs.keyFromPem(com.hedera.services.bdd.spec.utilops.UtilVerbs.keyFromPem) UtilVerbs.sleepFor(com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor) DUPLICATE_TRANSACTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) INVALID_TOPIC_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOPIC_ID) MESSAGE_SIZE_TOO_LARGE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MESSAGE_SIZE_TOO_LARGE) LoadTest(com.hedera.services.bdd.spec.utilops.LoadTest) UNKNOWN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNKNOWN) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TxnVerbs.submitMessageTo(com.hedera.services.bdd.spec.transactions.TxnVerbs.submitMessageTo) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) Instant(java.time.Instant) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TxnUtils.randomUtf8Bytes(com.hedera.services.bdd.spec.transactions.TxnUtils.randomUtf8Bytes) KeyFactory(com.hedera.services.bdd.spec.keys.KeyFactory) List(java.util.List) Logger(org.apache.logging.log4j.Logger) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) BUSY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY) TOPIC_EXPIRED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOPIC_EXPIRED) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

Example 62 with HapiApiSpec

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));
}
Also used : TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) Supplier(java.util.function.Supplier) LoadTest.defaultLoadTest(com.hedera.services.bdd.spec.utilops.LoadTest.defaultLoadTest) UtilVerbs.noOp(com.hedera.services.bdd.spec.utilops.UtilVerbs.noOp) List(java.util.List) Logger(org.apache.logging.log4j.Logger) DUPLICATE_TRANSACTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) BUSY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

Example 63 with HapiApiSpec

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));
}
Also used : IntStream(java.util.stream.IntStream) ValidateTokensStateAfterReconnect.reconnectingNode(com.hedera.services.bdd.suites.reconnect.ValidateTokensStateAfterReconnect.reconnectingNode) 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) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) UtilVerbs.sleepFor(com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) Duration(java.time.Duration) Map(java.util.Map) UtilVerbs.withLiveNode(com.hedera.services.bdd.spec.utilops.UtilVerbs.withLiveNode) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) ThrottleDefsLoader.protoDefsFromResource(com.hedera.services.bdd.suites.utils.sysfiles.serdes.ThrottleDefsLoader.protoDefsFromResource) HapiApiSpec.customHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.customHapiSpec) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) UtilVerbs.blockingOrder(com.hedera.services.bdd.spec.utilops.UtilVerbs.blockingOrder) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) Logger(org.apache.logging.log4j.Logger) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) Assertions(org.junit.jupiter.api.Assertions) AutoRenewEntitiesForReconnect.runTransfersBeforeReconnect(com.hedera.services.bdd.suites.reconnect.AutoRenewEntitiesForReconnect.runTransfersBeforeReconnect) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) HapiCryptoTransfer(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer) LogManager(org.apache.logging.log4j.LogManager) AtomicLong(java.util.concurrent.atomic.AtomicLong) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

Example 64 with HapiApiSpec

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)));
}
Also used : TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) HapiApiSpec.customHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.customHapiSpec) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) ByteString(com.google.protobuf.ByteString) TimeUnit(java.util.concurrent.TimeUnit) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) UtilVerbs.sleepFor(com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor) List(java.util.List) Logger(org.apache.logging.log4j.Logger) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) Duration(java.time.Duration) Map(java.util.Map) UtilVerbs.withLiveNode(com.hedera.services.bdd.spec.utilops.UtilVerbs.withLiveNode) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString)

Example 65 with HapiApiSpec

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);
}
Also used : FileDeleteTransactionBody(com.hederahashgraph.api.proto.java.FileDeleteTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) FileDeleteTransactionBody(com.hederahashgraph.api.proto.java.FileDeleteTransactionBody) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) MoreObjects(com.google.common.base.MoreObjects) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) Optional(java.util.Optional) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager)

Aggregations

HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)140 List (java.util.List)134 LogManager (org.apache.logging.log4j.LogManager)125 Logger (org.apache.logging.log4j.Logger)125 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)84 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)78 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)76 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)69 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)65 Function (java.util.function.Function)63 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)58 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)56 ByteString (com.google.protobuf.ByteString)53 Key (com.hederahashgraph.api.proto.java.Key)52 CustomSpecAssert.allRunFor (com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor)51 Optional (java.util.Optional)50 UtilVerbs.newKeyNamed (com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed)49 Consumer (java.util.function.Consumer)49 QueryVerbs.getAccountBalance (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance)47 TxnVerbs.fileCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate)46