helper_test.go 2.3 KB

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