准备工作比较多,以下都是在ubuntu18环境下
最好参考2019-04-24 使用Testeth跑以太坊测试集
确保基本测试可以通过
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.
cd ../../
git clone https://github.com/ewasm/hera --recursive
cd hera
mkdir build && cd build
cmake .. -DBUILD_SHARED_LIBS=ON
cmake --build .
然后把动态库复制到testeth的目录下
cp src/libhera.so ../../aleth/build/test/.
cd ../../
git clone https://github.com/ewasm/tests.git
然后复制两个目录到testeth的目录下
cp tests/GeneralStateTests/stEWASMTests/* aleth/test/jsontests/GeneralStateTests/stEWASMTests/.
cp tests/src/GeneralStateTestsFiller/stEWASMTests/* aleth/test/jsontests/src/GeneralStateTestsFiller/stEWASMTests/.
cd aleth/build/test/
./testeth -t GeneralStateTests/stEWASMTests -- --vm ./libhera.so --singlenet "Byzantium"
测试单个用例:
./testeth -t GeneralStateTests/stEWASMTests -- --vm ./libhera.so --singletest callCode --singlenet "Byzantium"
显示结果:
[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
参考# Debugging Ethereum Reference Tests
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
显示:
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']