From c159fa2e611fcb121f25146a63ef90b54402e16c Mon Sep 17 00:00:00 2001 From: ibankov Date: Fri, 29 Nov 2024 10:27:45 +0200 Subject: [PATCH] system admin exempt from throttles test Signed-off-by: ibankov --- .../integration/RepeatableHip423Tests.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/integration/RepeatableHip423Tests.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/integration/RepeatableHip423Tests.java index fb63b6cfce02..bd54bdfa6f9b 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/integration/RepeatableHip423Tests.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/integration/RepeatableHip423Tests.java @@ -64,6 +64,7 @@ import static com.hedera.services.bdd.suites.HapiSuite.ONE_HBAR; import static com.hedera.services.bdd.suites.HapiSuite.ONE_HUNDRED_HBARS; import static com.hedera.services.bdd.suites.HapiSuite.ONE_MILLION_HBARS; +import static com.hedera.services.bdd.suites.HapiSuite.SYSTEM_ADMIN; import static com.hederahashgraph.api.proto.java.HederaFunctionality.ConsensusCreateTopic; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.SCHEDULE_EXPIRY_IS_BUSY; @@ -502,6 +503,36 @@ final Stream executionResultsAreStreamedAsExpected() { cryptoTransfer(tinyBarsFromTo(DEFAULT_PAYER, FUNDING, 1L))); } + /** + * Tests that system accounts are exempt from throttles. + */ + @LeakyRepeatableHapiTest( + value = NEEDS_LAST_ASSIGNED_CONSENSUS_TIME, + overrides = {"scheduling.maxTxnPerSec"}) + final Stream systemAccountsExemptFromThrottles() { + final AtomicLong expiry = new AtomicLong(); + final var oddLifetime = 123 * ONE_MINUTE; + return hapiTest( + overriding("scheduling.maxTxnPerSec", "2"), + cryptoCreate(CIVILIAN_PAYER).balance(10 * ONE_HUNDRED_HBARS), + scheduleCreate("first", cryptoTransfer(tinyBarsFromTo(DEFAULT_PAYER, FUNDING, 123L))) + .payingWith(CIVILIAN_PAYER) + .fee(ONE_HBAR) + .expiringIn(oddLifetime), + // Consensus time advances exactly one second per transaction in repeatable mode + exposeSpecSecondTo(now -> expiry.set(now + oddLifetime - 1)), + sourcing(() -> scheduleCreate("second", cryptoTransfer(tinyBarsFromTo(DEFAULT_PAYER, FUNDING, 456L))) + .payingWith(CIVILIAN_PAYER) + .fee(ONE_HBAR) + .expiringAt(expiry.get())), + // When scheduling with the system account, the throttle should not apply + sourcing(() -> scheduleCreate("third", cryptoTransfer(tinyBarsFromTo(DEFAULT_PAYER, FUNDING, 789))) + .payingWith(SYSTEM_ADMIN) + .fee(ONE_HBAR) + .expiringAt(expiry.get())), + purgeExpiringWithin(oddLifetime)); + } + private static BiConsumer withStatus(@NonNull final ResponseCodeEnum status) { requireNonNull(status); return (body, result) -> assertEquals(status, result.status());