Skip to content

Commit

Permalink
fix: stabilize SysDelSysUndelSpec (#13289)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Tinker <michael.tinker@swirldslabs.com>
  • Loading branch information
tinker-michaelj committed May 15, 2024
1 parent d11f1a7 commit 0166e6a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ public interface OpProvider {
};

ResponseCodeEnum[] STANDARD_PERMISSIBLE_OUTCOMES = {
SUCCESS, LIVE_HASH_NOT_FOUND, INSUFFICIENT_PAYER_BALANCE, UNKNOWN, INSUFFICIENT_TX_FEE, INVALID_SIGNATURE
SUCCESS,
LIVE_HASH_NOT_FOUND,
INSUFFICIENT_PAYER_BALANCE,
UNKNOWN,
INSUFFICIENT_TX_FEE,
INVALID_SIGNATURE,
PAYER_ACCOUNT_DELETED
};

default List<HapiSpecOperation> suggestedInitializers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_HAS_NO_FREEZE_KEY;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_WAS_DELETED;

import com.hedera.services.bdd.spec.HapiSpecOperation;
import com.hedera.services.bdd.spec.infrastructure.OpProvider;
Expand All @@ -33,7 +34,7 @@ public class RandomTokenUnfreeze implements OpProvider {
private final RegistrySourcedNameProvider<TokenAccountRegistryRel> tokenRels;

private final ResponseCodeEnum[] permissibleOutcomes =
standardOutcomesAnd(TOKEN_HAS_NO_FREEZE_KEY, TOKEN_NOT_ASSOCIATED_TO_ACCOUNT);
standardOutcomesAnd(TOKEN_HAS_NO_FREEZE_KEY, TOKEN_NOT_ASSOCIATED_TO_ACCOUNT, TOKEN_WAS_DELETED);
private final ResponseCodeEnum[] customOutcomes;
private final ResponseCodeEnum[] customPrechecks = new ResponseCodeEnum[] {INVALID_SIGNATURE};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ public static SubmitModificationsOp submitModified(
return new SubmitModificationsOp(txnOpSupplier, modificationsFn);
}

public static SubmitModificationsOp submitModifiedWithFixedPayer(
@NonNull final Function<Transaction, List<TxnModification>> modificationsFn,
@NonNull final Supplier<HapiTxnOp<?>> txnOpSupplier) {
return new SubmitModificationsOp(false, txnOpSupplier, modificationsFn);
}

/**
* Returns an operation that repeatedly sends a query from the given
* supplier, but each time after modifying the query with one of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ public SubmitModificationsOp(
this.modificationsFn = modificationsFn;
}

public SubmitModificationsOp(
final boolean useCivilianPayer,
@NonNull final Supplier<HapiTxnOp<?>> txnOpSupplier,
@NonNull final Function<Transaction, List<TxnModification>> modificationsFn) {
this.useCivilianPayer = useCivilianPayer;
this.txnOpSupplier = txnOpSupplier;
this.modificationsFn = modificationsFn;
}

@Override
protected boolean submitOp(@NonNull final HapiSpec spec) throws Throwable {
final List<TxnModification> modifications = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate;
import static com.hedera.services.bdd.spec.transactions.TxnVerbs.systemFileDelete;
import static com.hedera.services.bdd.spec.transactions.TxnVerbs.systemFileUndelete;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.submitModified;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.submitModifiedWithFixedPayer;
import static com.hedera.services.bdd.spec.utilops.mod.ModificationUtils.withSuccessivelyVariedBodyIds;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.AUTHORIZATION_FAILED;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.ENTITY_NOT_ALLOWED_TO_DELETE;
Expand Down Expand Up @@ -69,7 +69,7 @@ public HapiSpec sysDelIdVariantsTreatedAsExpected() {
return defaultHapiSpec("sysDelIdVariantsTreatedAsExpected")
.given(fileCreate("misc").contents(ORIG_FILE))
.when()
.then(submitModified(withSuccessivelyVariedBodyIds(), () -> systemFileDelete("misc")
.then(submitModifiedWithFixedPayer(withSuccessivelyVariedBodyIds(), () -> systemFileDelete("misc")
.payingWith(SYSTEM_DELETE_ADMIN)));
}

Expand All @@ -78,7 +78,7 @@ public HapiSpec sysUndelIdVariantsTreatedAsExpected() {
return defaultHapiSpec("sysUndelIdVariantsTreatedAsExpected")
.given(fileCreate("misc").contents(ORIG_FILE))
.when(systemFileDelete("misc").payingWith(SYSTEM_DELETE_ADMIN))
.then(submitModified(withSuccessivelyVariedBodyIds(), () -> systemFileUndelete("misc")
.then(submitModifiedWithFixedPayer(withSuccessivelyVariedBodyIds(), () -> systemFileUndelete("misc")
.payingWith(SYSTEM_UNDELETE_ADMIN)));
}

Expand Down

0 comments on commit 0166e6a

Please sign in to comment.