@ -27,6 +27,16 @@ jar {
}
}
sourceSets {
test {
java {
compileClasspath + = main . output
runtimeClasspath + = main . output
srcDirs + = file ( './build/generated/sources/referencetests/java/test' )
}
}
}
dependencies {
annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess'
@ -115,6 +125,7 @@ test {
}
def generateTestFiles ( FileTree jsonPath , File templateFile , String pathstrip , String destination , String namePrefix , String . . . excludedPath ) {
mkdir ( destination )
def referenceTestTemplate = templateFile . text
// This is how many json files to include in each test file
@ -143,63 +154,79 @@ def generateTestFiles(FileTree jsonPath, File templateFile, String pathstrip, St
}
task blockchainReferenceTestsSetup {
inputs . files fileTree ( '../referencetests/src/test/resources/BlockchainTests' )
outputs . files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/blockchain"
generateTestFiles (
fileTree ( '../referencetests/src/test/resources/BlockchainTests' ) ,
file ( "./src/test/resources/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTest.java.template" ) ,
"BlockchainTests" ,
"./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain" ,
"./build/generated/ sou rces /reference tests /java/test /org/hyperledger/besu/ethereum/vm/blockchain" ,
"BlockchainReferenceTest" ,
( "BlockchainTests/InvalidBlocks/bcExpectSection" ) // exclude test for test filling tool
)
}
task legacyBlockchainReferenceTestsSetup {
inputs . files fileTree ( '../referencetests/src/test/resources/LegacyTests/Constantinople/BlockchainTests' )
outputs . files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/blockchain"
generateTestFiles (
fileTree ( '../referencetests/src/test/resources/LegacyTests/Constantinople/BlockchainTests' ) ,
file ( "./src/test/resources/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTest.java.template" ) ,
"LegacyTests" ,
"./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain" ,
"./build/generated/ sou rces /reference tests /java/test /org/hyperledger/besu/ethereum/vm/blockchain" ,
"LegacyBlockchainReferenceTest" ,
( "BlockchainTests/InvalidBlocks/bcExpectSection" ) // exclude test for test filling tool
)
}
task generalstateReferenceTestsSetup {
inputs . files fileTree ( "../referencetests/src/test/resources/GeneralStateTests" )
outputs . files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate"
generateTestFiles (
fileTree ( "../referencetests/src/test/resources/GeneralStateTests" ) ,
file ( "./src/test/resources/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTest.java.template" ) ,
"GeneralStateTests" ,
"./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate" ,
"./build/generated/ sou rces /reference tests /java/test /org/hyperledger/besu/ethereum/vm/generalstate" ,
"GeneralStateReferenceTest"
)
}
task legacyGeneralstateReferenceTestsSetup {
inputs . files fileTree ( '../referencetests/src/test/resources/LegacyTests/Constantinople/GeneralStateTests' )
outputs . files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate"
generateTestFiles (
fileTree ( '../referencetests/src/test/resources/LegacyTests/Constantinople/GeneralStateTests' ) ,
file ( "./src/test/resources/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTest.java.template" ) ,
"LegacyTests" ,
"./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate" ,
"./build/generated/ sou rces /reference tests /java/test /org/hyperledger/besu/ethereum/vm/generalstate" ,
"LegacyGeneralStateReferenceTest"
)
}
task generalstateRegressionReferenceTestsSetup {
inputs . files fileTree ( "./src/test/resources/regressions/generalstate" )
outputs . files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate"
generateTestFiles (
fileTree ( "./src/test/resources/regressions/generalstate" ) ,
file ( "./src/test/resources/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTest.java.template" ) ,
"regressions" ,
"./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate" ,
"./build/generated/ sou rces /reference tests /java/test /org/hyperledger/besu/ethereum/vm/generalstate" ,
"GeneralStateRegressionReferenceTest"
)
}
// TODO delete in Jan 2022 . This is left as a migration aid for reference tests moving to the build directory
task cleanupReferenceTests ( type: Delete ) {
delete fileTree ( "./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate/" ) {
include ( "**/GeneralStateReferenceTest*.java" )
include ( "**/GeneralStateRegressionReferenceTest*.java" )
include ( "**/LegacyGeneralStateReferenceTest*.java" )
include ( "**/LegacyGeneralStateRegressionReferenceTest*.java" )
}
delete fileTree ( "./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain/" ) {
include ( "**/BlockchainReferenceTest*.java" )
include ( "**/LegacyBlockchainReferenceTest*.java" )
}
delete fileTree ( "./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain/" ) { include ( "**/BlockchainReferenceTest*.java" ) }
}
clean . dependsOn ( cleanupReferenceTests )
@ -215,6 +242,8 @@ task referenceTests(type: Test, dependsOn: [
compileTestJava . mustRunAfter blockchainReferenceTestsSetup
compileTestJava . mustRunAfter generalstateReferenceTestsSetup
compileTestJava . mustRunAfter generalstateRegressionReferenceTestsSetup
compileTestJava . mustRunAfter legacyBlockchainReferenceTestsSetup
compileTestJava . mustRunAfter legacyGeneralstateReferenceTestsSetup
doFirst {
if ( ! file ( "../referencetests/src/test/resources/README.md" ) . exists ( ) ) {
throw new GradleException ( "ethereum/referencetests/src/test/resources/README.md missing: please clone submodules (git submodule update --init --recursive)" )