helper_test.go 2.3 KB

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