Skip to content

Commit

Permalink
chore: Clean up schedule HapiSpec suites (#10710)
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Sinclair <[email protected]>
  • Loading branch information
jsync-swirlds authored Jan 3, 2024
1 parent a4683b7 commit eb12fed
Show file tree
Hide file tree
Showing 10 changed files with 500 additions and 475 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 Hedera Hashgraph, LLC
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -106,7 +106,6 @@
import static com.hedera.services.bdd.suites.crypto.CryptoCreateSuite.ED_25519_KEY;
import static com.hedera.services.bdd.suites.crypto.CryptoCreateSuite.LAZY_CREATION_ENABLED;
import static com.hedera.services.bdd.suites.file.FileUpdateSuite.CIVILIAN;
import static com.hedera.services.bdd.suites.schedule.ScheduleLongTermExecutionSpecs.SENDER_TXN;
import static com.hedera.services.bdd.suites.token.TokenPauseSpecs.DEFAULT_MIN_AUTO_RENEW_PERIOD;
import static com.hedera.services.bdd.suites.token.TokenPauseSpecs.LEDGER_AUTO_RENEW_PERIOD_MIN_DURATION;
import static com.hedera.services.bdd.suites.token.TokenPauseSpecs.TokenIdOrderingAsserts.withOrderedTokenIds;
Expand Down Expand Up @@ -187,6 +186,7 @@ public class LeakyCryptoTestsSuite extends HapiSuite {
public static final String PAY_TXN = "payTxn";
public static final String CREATE_TX = "createTX";
public static final String V_0_34 = "v0.34";
private static final String SENDER_TXN = "senderTxn";

public static void main(String... args) {
new LeakyCryptoTestsSuite().runSuiteSync();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Hedera Hashgraph, LLC
* Copyright (C) 2020-2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,7 +44,29 @@
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.overriding;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor;
import static com.hedera.services.bdd.suites.schedule.ScheduleLongTermExecutionSpecs.withAndWithoutLongTermEnabled;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.ADMIN;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.BASIC_XFER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.CONTINUE;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.COPYCAT;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.CREATION;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.DEFAULT_TX_EXPIRY;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.DESIGNATING_PAYER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.ENTITY_MEMO;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.FIRST_PAYER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.NEVER_TO_BE;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.ONLY_BODY;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.ONLY_BODY_AND_ADMIN_KEY;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.ONLY_BODY_AND_MEMO;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.ONLY_BODY_AND_PAYER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.ORIGINAL;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.PAYER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.RECEIVER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.SCHEDULING_WHITELIST;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.SECOND_PAYER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.SENDER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.VALID_SCHEDULE;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.WHITELIST_DEFAULT;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.withAndWithoutLongTermEnabled;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_ID_DOES_NOT_EXIST;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.IDENTICAL_SCHEDULE_ALREADY_CREATED;
Expand Down Expand Up @@ -75,31 +97,6 @@
public class ScheduleCreateSpecs extends HapiSuite {
private static final Logger log = LogManager.getLogger(ScheduleCreateSpecs.class);

private static final String SCHEDULING_WHITELIST = "scheduling.whitelist";
private static final String defaultWhitelist =
HapiSpecSetup.getDefaultNodeProps().get(SCHEDULING_WHITELIST);
private static final String defaultTxExpiry =
HapiSpecSetup.getDefaultNodeProps().get("ledger.schedule.txExpiryTimeSecs");
private static final String DESIGNATING_PAYER = "1.2.3";
private static final String ONLY_BODY = "onlyBody";
private static final String ONLY_BODY_AND_ADMIN_KEY = "onlyBodyAndAdminKey";
private static final String ONLY_BODY_AND_MEMO = "onlyBodyAndMemo";
private static final String CREATION = "creation";
private static final String BASIC_XFER = "basicXfer";
private static final String NEVER_TO_BE = "neverToBe";
private static final String SENDER = "sender";
private static final String VALID_SCHEDULE = "validSchedule";
private static final String ADMIN = "admin";
private static final String PAYER = "payer";
private static final String ONLY_BODY_AND_PAYER = "onlyBodyAndPayer";
private static final String ORIGINAL = "original";
private static final String CONTINUE = "continue";
private static final String ENTITY_MEMO = "This was Mr. Bleaney's room. He stayed";
private static final String SECOND_PAYER = "secondPayer";
private static final String FIRST_PAYER = "firstPayer";
private static final String COPYCAT = "copycat";
private static final String RECEIVER = "receiver";

public static void main(String... args) {
new ScheduleCreateSpecs().runSuiteSync();
}
Expand Down Expand Up @@ -141,7 +138,7 @@ final HapiSpec suiteCleanup() {
return defaultHapiSpec("suiteCleanup")
.given()
.when()
.then(overriding("ledger.schedule.txExpiryTimeSecs", defaultTxExpiry));
.then(overriding("ledger.schedule.txExpiryTimeSecs", DEFAULT_TX_EXPIRY));
}

@HapiTest
Expand Down Expand Up @@ -441,7 +438,7 @@ final HapiSpec preservesRevocationServiceSemanticsForFileDelete() {
.sigControl(forKey(shouldBeDeletedEventually, compensatorySigs)),
sleepFor(1_000L),
getFileInfo(shouldBeDeletedEventually).hasDeleted(true),
overriding(SCHEDULING_WHITELIST, defaultWhitelist));
overriding(SCHEDULING_WHITELIST, WHITELIST_DEFAULT));
}

@HapiTest
Expand Down Expand Up @@ -585,7 +582,7 @@ public HapiSpec whitelistWorks() {
scheduleCreate("ok", createTopic(NEVER_TO_BE))
// prevent multiple runs of this test causing duplicates
.withEntityMemo("" + new SecureRandom().nextLong()))
.then(overriding(SCHEDULING_WHITELIST, defaultWhitelist));
.then(overriding(SCHEDULING_WHITELIST, WHITELIST_DEFAULT));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Hedera Hashgraph, LLC
* Copyright (C) 2020-2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,8 +26,12 @@
import static com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.overriding;
import static com.hedera.services.bdd.suites.schedule.ScheduleLongTermExecutionSpecs.withAndWithoutLongTermEnabled;
import static com.hedera.services.bdd.suites.schedule.ScheduleLongTermSignSpecs.SCHEDULING_WHITELIST;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.ADMIN;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.RECEIVER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.SCHEDULING_WHITELIST;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.SENDER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.VALID_SCHEDULED_TXN;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.withAndWithoutLongTermEnabled;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SCHEDULE_ID;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.SCHEDULE_ALREADY_DELETED;
Expand All @@ -45,10 +49,6 @@
@HapiTestSuite
public class ScheduleDeleteSpecs extends HapiSuite {
private static final Logger log = LogManager.getLogger(ScheduleDeleteSpecs.class);
private static final String VALID_SCHEDULED_TXN = "validScheduledTxn";
private static final String SENDER = "sender";
private static final String RECEIVER = "receiver";
private static final String ADMIN = "admin";

public static void main(String... args) {
new ScheduleDeleteSpecs().runSuiteAsync();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Hedera Hashgraph, LLC
* Copyright (C) 2020-2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,8 +37,26 @@
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.overriding;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext;
import static com.hedera.services.bdd.suites.schedule.ScheduleExecutionSpecs.addAllToWhitelist;
import static com.hedera.services.bdd.suites.schedule.ScheduleLongTermExecutionSpecs.withAndWithoutLongTermEnabled;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.A_TOKEN;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.DEFAULT_MAX_TOKEN_TRANSFER_LEN;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.DEFAULT_MAX_TRANSFER_LEN;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.DEFAULT_TX_EXPIRY;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.FAILING_TXN;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.LEDGER_TOKEN_TRANSFERS_MAX_LEN;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.LEDGER_TRANSFERS_MAX_LEN;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.PAYING_ACCOUNT;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.RECEIVER_A;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.RECEIVER_B;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.RECEIVER_C;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.SCHEDULE_PAYER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.SENDER;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.SUPPLY_KEY;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.TOKENS_NFTS_ARE_ENABLED;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.TREASURY;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.VALID_SCHEDULE;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.WHITELIST_DEFAULT;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.addAllToWhitelist;
import static com.hedera.services.bdd.suites.schedule.ScheduleUtils.withAndWithoutLongTermEnabled;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.NOT_SUPPORTED;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_TRANSFER_LIST_SIZE_LIMIT_EXCEEDED;
Expand All @@ -49,7 +67,6 @@
import com.hedera.services.bdd.junit.HapiTest;
import com.hedera.services.bdd.junit.HapiTestSuite;
import com.hedera.services.bdd.spec.HapiSpec;
import com.hedera.services.bdd.spec.HapiSpecSetup;
import com.hedera.services.bdd.suites.HapiSuite;
import com.hederahashgraph.api.proto.java.TokenType;
import java.util.List;
Expand All @@ -69,30 +86,6 @@ public class ScheduleExecutionSpecStateful extends HapiSuite {
private static final int TMP_MAX_TRANSFER_LENGTH = 2;
private static final int TMP_MAX_TOKEN_TRANSFER_LENGTH = 2;

private static final String defaultTxExpiry =
HapiSpecSetup.getDefaultNodeProps().get("ledger.schedule.txExpiryTimeSecs");
private static final String LEDGER_TRANSFERS_MAX_LEN = "ledger.transfers.maxLen";
private static final String defaultMaxTransferLen =
HapiSpecSetup.getDefaultNodeProps().get(LEDGER_TRANSFERS_MAX_LEN);
private static final String LEDGER_TOKEN_TRANSFERS_MAX_LEN = "ledger.tokenTransfers.maxLen";
private static final String defaultMaxTokenTransferLen =
HapiSpecSetup.getDefaultNodeProps().get(LEDGER_TOKEN_TRANSFERS_MAX_LEN);
private static final String defaultWhitelist =
HapiSpecSetup.getDefaultNodeProps().get("scheduling.whitelist");

private static final String A_TOKEN = "token";
private static final String VALID_SCHEDULE = "validSchedule";
private static final String SCHEDULE_PAYER = "schedulePayer";
private static final String TOKENS_NFTS_ARE_ENABLED = "tokens.nfts.areEnabled";
private static final String TREASURY = "treasury";
private static final String SUPPLY_KEY = "supplyKey";
private static final String SENDER = "sender";
private static final String RECEIVER_A = "receiverA";
private static final String RECEIVER_B = "receiverB";
private static final String RECEIVER_C = "receiverC";
private static final String PAYING_ACCOUNT = "payingAccount";
String failingTxn = "failingTxn";

public static void main(String... args) {
new ScheduleExecutionSpecStateful().runSuiteSync();
}
Expand Down Expand Up @@ -143,15 +136,15 @@ final HapiSpec scheduledUniqueMintFailsWithNftsDisabled() {
.initialSupply(0),
scheduleCreate(VALID_SCHEDULE, mintToken(A_TOKEN, List.of(ByteString.copyFromUtf8("m1"))))
.designatingPayer(SCHEDULE_PAYER)
.via(failingTxn),
.via(FAILING_TXN),
fileUpdate(APP_PROPERTIES)
.payingWith(ADDRESS_BOOK_CONTROL)
.overridingProps(Map.of(TOKENS_NFTS_ARE_ENABLED, "false")))
.when(scheduleSign(VALID_SCHEDULE)
.alsoSigningWith(SUPPLY_KEY, SCHEDULE_PAYER, TREASURY)
.hasKnownStatus(SUCCESS))
.then(
getTxnRecord(failingTxn)
getTxnRecord(FAILING_TXN)
.scheduled()
.hasPriority(recordWith().status(NOT_SUPPORTED)),
getTokenInfo(A_TOKEN).hasTotalSupply(0),
Expand All @@ -175,15 +168,15 @@ final HapiSpec scheduledUniqueBurnFailsWithNftsDisabled() {
.initialSupply(0),
scheduleCreate(VALID_SCHEDULE, burnToken(A_TOKEN, List.of(1L, 2L)))
.designatingPayer(SCHEDULE_PAYER)
.via(failingTxn),
.via(FAILING_TXN),
fileUpdate(APP_PROPERTIES)
.payingWith(ADDRESS_BOOK_CONTROL)
.overridingProps(Map.of(TOKENS_NFTS_ARE_ENABLED, "false")))
.when(scheduleSign(VALID_SCHEDULE)
.alsoSigningWith(SUPPLY_KEY, SCHEDULE_PAYER, TREASURY)
.hasKnownStatus(SUCCESS))
.then(
getTxnRecord(failingTxn)
getTxnRecord(FAILING_TXN)
.scheduled()
.hasPriority(recordWith().status(NOT_SUPPORTED)),
getTokenInfo(A_TOKEN).hasTotalSupply(0),
Expand Down Expand Up @@ -223,7 +216,7 @@ public HapiSpec executionWithTransferListWrongSizedFails() {
.via("signTx")
.hasKnownStatus(SUCCESS))
.then(
overriding(LEDGER_TRANSFERS_MAX_LEN, defaultMaxTransferLen),
overriding(LEDGER_TRANSFERS_MAX_LEN, DEFAULT_MAX_TRANSFER_LEN),
getAccountBalance(SENDER).hasTinyBars(senderBalance),
getAccountBalance(RECEIVER_A).hasTinyBars(noBalance),
getAccountBalance(RECEIVER_B).hasTinyBars(noBalance),
Expand Down Expand Up @@ -270,7 +263,7 @@ final HapiSpec executionWithTokenTransferListSizeExceedFails() {
.alsoSigningWith(xTreasury, schedulePayer)
.designatingPayer(schedulePayer))
.then(
overriding(LEDGER_TOKEN_TRANSFERS_MAX_LEN, defaultMaxTokenTransferLen),
overriding(LEDGER_TOKEN_TRANSFERS_MAX_LEN, DEFAULT_MAX_TOKEN_TRANSFER_LEN),
getTxnRecord(failedTxn)
.scheduled()
.hasPriority(recordWith().status(TOKEN_TRANSFER_LIST_SIZE_LIMIT_EXCEEDED)),
Expand All @@ -284,8 +277,8 @@ final HapiSpec suiteCleanup() {
.given()
.when()
.then(
overriding("ledger.schedule.txExpiryTimeSecs", defaultTxExpiry),
overriding("scheduling.whitelist", defaultWhitelist),
overriding("ledger.schedule.txExpiryTimeSecs", DEFAULT_TX_EXPIRY),
overriding("scheduling.whitelist", WHITELIST_DEFAULT),
fileUpdate(APP_PROPERTIES)
.payingWith(ADDRESS_BOOK_CONTROL)
.overridingProps(Map.of(TOKENS_NFTS_ARE_ENABLED, "true")));
Expand Down
Loading

0 comments on commit eb12fed

Please sign in to comment.