Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate input and out json files #1303

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@
import static net.consensys.linea.FailedTestJson.readFailedTestsOutput;
import static net.consensys.linea.MapFailedReferenceTestsTool.getModule;
import static net.consensys.linea.MapFailedReferenceTestsTool.getModulesToConstraints;
import static net.consensys.linea.ReferenceTestWatcher.JSON_OUTPUT_FILENAME;
import static net.consensys.linea.ReferenceTestWatcher.JSON_INPUT_FILENAME;
import static org.assertj.core.api.Assertions.assertThat;

import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

import lombok.extern.slf4j.Slf4j;
import net.consensys.linea.corset.CorsetValidator;
Expand Down Expand Up @@ -107,7 +109,7 @@ public static CompletableFuture<Set<String>> getRecordedFailedTestsFromJson(
}
JsonConverter jsonConverter = JsonConverter.builder().build();
CompletableFuture<List<ModuleToConstraints>> modulesToConstraintsFutures =
readFailedTestsOutput(JSON_OUTPUT_FILENAME)
readFailedTestsOutput(JSON_INPUT_FILENAME)
.thenApply(jsonString -> getModulesToConstraints(jsonString, jsonConverter));

return modulesToConstraintsFutures.thenApply(
Expand All @@ -132,26 +134,33 @@ public static Collection<Object[]> generateTestParametersForConfig(final String[
}

public static Collection<Object[]> generateTestParametersForConfig(
final String[] filePath, String failedModule, String failedConstraint) {
final String[] filePath, String failedModule, String failedConstraint)
throws ExecutionException, InterruptedException {
Arrays.stream(filePath).forEach(f -> log.info("checking file: {}", f));
Collection<Object[]> params =
PARAMS.generate(
Arrays.stream(filePath)
.map(f -> Paths.get("src/test/resources/ethereum-tests/" + f).toFile())
.toList());

getRecordedFailedTestsFromJson(failedModule, failedConstraint)
.thenAccept(
return getRecordedFailedTestsFromJson(failedModule, failedConstraint)
.thenApply(
failedTests -> {
params.forEach(param -> markTestToRun(param, failedTests));
});

return params;
List<Object[]> modifiedParams = new ArrayList<>();
for (Object[] param : params) {
Object[] modifiedParam = markTestToRun(param, failedTests);
modifiedParams.add(modifiedParam);
}
return modifiedParams;
})
.get();
}

public static void markTestToRun(Object[] params, Set<String> failedTests) {
String testName = (String) params[0];
params[2] = failedTests.contains(testName);
public static Object[] markTestToRun(Object[] param, Set<String> failedTests) {
String testName = (String) param[0];
param[2] = failedTests.contains(testName);

return param;
}

public static void executeTest(final BlockchainReferenceTestCaseSpec spec) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ReferenceTestWatcher implements TestWatcher {
private static final int LOGBACK_POLL_ATTEMPTS = 100;
private static final Duration LOGBACK_POLL_DELAY = Duration.ofMillis(10);

public static final String JSON_INPUT_FILENAME = "failedBlockchainReferenceTests-input.json";
public static final String JSON_OUTPUT_FILENAME = "failedBlockchainReferenceTests.json";
ListAppender<ILoggingEvent> listAppender = new ListAppender<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class %%TESTS_NAME%% {
private static final String FAILED_CONSTRAINT = "%%FAILED_CONSTRAINT%%";
private static final String[] TEST_CONFIG_FILE_DIR_PATH = new String[] {%%TESTS_FILE%%};

public static Stream<Arguments> getTestParametersForConfig() {
public static Stream<Arguments> getTestParametersForConfig()
throws ExecutionException, InterruptedException {
if (FAILED_MODULE.isEmpty()) {
return generateTestParametersForConfig(TEST_CONFIG_FILE_DIR_PATH).stream().map(params ->
Arguments.of(params[0], params[1], params[2])
Expand Down
Loading