前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >2019-04-28 以太坊java客户端ethereumj跑测试集

2019-04-28 以太坊java客户端ethereumj跑测试集

作者头像
oracle3
发布2022-05-13 08:27:05
4150
发布2022-05-13 08:27:05
举报
文章被收录于专栏:oracle3技术大杂烩

ethereumj也是支持https://github.com/ethereum/tests测试集,只是代码隐藏的比较深,后来知道Travis CI可以运行测试集,研究了ethereumj项目下的.travis.yml文件总算搞明白了方法。 以下在ubuntu18上执行成功,windows不成功

1、拉取ethereumj

参考https://github.com/ethereum/ethereumj

代码语言:javascript
复制
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

2、拉取tests

代码语言:javascript
复制
git clone https://github.com/ethereum/tests

3、修改配置文件user.conf

就是第一步复制的ethereumj-core/src/main/resources/user.conf,在末尾加上:

代码语言:javascript
复制
GitHubTests.testPath="/home/elikong/evmc/tests"

此路径对应第二步下载的tests代码

4、测试用例

使用eclipse导入,打开文件org.ethereum.jsontestsuite.GitHubVMTest 右键,run as,Junit test 执行成功

5、执行单个用例

在org.ethereum.jsontestsuite.GitHubVMTest增加函数:

代码语言:javascript
复制
    @Test
    public void runSingle() throws ParseException, IOException {
        VMTestSuite.runSingle(commitSHA, "vmSha3Test/sha3_0.json");
    }

6、windows下也可以执行了

主要是代码错误: 在函数中org.ethereum.jsontestsuite.suite.JSONReader.listJsonBlobsForTreeSha(String, String) 原始代码:

代码语言:javascript
复制
                    jsons.add(
                            f.replace(path + System.getProperty("file.separator"), "")
                             .replaceAll(System.getProperty("file.separator"), "/"));

修改为:

代码语言:javascript
复制
                    jsons.add(
                            f.replace(path + System.getProperty("file.separator"), "")
                             .replaceAll(Matcher.quoteReplacement(System.getProperty("file.separator")), "/"));

同样的原因,在函数org.ethereum.jsontestsuite.suite.JSONReader.getFromLocal(String) 原始代码:

代码语言:javascript
复制
        filename = SystemProperties.getDefault().githubTestsPath()
                + System.getProperty("file.separator") + filename.replaceAll("/", System.getProperty("file.separator"));

修改为:

代码语言:javascript
复制
        filename = SystemProperties.getDefault().githubTestsPath()
                + System.getProperty("file.separator") + filename.replaceAll("/", 
                        Matcher.quoteReplacement(System.getProperty("file.separator")));
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-05-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、拉取ethereumj
  • 2、拉取tests
  • 3、修改配置文件user.conf
  • 4、测试用例
  • 5、执行单个用例
  • 6、windows下也可以执行了
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档