ethchain: fix tests

This commit is contained in:
Felix Lange 2014-10-14 02:01:46 +02:00
parent 36cdab2068
commit 20cdb73862
3 changed files with 14 additions and 11 deletions

View File

@ -3,5 +3,5 @@ package ethchain
import "testing" import "testing"
func TestFilter(t *testing.T) { func TestFilter(t *testing.T) {
filter := NewFilter() NewFilter(NewTestManager())
} }

View File

@ -6,16 +6,17 @@ import (
"github.com/ethereum/eth-go/ethcrypto" "github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethdb" "github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire" "github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/eth-go/event"
) )
// Implement our EthTest Manager // Implement our EthTest Manager
type TestManager struct { type TestManager struct {
stateManager *StateManager stateManager *StateManager
reactor *ethreact.ReactorEngine eventMux *event.TypeMux
db ethutil.Database
txPool *TxPool txPool *TxPool
blockChain *BlockChain blockChain *BlockChain
Blocks []*Block Blocks []*Block
@ -49,8 +50,8 @@ func (tm *TestManager) StateManager() *StateManager {
return tm.stateManager return tm.stateManager
} }
func (tm *TestManager) Reactor() *ethreact.ReactorEngine { func (tm *TestManager) EventMux() *event.TypeMux {
return tm.reactor return tm.eventMux
} }
func (tm *TestManager) Broadcast(msgType ethwire.MsgType, data []interface{}) { func (tm *TestManager) Broadcast(msgType ethwire.MsgType, data []interface{}) {
fmt.Println("Broadcast not implemented") fmt.Println("Broadcast not implemented")
@ -63,7 +64,10 @@ func (tm *TestManager) KeyManager() *ethcrypto.KeyManager {
return nil return nil
} }
func (tm *TestManager) Db() ethutil.Database { return nil } func (tm *TestManager) Db() ethutil.Database {
return tm.db
}
func NewTestManager() *TestManager { func NewTestManager() *TestManager {
ethutil.ReadConfig(".ethtest", "/tmp/ethtest", "ETH") ethutil.ReadConfig(".ethtest", "/tmp/ethtest", "ETH")
@ -75,8 +79,8 @@ func NewTestManager() *TestManager {
ethutil.Config.Db = db ethutil.Config.Db = db
testManager := &TestManager{} testManager := &TestManager{}
testManager.reactor = ethreact.New() testManager.eventMux = new(event.TypeMux)
testManager.db = db
testManager.txPool = NewTxPool(testManager) testManager.txPool = NewTxPool(testManager)
testManager.blockChain = NewBlockChain(testManager) testManager.blockChain = NewBlockChain(testManager)
testManager.stateManager = NewStateManager(testManager) testManager.stateManager = NewStateManager(testManager)

View File

@ -59,7 +59,7 @@ type Ethereum struct {
// The block pool // The block pool
blockPool *BlockPool blockPool *BlockPool
// Eventer // Eventer
eventMux *event.TypeMux eventMux event.TypeMux
// Peers // Peers
peers *list.List peers *list.List
// Nonce // Nonce
@ -126,7 +126,6 @@ func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager
isUpToDate: true, isUpToDate: true,
filters: make(map[int]*ethchain.Filter), filters: make(map[int]*ethchain.Filter),
} }
ethereum.eventMux = event.NewTypeMux()
ethereum.blockPool = NewBlockPool(ethereum) ethereum.blockPool = NewBlockPool(ethereum)
ethereum.txPool = ethchain.NewTxPool(ethereum) ethereum.txPool = ethchain.NewTxPool(ethereum)
@ -162,7 +161,7 @@ func (s *Ethereum) BlockPool() *BlockPool {
return s.blockPool return s.blockPool
} }
func (s *Ethereum) EventMux() *event.TypeMux { func (s *Ethereum) EventMux() *event.TypeMux {
return s.eventMux return &s.eventMux
} }
func (self *Ethereum) Db() ethutil.Database { func (self *Ethereum) Db() ethutil.Database {
return self.db return self.db