Refactored ethutil.Config.Db out
This commit is contained in:
@ -6,16 +6,22 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/ethutil"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
)
|
||||
|
||||
// State query interface
|
||||
type stateQuery struct{}
|
||||
type stateQuery struct{ db ethutil.Database }
|
||||
|
||||
func SQ() stateQuery {
|
||||
db, _ := ethdb.NewMemDatabase()
|
||||
return stateQuery{db: db}
|
||||
}
|
||||
|
||||
func (self stateQuery) GetAccount(addr []byte) *state.StateObject {
|
||||
return state.NewStateObject(addr)
|
||||
return state.NewStateObject(addr, self.db)
|
||||
}
|
||||
|
||||
func transaction() *types.Transaction {
|
||||
@ -66,7 +72,7 @@ func TestRemoveInvalid(t *testing.T) {
|
||||
pool, key := setup()
|
||||
tx1 := transaction()
|
||||
pool.addTx(tx1)
|
||||
pool.RemoveInvalid(stateQuery{})
|
||||
pool.RemoveInvalid(SQ())
|
||||
if pool.Size() > 0 {
|
||||
t.Error("expected pool size to be 0")
|
||||
}
|
||||
@ -74,7 +80,7 @@ func TestRemoveInvalid(t *testing.T) {
|
||||
tx1.SetNonce(1)
|
||||
tx1.SignECDSA(key)
|
||||
pool.addTx(tx1)
|
||||
pool.RemoveInvalid(stateQuery{})
|
||||
pool.RemoveInvalid(SQ())
|
||||
if pool.Size() != 1 {
|
||||
t.Error("expected pool size to be 1, is", pool.Size())
|
||||
}
|
||||
|
Reference in New Issue
Block a user