github.com/klaytn/klaytn@v1.12.1/blockchain/helper_test.go (about)

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