EVM testing in CPP client

I found this nifty thing in the GO-codebase; ' ./evm -code=FFF...' which spins up a little EVM and runs the code. Is there anything similarly simple in the cpp-codebase so I can compare the two implementations?

I'd like to just compare the to VM:s, without everything else - just to watch the stack and results without caring about the sideeffects.


  • mhswendemhswende Member Posts: 3
    I posted the same question on IRC, got this response:
    <gavofyork> @holliman it can be arranged
     <gavofyork> however, it makes only partial sense
     <gavofyork> not clear what other accounts would do
     <gavofyork> or the blockchin access operations
    It's pretty simple (https://github.com/ethereum/go-ethereum/blob/develop/cmd/evm/main.go)
    	db, _ := ethdb.NewMemDatabase()
    	statedb := state.New(common.Hash{}, db)
    	sender := statedb.CreateAccount(common.StringToAddress("sender"))
    	receiver := statedb.CreateAccount(common.StringToAddress("receiver"))
    	vmenv := NewEnv(statedb, common.StringToAddress("evmuser"), common.Big(*value))
    	tstart := time.Now()
    	ret, e := vmenv.Call(sender, receiver.Address(), common.Hex2Bytes(*data), common.Big(*gas), common.Big(*price), common.Big(*value))
    Just initialize an empty state with a couple of basic defaults.
  • ChrJentzschChrJentzsch Member Posts: 17
    edited July 2015
    Yes this can be done with this tool: /build/ethvm. Type ./ethvm --help to check its functionality.
    Even better, write a StateTest (https://github.com/ethereum/tests/wiki/State-tests). There you can set the environment which is needed (blocknumber, time, ...). You can then run the test and get a trace using testeth (build/tests/testeth, see here: https://github.com/ethereum/tests/wiki/Using-Testeth)
Sign In or Register to comment.