github.com/intfoundation/intchain@v0.0.0-20220727031208-4316ad31ca73/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 "github.com/intfoundation/intchain/core/rawdb" 22 "github.com/intfoundation/intchain/core/types" 23 "github.com/intfoundation/intchain/event" 24 "github.com/intfoundation/intchain/intdb" 25 ) 26 27 // Implement our EthTest Manager 28 type TestManager struct { 29 // stateManager *StateManager 30 eventMux *event.TypeMux 31 32 db intdb.Database 33 txPool *TxPool 34 blockChain *BlockChain 35 Blocks []*types.Block 36 } 37 38 func (tm *TestManager) IsListening() bool { 39 return false 40 } 41 42 func (tm *TestManager) IsMining() bool { 43 return false 44 } 45 46 func (tm *TestManager) PeerCount() int { 47 return 0 48 } 49 50 func (tm *TestManager) Peers() *list.List { 51 return list.New() 52 } 53 54 func (tm *TestManager) BlockChain() *BlockChain { 55 return tm.blockChain 56 } 57 58 func (tm *TestManager) TxPool() *TxPool { 59 return tm.txPool 60 } 61 62 // func (tm *TestManager) StateManager() *StateManager { 63 // return tm.stateManager 64 // } 65 66 func (tm *TestManager) EventMux() *event.TypeMux { 67 return tm.eventMux 68 } 69 70 // func (tm *TestManager) KeyManager() *crypto.KeyManager { 71 // return nil 72 // } 73 74 func (tm *TestManager) Db() intdb.Database { 75 return tm.db 76 } 77 78 func NewTestManager() *TestManager { 79 //db, err := rawdb.NewMemoryDatabase() 80 //if err != nil { 81 // fmt.Println("Could not create mem-db, failing") 82 // return nil 83 //} 84 85 testManager := &TestManager{} 86 testManager.eventMux = new(event.TypeMux) 87 testManager.db = rawdb.NewMemoryDatabase() 88 // testManager.txPool = NewTxPool(testManager) 89 // testManager.blockChain = NewBlockChain(testManager) 90 // testManager.stateManager = NewStateManager(testManager) 91 92 return testManager 93 }