Skip to content

Commit

Permalink
fix: change failInvalidOutsideDispatchDoesNotAttemptToChargeFees()
Browse files Browse the repository at this point in the history
…for refactored ScheduleService schema (#16328)

Signed-off-by: Michael Tinker <[email protected]>
  • Loading branch information
tinker-michaelj authored Oct 31, 2024
1 parent 2c30a3a commit 7fe8ebe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.hedera.services.bdd.spec;

import static com.hedera.node.app.service.addressbook.AddressBookHelper.NODES_KEY;
import static com.hedera.node.app.service.schedule.impl.schemas.V0490ScheduleSchema.SCHEDULES_BY_EXPIRY_SEC_KEY;
import static com.hedera.node.app.service.schedule.impl.schemas.V0570ScheduleSchema.SCHEDULE_IDS_BY_EXPIRY_SEC_KEY;
import static com.hedera.node.app.service.token.impl.schemas.V0490TokenSchema.ACCOUNTS_KEY;
import static com.hedera.node.app.service.token.impl.schemas.V0490TokenSchema.TOKENS_KEY;
import static com.hedera.services.bdd.junit.extensions.NetworkTargetingExtension.REPEATABLE_KEY_GENERATOR;
Expand Down Expand Up @@ -69,7 +69,7 @@
import com.hedera.hapi.node.state.addressbook.Node;
import com.hedera.hapi.node.state.common.EntityNumber;
import com.hedera.hapi.node.state.primitives.ProtoLong;
import com.hedera.hapi.node.state.schedule.ScheduleList;
import com.hedera.hapi.node.state.schedule.ScheduleIdList;
import com.hedera.hapi.node.state.token.Account;
import com.hedera.hapi.node.state.token.Token;
import com.hedera.node.app.fixtures.state.FakeState;
Expand Down Expand Up @@ -522,9 +522,9 @@ public void sleepConsensusTime(@NonNull final Duration duration) {
* @return the embedded schedule expiries state
* @throws IllegalStateException if this spec is not targeting an embedded network
*/
public @NonNull WritableKVState<ProtoLong, ScheduleList> embeddedScheduleExpiriesOrThrow() {
public @NonNull WritableKVState<ProtoLong, ScheduleIdList> embeddedScheduleExpiriesOrThrow() {
final var state = embeddedStateOrThrow();
return state.getWritableStates(ScheduleService.NAME).get(SCHEDULES_BY_EXPIRY_SEC_KEY);
return state.getWritableStates(ScheduleService.NAME).get(SCHEDULE_IDS_BY_EXPIRY_SEC_KEY);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.hedera.hapi.node.state.blockrecords.BlockInfo;
import com.hedera.hapi.node.state.blockstream.BlockStreamInfo;
import com.hedera.hapi.node.state.primitives.ProtoLong;
import com.hedera.hapi.node.state.schedule.ScheduleList;
import com.hedera.hapi.node.state.schedule.ScheduleIdList;
import com.hedera.hapi.node.state.token.Account;
import com.hedera.hapi.node.state.token.AccountPendingAirdrop;
import com.hedera.hapi.node.state.token.Token;
Expand Down Expand Up @@ -83,7 +83,7 @@ public static MutateTokenOp mutateToken(
* @return the operation that will mutate the schedule expiries
*/
public static MutateScheduleExpiries mutateScheduleExpiries(
@NonNull final Consumer<WritableKVState<ProtoLong, ScheduleList>> mutation) {
@NonNull final Consumer<WritableKVState<ProtoLong, ScheduleIdList>> mutation) {
return new MutateScheduleExpiries(mutation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static java.util.Objects.requireNonNull;

import com.hedera.hapi.node.state.primitives.ProtoLong;
import com.hedera.hapi.node.state.schedule.ScheduleList;
import com.hedera.hapi.node.state.schedule.ScheduleIdList;
import com.hedera.services.bdd.spec.HapiSpec;
import com.hedera.services.bdd.spec.utilops.UtilOp;
import com.swirlds.state.spi.WritableKVState;
Expand All @@ -30,9 +30,9 @@
* An operation that allows the test author to directly mutate the schedule experies in an embedded state.
*/
public class MutateScheduleExpiries extends UtilOp {
private final Consumer<WritableKVState<ProtoLong, ScheduleList>> mutation;
private final Consumer<WritableKVState<ProtoLong, ScheduleIdList>> mutation;

public MutateScheduleExpiries(@NonNull final Consumer<WritableKVState<ProtoLong, ScheduleList>> mutation) {
public MutateScheduleExpiries(@NonNull final Consumer<WritableKVState<ProtoLong, ScheduleIdList>> mutation) {
this.mutation = requireNonNull(mutation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
import com.hedera.hapi.block.stream.output.TransactionResult;
import com.hedera.hapi.node.base.AccountID;
import com.hedera.hapi.node.base.ResponseCodeEnum;
import com.hedera.hapi.node.base.ScheduleID;
import com.hedera.hapi.node.state.blockstream.BlockStreamInfo;
import com.hedera.hapi.node.state.primitives.ProtoLong;
import com.hedera.hapi.node.state.schedule.Schedule;
import com.hedera.hapi.node.state.schedule.ScheduleList;
import com.hedera.hapi.node.state.schedule.ScheduleIdList;
import com.hedera.node.app.blocks.BlockStreamService;
import com.hedera.services.bdd.junit.EmbeddedHapiTest;
import com.hedera.services.bdd.junit.GenesisHapiTest;
Expand All @@ -69,6 +69,7 @@
import com.hedera.services.bdd.spec.transactions.token.TokenMovement;
import com.hedera.services.bdd.spec.utilops.streams.assertions.BlockStreamAssertion;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -168,6 +169,8 @@ final Stream<DynamicTest> failInvalidDuringDispatchRechargesFees() {
@DisplayName("fail invalid outside dispatch does not attempt to charge fees")
final Stream<DynamicTest> failInvalidOutsideDispatchDoesNotAttemptToChargeFees() {
final AtomicReference<BlockStreamInfo> blockStreamInfo = new AtomicReference<>();
final List<ScheduleID> corruptedScheduleIds = new ArrayList<>();
corruptedScheduleIds.add(null);
return hapiTest(
blockStreamMustIncludePassFrom(spec -> blockWithResultOf(FAIL_INVALID)),
cryptoCreate("civilian").balance(ONE_HUNDRED_HBARS),
Expand All @@ -183,7 +186,7 @@ final Stream<DynamicTest> failInvalidOutsideDispatchDoesNotAttemptToChargeFees()
.get()
.lastIntervalProcessTimeOrThrow()
.seconds()),
new ScheduleList(List.of(Schedule.DEFAULT))))),
new ScheduleIdList(corruptedScheduleIds)))),
cryptoTransfer(tinyBarsFromTo("civilian", FUNDING, 1))
.fee(ONE_HBAR)
.hasKnownStatus(com.hederahashgraph.api.proto.java.ResponseCodeEnum.FAIL_INVALID),
Expand Down

0 comments on commit 7fe8ebe

Please sign in to comment.