EvmTool Quality of Life upgrades (#1553)

* Report a reasonable value for version (#1471)
* Accept filenames from stdin instead of json content (#1470)

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
pull/1559/head
Danno Ferrin 4 years ago committed by GitHub
parent 03a14841b5
commit 94aec764ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java
  2. 32
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java
  3. 30
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/VersionProvider.java

@ -66,6 +66,7 @@ import picocli.CommandLine.Option;
abbreviateSynopsis = true,
name = "evm",
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class,
sortOptions = false,
header = "Usage:",
synopsisHeading = "%n",

@ -40,14 +40,18 @@ import org.hyperledger.besu.ethereum.vm.OperationTracer;
import org.hyperledger.besu.ethereum.vm.StandardJsonTracer;
import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import com.fasterxml.jackson.core.JsonParser.Feature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@ -65,7 +69,8 @@ import picocli.CommandLine.ParentCommand;
@Command(
name = COMMAND_NAME,
description = "Execute an Ethereum State Test.",
mixinStandardHelpOptions = true)
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class)
public class StateTestSubCommand implements Runnable {
private static final Logger LOG = LogManager.getLogger();
@ -95,14 +100,27 @@ public class StateTestSubCommand implements Runnable {
.constructParametricType(Map.class, String.class, GeneralStateTestCaseSpec.class);
try {
if (stateTestFiles.isEmpty()) {
// if no state tests were specified use standard input
// if no state tests were specified use standard input to get filenames
final BufferedReader in =
new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
while (true) {
final Map<String, GeneralStateTestCaseSpec> generalStateTests =
objectMapper.readValue(System.in, javaType);
if (generalStateTests == null || generalStateTests.isEmpty()) {
final String fileName = in.readLine();
if (fileName == null) {
// reached end of file. Stop the loop.
break;
}
executeStateTest(generalStateTests);
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) {
System.out.println("File content error :" + jpe.toString());
}
} else {
System.out.println("File not found:" + fileName);
}
}
} else {
for (final File stateTestFile : stateTestFiles) {
@ -128,7 +146,7 @@ public class StateTestSubCommand implements Runnable {
private void traceTestSpecs(final String test, final List<GeneralStateTestCaseEipSpec> specs) {
Configurator.setLevel(
"org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder", Level.OFF);
var referenceTestProtocolSchedules = ReferenceTestProtocolSchedules.create();
final var referenceTestProtocolSchedules = ReferenceTestProtocolSchedules.create();
Configurator.setLevel("org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder", null);
final OperationTracer tracer = // You should have picked Mercy.

@ -0,0 +1,30 @@
/*
* Copyright ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.evmtool;
import org.hyperledger.besu.BesuInfo;
import picocli.CommandLine;
public class VersionProvider implements CommandLine.IVersionProvider {
public VersionProvider() {}
@Override
public String[] getVersion() {
return new String[] {"Hyperledger Besu EvmTool", BesuInfo.version()};
}
}
Loading…
Cancel
Save