diff --git a/eth/tracers/logger/logger_test.go b/eth/tracers/logger/logger_test.go index 432eb3f934..6883af1014 100644 --- a/eth/tracers/logger/logger_test.go +++ b/eth/tracers/logger/logger_test.go @@ -23,6 +23,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" @@ -52,10 +53,18 @@ func (*dummyStatedb) GetRefund() uint64 { func (*dummyStatedb) GetState(_ common.Address, _ common.Hash) common.Hash { return common.Hash{} } func (*dummyStatedb) SetState(_ common.Address, _ common.Hash, _ common.Hash) {} +// newTestStateDB create a sample test state to test node-wise reconstruction. +func newTestStateDB() *state.StateDB { + // Create an empty state + db := state.NewDatabase(rawdb.NewMemoryDatabase()) + stateDb, _ := state.New(common.Hash{}, db, nil) + return stateDb +} + func TestStoreCapture(t *testing.T) { var ( logger = NewStructLogger(nil) - env = vm.NewEVM(vm.BlockContext{}, vm.TxContext{}, &dummyStatedb{}, params.TestChainConfig, vm.Config{Tracer: logger}) + env = vm.NewEVM(vm.BlockContext{}, vm.TxContext{}, newTestStateDB(), params.TestChainConfig, vm.Config{Tracer: logger}) contract = vm.NewContract(&dummyContractRef{}, &dummyContractRef{}, new(big.Int), 100000) ) contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x0, byte(vm.SSTORE)}