e3: enable simulated backend (#7245)

This commit is contained in:
Alex Sharov 2023-04-03 16:36:31 +07:00 committed by GitHub
parent 8720641c3a
commit bd83f85912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -199,11 +199,11 @@ func (b *SimulatedBackend) emptyPendingBlock() {
// stateByBlockNumber retrieves a state by a given blocknumber.
func (b *SimulatedBackend) stateByBlockNumber(db kv.Tx, blockNumber *big.Int) *state.IntraBlockState {
if blockNumber == nil || blockNumber.Cmp(b.pendingBlock.Number()) == 0 {
return state.New(state.NewPlainState(db, b.pendingBlock.NumberU64()+1, nil))
//return state.New(b.m.NewHistoryStateReader(b.pendingBlock.NumberU64()+1, db))
//return state.New(state.NewPlainState(db, b.pendingBlock.NumberU64()+1, nil))
return state.New(b.m.NewHistoryStateReader(b.pendingBlock.NumberU64()+1, db))
}
return state.New(state.NewPlainState(db, blockNumber.Uint64()+1, nil))
//return state.New(b.m.NewHistoryStateReader(blockNumber.Uint64()+1, db))
//return state.New(state.NewPlainState(db, blockNumber.Uint64()+1, nil))
return state.New(b.m.NewHistoryStateReader(blockNumber.Uint64()+1, db))
}
// CodeAt returns the code associated with a certain account in the blockchain.

View File

@ -35,7 +35,6 @@ import (
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/common/u256"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/params"
@ -147,8 +146,8 @@ func TestNewSimulatedBackend(t *testing.T) {
t.Fatal(err)
}
//statedb := sim.stateByBlockNumber(tx, big.NewInt(int64(num+1)))
statedb := state.New(state.NewPlainState(tx, num+1, nil))
statedb := sim.stateByBlockNumber(tx, big.NewInt(int64(num+1)))
//statedb := state.New(state.NewPlainState(tx, num+1, nil))
bal := statedb.GetBalance(testAddr)
if !bal.Eq(expectedBal) {
t.Errorf("expected balance for test address not received. expected: %v actual: %v", expectedBal, bal)