Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: System admin exempt from long term schedule throttles #16838

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -502,6 +503,36 @@ final Stream<DynamicTest> 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<DynamicTest> 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<TransactionBody, TransactionResult> withStatus(@NonNull final ResponseCodeEnum status) {
requireNonNull(status);
return (body, result) -> assertEquals(status, result.status());
Expand Down