ethereumj也是支持https://github.com/ethereum/tests测试集,只是代码隐藏的比较深,后来知道Travis CI可以运行测试集,研究了ethereumj项目下的.travis.yml文件总算搞明白了方法。 以下在ubuntu18上执行成功,windows不成功
参考https://github.com/ethereum/ethereumj
git clone https://github.com/ethereum/ethereumj
cd ethereumj
cp ethereumj-core/src/main/resources/ethereumj.conf ethereumj-core/src/main/resources/user.conf
vim ethereumj-core/src/main/resources/user.conf # adjust user.conf to your needs
./gradlew clean fatJar
git clone https://github.com/ethereum/tests
就是第一步复制的ethereumj-core/src/main/resources/user.conf,在末尾加上:
GitHubTests.testPath="/home/elikong/evmc/tests"
此路径对应第二步下载的tests代码
使用eclipse导入,打开文件org.ethereum.jsontestsuite.GitHubVMTest 右键,run as,Junit test 执行成功
在org.ethereum.jsontestsuite.GitHubVMTest增加函数:
@Test
public void runSingle() throws ParseException, IOException {
VMTestSuite.runSingle(commitSHA, "vmSha3Test/sha3_0.json");
}
主要是代码错误: 在函数中org.ethereum.jsontestsuite.suite.JSONReader.listJsonBlobsForTreeSha(String, String) 原始代码:
jsons.add(
f.replace(path + System.getProperty("file.separator"), "")
.replaceAll(System.getProperty("file.separator"), "/"));
修改为:
jsons.add(
f.replace(path + System.getProperty("file.separator"), "")
.replaceAll(Matcher.quoteReplacement(System.getProperty("file.separator")), "/"));
同样的原因,在函数org.ethereum.jsontestsuite.suite.JSONReader.getFromLocal(String) 原始代码:
filename = SystemProperties.getDefault().githubTestsPath()
+ System.getProperty("file.separator") + filename.replaceAll("/", System.getProperty("file.separator"));
修改为:
filename = SystemProperties.getDefault().githubTestsPath()
+ System.getProperty("file.separator") + filename.replaceAll("/",
Matcher.quoteReplacement(System.getProperty("file.separator")));