helper_test.go 2.2 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

import (
	"container/list"

22
	"github.com/ethereum/go-ethereum/core/rawdb"
23
	"github.com/ethereum/go-ethereum/core/types"
obscuren's avatar
obscuren committed
24
	"github.com/ethereum/go-ethereum/ethdb"
25
	"github.com/ethereum/go-ethereum/event"
26 27 28 29
)

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

33
	db         ethdb.Database
34
	txPool     *TxPool
35
	blockChain *BlockChain
obscuren's avatar
obscuren committed
36
	Blocks     []*types.Block
37 38
}

39
func (tm *TestManager) IsListening() bool {
40 41 42
	return false
}

43
func (tm *TestManager) IsMining() bool {
44 45 46
	return false
}

47
func (tm *TestManager) PeerCount() int {
48 49 50
	return 0
}

51
func (tm *TestManager) Peers() *list.List {
52 53 54
	return list.New()
}

55 56
func (tm *TestManager) BlockChain() *BlockChain {
	return tm.blockChain
57 58 59 60 61 62
}

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

63 64 65
// func (tm *TestManager) StateManager() *StateManager {
// 	return tm.stateManager
// }
66

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

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

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

79 80
func NewTestManager() *TestManager {
	testManager := &TestManager{}
Felix Lange's avatar
Felix Lange committed
81
	testManager.eventMux = new(event.TypeMux)
82
	testManager.db = rawdb.NewMemoryDatabase()
83
	// testManager.txPool = NewTxPool(testManager)
84
	// testManager.blockChain = NewBlockChain(testManager)
85
	// testManager.stateManager = NewStateManager(testManager)
86 87
	return testManager
}