准备工作比较多,以下都是在ubuntu18环境下
1、编译Testeth
最好参考2019-04-24 使用Testeth跑以太坊测试集
确保基本测试可以通过
代码语言:javascript复制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、编译hera
可以参考2018-11-26 ewasm在以太坊私有链测试
代码语言:javascript复制cd ../../
git clone https://github.com/ewasm/hera --recursive
cd hera
mkdir build && cd build
cmake .. -DBUILD_SHARED_LIBS=ON
cmake --build .
然后把动态库复制到testeth的目录下
代码语言:javascript复制cp src/libhera.so ../../aleth/build/test/.
3、拉取ewasm测试用例
代码语言:javascript复制cd ../../
git clone https://github.com/ewasm/tests.git
然后复制两个目录到testeth的目录下
代码语言:javascript复制cp tests/GeneralStateTests/stEWASMTests/* aleth/test/jsontests/GeneralStateTests/stEWASMTests/.
cp tests/src/GeneralStateTestsFiller/stEWASMTests/* aleth/test/jsontests/src/GeneralStateTestsFiller/stEWASMTests/.
4、执行测试集
代码语言:javascript复制cd aleth/build/test/
./testeth -t GeneralStateTests/stEWASMTests -- --vm ./libhera.so --singlenet "Byzantium"
测试单个用例:
代码语言:javascript复制./testeth -t GeneralStateTests/stEWASMTests -- --vm ./libhera.so --singletest callCode --singlenet "Byzantium"
显示结果:
代码语言:javascript复制[2019-04-26 16:21:04.623418] [0x00007fc85b02fb00] [info] Loaded EVMC module: hera 0.2.3-alpha.0-3 commit.6fc7cb40 (./libhera.so)
Running tests using path: "../../test/jsontests"
Running 1 test case...
Test Case "stEWASMTests":
100%
Executing message in Hera
importGlobals
[0] callCode 186a0 0 20 20 1
Executing message in Hera
importGlobals
[1] storageStore 0 20
[0] storageStore 80 60
*** No errors detected
5、调试信息
参考# Debugging Ethereum Reference Tests
代码语言:javascript复制cd aleth/build
rm -rfd *
cmake .. -DVMTRACE=1
make
cd build/test
./testeth -t GeneralStateTests/stEWASMTests -- --vm ./libhera.so --singletest createCode --singlenet "Byzantium" --verbosity 3 --vmtrace --statediff
显示:
代码语言:javascript复制TEST createCode:
TRACE 06-04 12:16:31 testeth exec Paying 7 Mwei from sender for gas (7000000 gas at 1 wei)
Executing message in Hera
importGlobals
[0] create 40 100 66 96
Executing message in Hera
importGlobals
[1] finish 200 2
[0] storageStore 0 80
[0] storageStore 20 60
DEBUG 06-04 12:16:31 testeth overlaydb Closing state DB
INFO 06-04 12:16:31 testeth state trNetID: Byzantium
trDataInd: 0 tdGasInd: 0 trValInd: 0
INFO 06-04 12:16:31 testeth state
2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
'balance' : ['0x00', ' =', '0x013240']
'balance' : ['0x00', '->', '0x013240']
'newlyCreated' : ['true']
a94f5374fce5edbc8e2a8697c15331677e6ebf0b
'balance' : ['0x174876e800', ' =', '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff953040']
'balance' : ['0x17480c1840', ' =', '0x699d80']
'balance' : ['0x174876e800', '->', '0x174875b5c0']
'nonce' : ['0x04', '->', '0x05']
deadbeef00000000000000000000000000000000
'nonce' : ['0x00', '->', '0x01']
'storage' : ['0x01 : 0x00', '->', '0x01 : 0xf2048c36a5536fea3bc71d49ed59f2c65c546eea000000000000000000000000']
f2048c36a5536fea3bc71d49ed59f2c65c546eea
'code' : ['0x', '->', '0xbeef']
'newlyCreated' : ['true']
'nonce' : ['0x00', '->', '0x01']