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