From f32b79ffe0d923e8014cffddd577e31d1b5be11d Mon Sep 17 00:00:00 2001 From: Michael Tinker Date: Wed, 30 Oct 2024 20:16:54 -0500 Subject: [PATCH] fix: change `failInvalidOutsideDispatchDoesNotAttemptToChargeFees()` for refactored ScheduleService schema (#16328) Signed-off-by: Michael Tinker --- .../main/java/com/hedera/services/bdd/spec/HapiSpec.java | 8 ++++---- .../hedera/services/bdd/spec/utilops/EmbeddedVerbs.java | 4 ++-- .../spec/utilops/embedded/MutateScheduleExpiries.java | 6 +++--- .../suites/integration/ConcurrentIntegrationTests.java | 9 ++++++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/HapiSpec.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/HapiSpec.java index 8de93abf354..97a690b9d87 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/HapiSpec.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/HapiSpec.java @@ -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; @@ -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; @@ -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 embeddedScheduleExpiriesOrThrow() { + public @NonNull WritableKVState 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); } /** diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/utilops/EmbeddedVerbs.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/utilops/EmbeddedVerbs.java index 004bc5b1b79..d758ecec2d6 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/utilops/EmbeddedVerbs.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/utilops/EmbeddedVerbs.java @@ -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; @@ -83,7 +83,7 @@ public static MutateTokenOp mutateToken( * @return the operation that will mutate the schedule expiries */ public static MutateScheduleExpiries mutateScheduleExpiries( - @NonNull final Consumer> mutation) { + @NonNull final Consumer> mutation) { return new MutateScheduleExpiries(mutation); } diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/utilops/embedded/MutateScheduleExpiries.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/utilops/embedded/MutateScheduleExpiries.java index 0a8433d116d..cb9058bfb4a 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/utilops/embedded/MutateScheduleExpiries.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/utilops/embedded/MutateScheduleExpiries.java @@ -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; @@ -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> mutation; + private final Consumer> mutation; - public MutateScheduleExpiries(@NonNull final Consumer> mutation) { + public MutateScheduleExpiries(@NonNull final Consumer> mutation) { this.mutation = requireNonNull(mutation); } diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/integration/ConcurrentIntegrationTests.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/integration/ConcurrentIntegrationTests.java index 07c78e26958..bd7e3b43dcb 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/integration/ConcurrentIntegrationTests.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/integration/ConcurrentIntegrationTests.java @@ -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; @@ -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; @@ -168,6 +169,8 @@ final Stream failInvalidDuringDispatchRechargesFees() { @DisplayName("fail invalid outside dispatch does not attempt to charge fees") final Stream failInvalidOutsideDispatchDoesNotAttemptToChargeFees() { final AtomicReference blockStreamInfo = new AtomicReference<>(); + final List corruptedScheduleIds = new ArrayList<>(); + corruptedScheduleIds.add(null); return hapiTest( blockStreamMustIncludePassFrom(spec -> blockWithResultOf(FAIL_INVALID)), cryptoCreate("civilian").balance(ONE_HUNDRED_HBARS), @@ -183,7 +186,7 @@ final Stream 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),