Skip to content

Commit

Permalink
make tests parametrized
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-aouadi committed Oct 16, 2024
1 parent a5b7a08 commit 4a35c6d
Showing 1 changed file with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import tech.pegasys.teku.ethereum.execution.types.Eth1Address;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.async.StubAsyncRunner;
Expand Down Expand Up @@ -104,21 +106,12 @@ void shouldSetupStatePrunerWhenArchiveModeAndRetentionSlotsEnabled() {
.isEqualTo(StorageConfiguration.DEFAULT_STATE_PRUNING_INTERVAL);
}

@Test
void shouldSetupStatePrunerWhenPruneMode() {
when(storageConfiguration.getDataStorageMode()).thenReturn(StateStorageMode.PRUNE);
final SafeFuture<?> future = storageService.doStart();
final Optional<StatePruner> maybeStatePruner = storageService.getStatePruner();
assertThat(future).isCompleted();
assertThat(maybeStatePruner).isPresent();
final StatePruner statePruner = maybeStatePruner.get();
assertThat(statePruner.isRunning()).isTrue();
assertThat(statePruner.getPruneInterval()).isEqualTo(StorageService.STATE_PRUNING_INTERVAL);
}

@Test
void shouldSetupStatePrunerWhenMinimalMode() {
when(storageConfiguration.getDataStorageMode()).thenReturn(StateStorageMode.MINIMAL);
@ParameterizedTest
@EnumSource(
value = StateStorageMode.class,
names = {"PRUNE", "MINIMAL"})
void shouldSetupStatePrunerWhenPruneMode(final StateStorageMode stateStorageMode) {
when(storageConfiguration.getDataStorageMode()).thenReturn(stateStorageMode);
final SafeFuture<?> future = storageService.doStart();
final Optional<StatePruner> maybeStatePruner = storageService.getStatePruner();
assertThat(future).isCompleted();
Expand All @@ -128,9 +121,12 @@ void shouldSetupStatePrunerWhenMinimalMode() {
assertThat(statePruner.getPruneInterval()).isEqualTo(StorageService.STATE_PRUNING_INTERVAL);
}

@Test
void shouldSetupStatePrunerWithCustomInterval() {
when(storageConfiguration.getDataStorageMode()).thenReturn(StateStorageMode.MINIMAL);
@ParameterizedTest
@EnumSource(
value = StateStorageMode.class,
names = {"PRUNE", "MINIMAL"})
void shouldSetupStatePrunerWithCustomInterval(final StateStorageMode stateStorageMode) {
when(storageConfiguration.getDataStorageMode()).thenReturn(stateStorageMode);
final Duration customPruningInterval = Duration.ofSeconds(8);
when(storageConfiguration.getStatePruningInterval()).thenReturn(customPruningInterval);
final SafeFuture<?> future = storageService.doStart();
Expand Down

0 comments on commit 4a35c6d

Please sign in to comment.