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 9f3f5df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import tech.pegasys.teku.storage.client.CombinedChainDataClient;
import tech.pegasys.teku.storage.client.EarliestAvailableBlockSlot;
import tech.pegasys.teku.storage.client.RecentChainData;
import tech.pegasys.teku.storage.server.StateStorageMode;
import tech.pegasys.teku.storage.storageSystem.InMemoryStorageSystemBuilder;
import tech.pegasys.teku.storage.storageSystem.StorageSystem;

Expand Down Expand Up @@ -290,7 +291,7 @@ public void run_requestBatchWithSkippedSlots() {
}

@ParameterizedTest
@ValueSource(booleans = {true, false})
@ValueSource(classes = {StateStorageMode.class, false})
public void run_requestBatchForRangeOfEmptyBlocks(final boolean blobSidecarsRequired) {
if (blobSidecarsRequired) {
when(blobSidecarManager.isAvailabilityRequiredAtSlot(any())).thenReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
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 org.junit.jupiter.params.provider.ValueSource;
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 +107,10 @@ 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 +120,10 @@ 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 9f3f5df

Please sign in to comment.