helper_test.go 2.3 KB
Newer Older
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 6 7 8
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
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 13 14
// GNU Lesser General Public License for more details.
//
// 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

obscuren's avatar
obscuren committed
17
package core
18 19 20 21 22

import (
	"container/list"
	"fmt"

23
	"github.com/ethereum/go-ethereum/core/types"
24
	// "github.com/ethereum/go-ethereum/crypto"
25

obscuren's avatar
obscuren committed
26
	"github.com/ethereum/go-ethereum/ethdb"
27
	"github.com/ethereum/go-ethereum/event"
28 29 30 31
)

// Implement our EthTest Manager
type TestManager struct {
32 33
	// stateManager *StateManager
	eventMux *event.TypeMux
34

35
	db         ethdb.Database
36
	txPool     *TxPool
37
	blockChain *BlockChain
obscuren's avatar
obscuren committed
38
	Blocks     []*types.Block
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
}

func (s *TestManager) IsListening() bool {
	return false
}

func (s *TestManager) IsMining() bool {
	return false
}

func (s *TestManager) PeerCount() int {
	return 0
}

func (s *TestManager) Peers() *list.List {
	return list.New()
}

57
func (s *TestManager) BlockChain() *BlockChain {
58 59 60 61 62 63 64
	return s.blockChain
}

func (tm *TestManager) TxPool() *TxPool {
	return tm.txPool
}

65 66 67
// func (tm *TestManager) StateManager() *StateManager {
// 	return tm.stateManager
// }
68

Felix Lange's avatar
Felix Lange committed
69 70
func (tm *TestManager) EventMux() *event.TypeMux {
	return tm.eventMux
71
}
72 73 74 75

// func (tm *TestManager) KeyManager() *crypto.KeyManager {
// 	return nil
// }
76

77
func (tm *TestManager) Db() ethdb.Database {
Felix Lange's avatar
Felix Lange committed
78 79 80
	return tm.db
}

81 82 83 84 85 86 87 88
func NewTestManager() *TestManager {
	db, err := ethdb.NewMemDatabase()
	if err != nil {
		fmt.Println("Could not create mem-db, failing")
		return nil
	}

	testManager := &TestManager{}
Felix Lange's avatar
Felix Lange committed
89 90
	testManager.eventMux = new(event.TypeMux)
	testManager.db = db
91
	// testManager.txPool = NewTxPool(testManager)
92
	// testManager.blockChain = NewBlockChain(testManager)
93
	// testManager.stateManager = NewStateManager(testManager)
94 95 96

	return testManager
}