github.com/devfans/go-ethereum@v1.5.10-0.20170326212234-7419d0c38291/core/helper_test.go (about) 1 // Copyright 2014 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package core 18 19 import ( 20 "container/list" 21 "fmt" 22 23 "github.com/ethereum/go-ethereum/core/types" 24 // "github.com/ethereum/go-ethereum/crypto" 25 26 "github.com/ethereum/go-ethereum/ethdb" 27 "github.com/ethereum/go-ethereum/event" 28 ) 29 30 // Implement our EthTest Manager 31 type TestManager struct { 32 // stateManager *StateManager 33 eventMux *event.TypeMux 34 35 db ethdb.Database 36 txPool *TxPool 37 blockChain *BlockChain 38 Blocks []*types.Block 39 } 40 41 func (s *TestManager) IsListening() bool { 42 return false 43 } 44 45 func (s *TestManager) IsMining() bool { 46 return false 47 } 48 49 func (s *TestManager) PeerCount() int { 50 return 0 51 } 52 53 func (s *TestManager) Peers() *list.List { 54 return list.New() 55 } 56 57 func (s *TestManager) BlockChain() *BlockChain { 58 return s.blockChain 59 } 60 61 func (tm *TestManager) TxPool() *TxPool { 62 return tm.txPool 63 } 64 65 // func (tm *TestManager) StateManager() *StateManager { 66 // return tm.stateManager 67 // } 68 69 func (tm *TestManager) EventMux() *event.TypeMux { 70 return tm.eventMux 71 } 72 73 // func (tm *TestManager) KeyManager() *crypto.KeyManager { 74 // return nil 75 // } 76 77 func (tm *TestManager) Db() ethdb.Database { 78 return tm.db 79 } 80 81 func NewTestManager() *TestManager { 82 db, err := ethdb.NewMemDatabase() 83 if err != nil { 84 fmt.Println("Could not create mem-db, failing") 85 return nil 86 } 87 88 testManager := &TestManager{} 89 testManager.eventMux = new(event.TypeMux) 90 testManager.db = db 91 // testManager.txPool = NewTxPool(testManager) 92 // testManager.blockChain = NewBlockChain(testManager) 93 // testManager.stateManager = NewStateManager(testManager) 94 95 return testManager 96 }