helper_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. package core
  17. import (
  18. "container/list"
  19. "github.com/ethereum/go-ethereum/core/types"
  20. "github.com/ethereum/go-ethereum/ethdb"
  21. "github.com/ethereum/go-ethereum/event"
  22. )
  23. // Implement our EthTest Manager
  24. type TestManager struct {
  25. // stateManager *StateManager
  26. eventMux *event.TypeMux
  27. db ethdb.Database
  28. txPool *TxPool
  29. blockChain *BlockChain
  30. Blocks []*types.Block
  31. }
  32. func (tm *TestManager) IsListening() bool {
  33. return false
  34. }
  35. func (tm *TestManager) IsMining() bool {
  36. return false
  37. }
  38. func (tm *TestManager) PeerCount() int {
  39. return 0
  40. }
  41. func (tm *TestManager) Peers() *list.List {
  42. return list.New()
  43. }
  44. func (tm *TestManager) BlockChain() *BlockChain {
  45. return tm.blockChain
  46. }
  47. func (tm *TestManager) TxPool() *TxPool {
  48. return tm.txPool
  49. }
  50. // func (tm *TestManager) StateManager() *StateManager {
  51. // return tm.stateManager
  52. // }
  53. func (tm *TestManager) EventMux() *event.TypeMux {
  54. return tm.eventMux
  55. }
  56. // func (tm *TestManager) KeyManager() *crypto.KeyManager {
  57. // return nil
  58. // }
  59. func (tm *TestManager) Db() ethdb.Database {
  60. return tm.db
  61. }
  62. func NewTestManager() *TestManager {
  63. testManager := &TestManager{}
  64. testManager.eventMux = new(event.TypeMux)
  65. testManager.db = ethdb.NewMemDatabase()
  66. // testManager.txPool = NewTxPool(testManager)
  67. // testManager.blockChain = NewBlockChain(testManager)
  68. // testManager.stateManager = NewStateManager(testManager)
  69. return testManager
  70. }