Skip to content

Creating a GeneralStateTest (Yoichi's attempt, rough record)

Yoichi Hirai edited this page May 12, 2017 · 23 revisions

choosing what to test

I was going to test "RETURNDATACOPY" in the beginning should copy zero's into the memory.

checking out sources

I checked out https://github.com/ethereum/cpp-ethereum/pull/4062 at ~/src/cpp-ethereum, and

mkdir -p ~/src/cpp-ethereum/build
cd ~/src/cpp-ethereum/build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DVMTRACE=1 ..
make

This PR was still work in progress, but I thought it would perform correctly for this particular test case.

I also checked out https://github.com/ethereum/tests in ~/src/tests (develop branch).

writing test source

choosing a test file

I looked at ~/src/tests/GeneralStateTests.

stAttackTest/                          stChangedEIP150/              stEIP158Specific/           stMemoryStressTest/         stRecursiveCreate/  stSystemOperationsTest/
stBoundsTest/                          stCodeSizeLimit/              stExample/                  stMemoryTest/               stRefundTest/       stTransactionTest/
stCallCodes/                           stCreateTest/                 stHomesteadSpecific/        stNonZeroCallsTest/         stRevertTest/       stTransitionTest/
stCallCreateCallCodeTest/              stDelegatecallTestHomestead/  stInitCodeTest/             stPreCompiledContracts/     stSolidityTest/     stWalletTest/
stCallDelegateCodesCallCodeHomestead/  stEIP150singleCodeGasPrices/  stLogTests/                 stQuadraticComplexityTest/  stSpecialTest/      stZeroCallsRevert/
stCallDelegateCodesHomestead/          stEIP150Specific/             stMemExpandingEIP150Calls/  stRandom/                   stStackTests/       stZeroCallsTest/

Maybe I need a new directory stReturnDataTest.

writing the code

I thought I should fill the memory with some random data first, and then perform "RETURNDATACOPY". Also, the result of the RETURNDATACOPY should be visible somewhere in the state, so I have to MLOAD and SSTORE the result of the RETURNDATACOPY.

The program looks like this

a
b
c

writing a pre-state

generating the test

and then?

file a PR to cpp-ethereum?

file a PR to test? or this is not necessary?

Clone this wiki locally