use of org.hyperledger.besu.ethereum.referencetests.GeneralStateTestCaseSpec in project besu by hyperledger.
the class StateTestSubCommand method run.
@Override
public void run() {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.disable(Feature.AUTO_CLOSE_SOURCE);
final JavaType javaType = objectMapper.getTypeFactory().constructParametricType(Map.class, String.class, GeneralStateTestCaseSpec.class);
try {
if (stateTestFiles.isEmpty()) {
// if no state tests were specified use standard input to get filenames
final BufferedReader in = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
while (true) {
final String fileName = in.readLine();
if (fileName == null) {
// reached end of file. Stop the loop.
break;
}
final File file = new File(fileName);
if (file.isFile()) {
try {
final Map<String, GeneralStateTestCaseSpec> generalStateTests = objectMapper.readValue(file, javaType);
executeStateTest(generalStateTests);
} catch (final JsonProcessingException jpe) {
output.println("File content error: " + jpe);
}
} else {
output.println("File not found: " + fileName);
}
}
} else {
for (final File stateTestFile : stateTestFiles) {
final Map<String, GeneralStateTestCaseSpec> generalStateTests = objectMapper.readValue(stateTestFile, javaType);
executeStateTest(generalStateTests);
}
}
} catch (final IOException e) {
LOG.error("Unable to read state file", e);
}
}
Aggregations