fix(test): fix TestStoreCapture (#711)

This commit is contained in:
HAOYUatHZ 2024-04-18 23:31:36 +08:00 committed by GitHub
parent b078aca5f6
commit 675d81b417
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)}