参考https://github.com/ethereum/aleth/blob/master/doc/usingtesteth.rst
1、编译aleth,参考https://github.com/ethereum/aleth#building-from-source
ubuntu环境:(文档说windows环境不确保成功,mac估计没问题)
git clone --recursive https://github.com/ethereum/aleth.git
cd aleth
mkdir build; cd build # Create a build directory.
cmake .. # Configure the project.
cmake --build . # Build all default targets.
2、执行testeth,参考https://github.com/ethereum/aleth/blob/master/doc/usingtesteth.rst
cd /build/test
./testeth
这样执行的是全部测试用例
3、可以执行部分测试用例:
./testeth -t <TEST_SUITE>/<TEST_CASE>
<TEST_SUITE>就是../../test/jsontests/目录下的几个目录名称,
<TEST_CASE>就是<TEST_SUITE>目录下的目录名称
例如:VMTests
./testeth -t VMTests
就是测试../../test/jsontests/VMTests目录下所有文件
./testeth -t VMTests/vmSha3Test
就是测试../../test/jsontests/VMTests/vmSha3Test目录下所有文件
4、也可以测试指定文件
./testeth -t <TEST_SUITE>/<TEST_CASE> -- --singletest <TEST_NAME>
<TEST_NAME>就是<TEST_CASE>目录下的文件名,不包含后缀
例如:
./testeth -t VMTests/vmSha3Test -- --singletest sha3_0
返回:
Running tests using path: "../../test/jsontests"
Running 1 test case...
Test Case "vmSha3Test":
100%
*** No errors detected
如果我们修改sha3_0.json文件中,post段的storage值,
原始的:"0x00" : "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
修改为:"0x00" : "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a471"
保存后,再次执行
./testeth -t VMTests/vmSha3Test -- --singletest sha3_0
返回:
Running tests using path: "../../test/jsontests"
Running 1 test case...
Test Case "vmSha3Test":
100%
/home/elikong/evmc/aleth/test/tools/libtesteth/ImportTest.cpp(584): error: in "VMTests/vmSha3Test": sha3_0 Check State: 0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6: incorrect storage [0x] = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470, expected [0x] = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a471
*** 1 failure is detected (5 failures are expected) in the test module "Master Test Suite"
出现了错误提示
具体测试文件的格式描述参考https://ethereum-tests.readthedocs.io/en/latest/test_types/vm_tests.html
网友评论