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