[#797] Simplify node.Manager public api and rename it to StatusNode

- [x] [#797] : Remove unused methods PopulateStaticPeers, ReconnectStaticPeers, removeStaticPeers, removePeer
- [x] [#797] : Rename node.Manager to node. StatusNode and simplify its public api
- [x] [#797] : Rename all references to nodeManager to statusNode
This commit is contained in:
Adrià Cidre 2018-04-05 11:45:26 +02:00 committed by Igor Mandrigin
parent 74ce515ab2
commit 359b3621e9
29 changed files with 363 additions and 380 deletions

View File

@ -129,7 +129,7 @@ func main() {
} }
// handle interrupt signals // handle interrupt signals
interruptCh := haltOnInterruptSignal(backend.NodeManager()) interruptCh := haltOnInterruptSignal(backend.StatusNode())
// Check if debugging CLI connection shall be enabled. // Check if debugging CLI connection shall be enabled.
if *cliEnabled { if *cliEnabled {
@ -147,15 +147,15 @@ func main() {
// Run stats server. // Run stats server.
if *statsEnabled { if *statsEnabled {
go startCollectingStats(interruptCh, backend.NodeManager()) go startCollectingStats(interruptCh, backend.StatusNode())
} }
// Sync blockchain and stop. // Sync blockchain and stop.
if *syncAndExit >= 0 { if *syncAndExit >= 0 {
exitCode := syncAndStopNode(interruptCh, backend.NodeManager(), *syncAndExit) exitCode := syncAndStopNode(interruptCh, backend.StatusNode(), *syncAndExit)
// Call was interrupted. Wait for graceful shutdown. // Call was interrupted. Wait for graceful shutdown.
if exitCode == -1 { if exitCode == -1 {
if node, err := backend.NodeManager().Node(); err == nil && node != nil { if node, err := backend.StatusNode().GethNode(); err == nil && node != nil {
node.Wait() node.Wait()
} }
return return
@ -164,7 +164,7 @@ func main() {
os.Exit(exitCode) os.Exit(exitCode)
} }
node, err := backend.NodeManager().Node() node, err := backend.StatusNode().GethNode()
if err != nil { if err != nil {
logger.Error("Getting node failed", "error", err) logger.Error("Getting node failed", "error", err)
return return
@ -182,11 +182,11 @@ func startDebug(backend *api.StatusBackend) error {
} }
// startCollectingStats collects various stats about the node and other protocols like Whisper. // startCollectingStats collects various stats about the node and other protocols like Whisper.
func startCollectingStats(interruptCh <-chan struct{}, nodeManager *node.Manager) { func startCollectingStats(interruptCh <-chan struct{}, statusNode *node.StatusNode) {
logger.Info("Starting stats", "stats", *statsAddr) logger.Info("Starting stats", "stats", *statsAddr)
node, err := nodeManager.Node() node, err := statusNode.GethNode()
if err != nil { if err != nil {
logger.Error("Failed to run metrics because could not get node", "error", err) logger.Error("Failed to run metrics because could not get node", "error", err)
return return
@ -332,7 +332,7 @@ Options:
// haltOnInterruptSignal catches interrupt signal (SIGINT) and // haltOnInterruptSignal catches interrupt signal (SIGINT) and
// stops the node. It times out after 5 seconds // stops the node. It times out after 5 seconds
// if the node can not be stopped. // if the node can not be stopped.
func haltOnInterruptSignal(nodeManager *node.Manager) <-chan struct{} { func haltOnInterruptSignal(statusNode *node.StatusNode) <-chan struct{} {
interruptCh := make(chan struct{}) interruptCh := make(chan struct{})
go func() { go func() {
signalCh := make(chan os.Signal, 1) signalCh := make(chan os.Signal, 1)
@ -341,7 +341,7 @@ func haltOnInterruptSignal(nodeManager *node.Manager) <-chan struct{} {
<-signalCh <-signalCh
close(interruptCh) close(interruptCh)
logger.Info("Got interrupt, shutting down...") logger.Info("Got interrupt, shutting down...")
if err := nodeManager.StopNode(); err != nil { if err := statusNode.Stop(); err != nil {
logger.Error("Failed to stop node", "error", err) logger.Error("Failed to stop node", "error", err)
os.Exit(1) os.Exit(1)
} }

View File

@ -19,7 +19,7 @@ func createContextFromTimeout(timeout int) (context.Context, context.CancelFunc)
// It returns an exit code (`0` if successful or `1` in case of error) // It returns an exit code (`0` if successful or `1` in case of error)
// that can be used in `os.Exit` to exit immediately when the function returns. // that can be used in `os.Exit` to exit immediately when the function returns.
// The special exit code `-1` is used if execution was interrupted. // The special exit code `-1` is used if execution was interrupted.
func syncAndStopNode(interruptCh <-chan struct{}, nodeManager *node.Manager, timeout int) (exitCode int) { func syncAndStopNode(interruptCh <-chan struct{}, statusNode *node.StatusNode, timeout int) (exitCode int) {
logger.Info("syncAndStopNode: node will synchronize the chain and exit", "timeoutInMins", timeout) logger.Info("syncAndStopNode: node will synchronize the chain and exit", "timeoutInMins", timeout)
@ -29,7 +29,7 @@ func syncAndStopNode(interruptCh <-chan struct{}, nodeManager *node.Manager, tim
doneSync := make(chan struct{}) doneSync := make(chan struct{})
errSync := make(chan error) errSync := make(chan error)
go func() { go func() {
if err := nodeManager.EnsureSync(ctx); err != nil { if err := statusNode.EnsureSync(ctx); err != nil {
errSync <- err errSync <- err
} }
close(doneSync) close(doneSync)
@ -46,7 +46,7 @@ func syncAndStopNode(interruptCh <-chan struct{}, nodeManager *node.Manager, tim
return -1 return -1
} }
if err := nodeManager.StopNode(); err != nil { if err := statusNode.Stop(); err != nil {
logger.Error("syncAndStopNode: failed to stop the node", "error", err) logger.Error("syncAndStopNode: failed to stop the node", "error", err)
return 1 return 1
} }

View File

@ -34,9 +34,9 @@ func NewStatusAPIWithBackend(b *StatusBackend) *StatusAPI {
} }
} }
// NodeManager returns reference to node manager // StatusNode returns reference to StatusNode.
func (api *StatusAPI) NodeManager() *node.Manager { func (api *StatusAPI) StatusNode() *node.StatusNode {
return api.b.NodeManager() return api.b.StatusNode()
} }
// AccountManager returns reference to account manager // AccountManager returns reference to account manager

View File

@ -33,7 +33,7 @@ var (
// StatusBackend implements Status.im service // StatusBackend implements Status.im service
type StatusBackend struct { type StatusBackend struct {
mu sync.Mutex mu sync.Mutex
nodeManager *node.Manager statusNode *node.StatusNode
accountManager *account.Manager accountManager *account.Manager
txQueueManager *transactions.Manager txQueueManager *transactions.Manager
jailManager jail.Manager jailManager jail.Manager
@ -46,14 +46,14 @@ type StatusBackend struct {
func NewStatusBackend() *StatusBackend { func NewStatusBackend() *StatusBackend {
defer log.Info("Status backend initialized") defer log.Info("Status backend initialized")
nodeManager := node.NewManager() statusNode := node.New()
accountManager := account.NewManager(nodeManager) accountManager := account.NewManager(statusNode)
txQueueManager := transactions.NewManager(nodeManager) txQueueManager := transactions.NewManager(statusNode)
jailManager := jail.New(nodeManager) jailManager := jail.New(statusNode)
notificationManager := fcm.NewNotification(fcmServerKey) notificationManager := fcm.NewNotification(fcmServerKey)
return &StatusBackend{ return &StatusBackend{
nodeManager: nodeManager, statusNode: statusNode,
accountManager: accountManager, accountManager: accountManager,
jailManager: jailManager, jailManager: jailManager,
txQueueManager: txQueueManager, txQueueManager: txQueueManager,
@ -62,9 +62,9 @@ func NewStatusBackend() *StatusBackend {
} }
} }
// NodeManager returns reference to node manager // StatusNode returns reference to node manager
func (b *StatusBackend) NodeManager() *node.Manager { func (b *StatusBackend) StatusNode() *node.StatusNode {
return b.nodeManager return b.statusNode
} }
// AccountManager returns reference to account manager // AccountManager returns reference to account manager
@ -84,7 +84,7 @@ func (b *StatusBackend) TxQueueManager() *transactions.Manager {
// IsNodeRunning confirm that node is running // IsNodeRunning confirm that node is running
func (b *StatusBackend) IsNodeRunning() bool { func (b *StatusBackend) IsNodeRunning() bool {
return b.nodeManager.IsNodeRunning() return b.statusNode.IsRunning()
} }
// StartNode start Status node, fails if node is already started // StartNode start Status node, fails if node is already started
@ -100,7 +100,7 @@ func (b *StatusBackend) startNode(config *params.NodeConfig) (err error) {
err = fmt.Errorf("node crashed on start: %v", err) err = fmt.Errorf("node crashed on start: %v", err)
} }
}() }()
err = b.nodeManager.StartNode(config) err = b.statusNode.Start(config)
if err != nil { if err != nil {
switch err.(type) { switch err.(type) {
case node.RPCClientError: case node.RPCClientError:
@ -145,7 +145,7 @@ func (b *StatusBackend) stopNode() error {
b.txQueueManager.Stop() b.txQueueManager.Stop()
b.jailManager.Stop() b.jailManager.Stop()
defer signal.Send(signal.Envelope{Type: signal.EventNodeStopped}) defer signal.Send(signal.Envelope{Type: signal.EventNodeStopped})
return b.nodeManager.StopNode() return b.statusNode.Stop()
} }
// RestartNode restart running Status node, fails if node is not running // RestartNode restart running Status node, fails if node is not running
@ -153,7 +153,7 @@ func (b *StatusBackend) RestartNode() error {
if !b.IsNodeRunning() { if !b.IsNodeRunning() {
return node.ErrNoRunningNode return node.ErrNoRunningNode
} }
config, err := b.nodeManager.NodeConfig() config, err := b.statusNode.Config()
if err != nil { if err != nil {
return err return err
} }
@ -169,7 +169,7 @@ func (b *StatusBackend) RestartNode() error {
func (b *StatusBackend) ResetChainData() error { func (b *StatusBackend) ResetChainData() error {
b.mu.Lock() b.mu.Lock()
defer b.mu.Unlock() defer b.mu.Unlock()
config, err := b.nodeManager.NodeConfig() config, err := b.statusNode.Config()
if err != nil { if err != nil {
return err return err
} }
@ -178,7 +178,7 @@ func (b *StatusBackend) ResetChainData() error {
return err return err
} }
// config is cleaned when node is stopped // config is cleaned when node is stopped
if err := b.nodeManager.ResetChainData(&newcfg); err != nil { if err := b.statusNode.ResetChainData(&newcfg); err != nil {
return err return err
} }
signal.Send(signal.Envelope{Type: signal.EventChainDataRemoved}) signal.Send(signal.Envelope{Type: signal.EventChainDataRemoved})
@ -187,7 +187,7 @@ func (b *StatusBackend) ResetChainData() error {
// CallRPC executes RPC request on node's in-proc RPC server // CallRPC executes RPC request on node's in-proc RPC server
func (b *StatusBackend) CallRPC(inputJSON string) string { func (b *StatusBackend) CallRPC(inputJSON string) string {
client := b.nodeManager.RPCClient() client := b.statusNode.RPCClient()
return client.CallRaw(inputJSON) return client.CallRaw(inputJSON)
} }
@ -213,7 +213,7 @@ func (b *StatusBackend) getVerifiedAccount(password string) (*account.SelectedEx
b.log.Error("failed to get a selected account", "err", err) b.log.Error("failed to get a selected account", "err", err)
return nil, err return nil, err
} }
config, err := b.NodeManager().NodeConfig() config, err := b.StatusNode().Config()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -269,7 +269,7 @@ func (b *StatusBackend) DiscardTransactions(ids []string) map[string]error {
// registerHandlers attaches Status callback handlers to running node // registerHandlers attaches Status callback handlers to running node
func (b *StatusBackend) registerHandlers() error { func (b *StatusBackend) registerHandlers() error {
rpcClient := b.NodeManager().RPCClient() rpcClient := b.StatusNode().RPCClient()
if rpcClient == nil { if rpcClient == nil {
return node.ErrRPCClient return node.ErrRPCClient
} }
@ -299,7 +299,7 @@ func (b *StatusBackend) AppStateChange(state AppState) {
// Logout clears whisper identities. // Logout clears whisper identities.
func (b *StatusBackend) Logout() error { func (b *StatusBackend) Logout() error {
whisperService, err := b.nodeManager.WhisperService() whisperService, err := b.statusNode.WhisperService()
if err != nil { if err != nil {
return err return err
} }
@ -317,7 +317,7 @@ func (b *StatusBackend) ReSelectAccount() error {
if selectedAccount == nil || err == account.ErrNoAccountSelected { if selectedAccount == nil || err == account.ErrNoAccountSelected {
return nil return nil
} }
whisperService, err := b.nodeManager.WhisperService() whisperService, err := b.statusNode.WhisperService()
if err != nil { if err != nil {
return err return err
} }
@ -341,7 +341,7 @@ func (b *StatusBackend) SelectAccount(address, password string) error {
return err return err
} }
whisperService, err := b.nodeManager.WhisperService() whisperService, err := b.statusNode.WhisperService()
if err != nil { if err != nil {
return err return err
} }

View File

@ -9,7 +9,7 @@ import (
// ServiceProvider provides node and required services. // ServiceProvider provides node and required services.
type ServiceProvider interface { type ServiceProvider interface {
Node() (*node.Node, error) GethNode() (*node.Node, error)
WhisperService() (*whisper.Whisper, error) WhisperService() (*whisper.Whisper, error)
} }

View File

@ -80,7 +80,7 @@ func (api *PublicAPI) RequestMessages(_ context.Context, r MessagesRequest) (boo
return false, err return false, err
} }
node, err := api.provider.Node() node, err := api.provider.GethNode()
if err != nil { if err != nil {
return false, err return false, err
} }

View File

@ -43,14 +43,14 @@ func TestRequestMessagesFailures(t *testing.T) {
// invalid MailServer enode address // invalid MailServer enode address
provider.EXPECT().WhisperService().Return(nil, nil) provider.EXPECT().WhisperService().Return(nil, nil)
provider.EXPECT().Node().Return(nil, nil) provider.EXPECT().GethNode().Return(nil, nil)
result, err = api.RequestMessages(context.TODO(), MessagesRequest{MailServerPeer: "invalid-address"}) result, err = api.RequestMessages(context.TODO(), MessagesRequest{MailServerPeer: "invalid-address"})
require.False(t, result) require.False(t, result)
require.EqualError(t, err, "invalid mailServerPeer value: invalid URL scheme, want \"enode\"") require.EqualError(t, err, "invalid mailServerPeer value: invalid URL scheme, want \"enode\"")
// non-existent symmetric key // non-existent symmetric key
provider.EXPECT().WhisperService().Return(shh, nil) provider.EXPECT().WhisperService().Return(shh, nil)
provider.EXPECT().Node().Return(nil, nil) provider.EXPECT().GethNode().Return(nil, nil)
result, err = api.RequestMessages(context.TODO(), MessagesRequest{ result, err = api.RequestMessages(context.TODO(), MessagesRequest{
MailServerPeer: mailServerPeer, MailServerPeer: mailServerPeer,
}) })
@ -61,7 +61,7 @@ func TestRequestMessagesFailures(t *testing.T) {
symKeyID, symKeyErr := shh.AddSymKeyFromPassword("some-pass") symKeyID, symKeyErr := shh.AddSymKeyFromPassword("some-pass")
require.NoError(t, symKeyErr) require.NoError(t, symKeyErr)
provider.EXPECT().WhisperService().Return(shh, nil) provider.EXPECT().WhisperService().Return(shh, nil)
provider.EXPECT().Node().Return(nodeA, nil) provider.EXPECT().GethNode().Return(nodeA, nil)
result, err = api.RequestMessages(context.TODO(), MessagesRequest{ result, err = api.RequestMessages(context.TODO(), MessagesRequest{
MailServerPeer: mailServerPeer, MailServerPeer: mailServerPeer,
SymKeyID: symKeyID, SymKeyID: symKeyID,

View File

@ -5,10 +5,11 @@
package mailservice package mailservice
import ( import (
reflect "reflect"
node "github.com/ethereum/go-ethereum/node" node "github.com/ethereum/go-ethereum/node"
whisperv6 "github.com/ethereum/go-ethereum/whisper/whisperv6" whisperv6 "github.com/ethereum/go-ethereum/whisper/whisperv6"
gomock "github.com/golang/mock/gomock" gomock "github.com/golang/mock/gomock"
reflect "reflect"
) )
// MockServiceProvider is a mock of ServiceProvider interface // MockServiceProvider is a mock of ServiceProvider interface
@ -34,17 +35,17 @@ func (m *MockServiceProvider) EXPECT() *MockServiceProviderMockRecorder {
return m.recorder return m.recorder
} }
// Node mocks base method // GethNode mocks base method
func (m *MockServiceProvider) Node() (*node.Node, error) { func (m *MockServiceProvider) GethNode() (*node.Node, error) {
ret := m.ctrl.Call(m, "Node") ret := m.ctrl.Call(m, "GethNode")
ret0, _ := ret[0].(*node.Node) ret0, _ := ret[0].(*node.Node)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// Node indicates an expected call of Node // GethNode indicates an expected call of Node
func (mr *MockServiceProviderMockRecorder) Node() *gomock.Call { func (mr *MockServiceProviderMockRecorder) GethNode() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Node", reflect.TypeOf((*MockServiceProvider)(nil).Node)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GethNode", reflect.TypeOf((*MockServiceProvider)(nil).GethNode))
} }
// WhisperService mocks base method // WhisperService mocks base method

View File

@ -119,8 +119,6 @@ func defaultEmbeddedNodeConfig(config *params.NodeConfig) *node.Config {
} }
if config.ClusterConfig.Enabled { if config.ClusterConfig.Enabled {
// TODO(themue) Should static nodes always be set? Had been done via
// PopulateStaticPeers() before.
nc.P2P.StaticNodes = parseNodes(config.ClusterConfig.StaticNodes) nc.P2P.StaticNodes = parseNodes(config.ClusterConfig.StaticNodes)
nc.P2P.BootstrapNodes = parseNodes(config.ClusterConfig.BootNodes) nc.P2P.BootstrapNodes = parseNodes(config.ClusterConfig.BootNodes)
} }

View File

@ -26,7 +26,7 @@ import (
var ( var (
ErrNodeExists = errors.New("node is already running") ErrNodeExists = errors.New("node is already running")
ErrNoRunningNode = errors.New("there is no running node") ErrNoRunningNode = errors.New("there is no running node")
ErrInvalidNodeManager = errors.New("node manager is not properly initialized") ErrInvalidStatusNode = errors.New("status node is not properly initialized")
ErrInvalidWhisperService = errors.New("whisper service is unavailable") ErrInvalidWhisperService = errors.New("whisper service is unavailable")
ErrInvalidLightEthereumService = errors.New("LES service is unavailable") ErrInvalidLightEthereumService = errors.New("LES service is unavailable")
ErrInvalidAccountManager = errors.New("could not retrieve account manager") ErrInvalidAccountManager = errors.New("could not retrieve account manager")
@ -40,10 +40,9 @@ type RPCClientError error
// EthNodeError is reported when node crashed on start up. // EthNodeError is reported when node crashed on start up.
type EthNodeError error type EthNodeError error
// Manager manages Status node (which abstracts contained geth node) // StatusNode abstracts contained geth node and provides helper methods to
// nolint: golint // interact with it.
// should be fixed at https://github.com/status-im/status-go/issues/200 type StatusNode struct {
type Manager struct {
mu sync.RWMutex mu sync.RWMutex
config *params.NodeConfig // Status node configuration config *params.NodeConfig // Status node configuration
node *node.Node // reference to Geth P2P stack/node node *node.Node // reference to Geth P2P stack/node
@ -54,23 +53,23 @@ type Manager struct {
log log.Logger log log.Logger
} }
// NewManager makes new instance of node manager // New makes new instance of StatusNode.
func NewManager() *Manager { func New() *StatusNode {
return &Manager{ return &StatusNode{
log: log.New("package", "status-go/geth/node.Manager"), log: log.New("package", "status-go/geth/node.StatusNode"),
} }
} }
// StartNode start Status node, fails if node is already started // Start starts current StatusNode, will fail if it's already started.
func (m *Manager) StartNode(config *params.NodeConfig) error { func (n *StatusNode) Start(config *params.NodeConfig) error {
m.mu.Lock() n.mu.Lock()
defer m.mu.Unlock() defer n.mu.Unlock()
return m.startNode(config) return n.start(config)
} }
// startNode start Status node, fails if node is already started // start starts current StatusNode, will fail if it's already started.
func (m *Manager) startNode(config *params.NodeConfig) error { func (n *StatusNode) start(config *params.NodeConfig) error {
if err := m.isNodeAvailable(); err == nil { if err := n.isAvailable(); err == nil {
return ErrNodeExists return ErrNodeExists
} }
@ -78,12 +77,12 @@ func (m *Manager) startNode(config *params.NodeConfig) error {
if err != nil { if err != nil {
return err return err
} }
m.node = ethNode n.node = ethNode
m.config = config n.config = config
// activate MailService required for Offline Inboxing // activate MailService required for Offline Inboxing
if err := ethNode.Register(func(_ *node.ServiceContext) (node.Service, error) { if err := ethNode.Register(func(_ *node.ServiceContext) (node.Service, error) {
return mailservice.New(m), nil return mailservice.New(n), nil
}); err != nil { }); err != nil {
return err return err
} }
@ -93,47 +92,47 @@ func (m *Manager) startNode(config *params.NodeConfig) error {
return EthNodeError(err) return EthNodeError(err)
} }
// init RPC client for this node // init RPC client for this node
localRPCClient, err := m.node.Attach() localRPCClient, err := n.node.Attach()
if err == nil { if err == nil {
m.rpcClient, err = rpc.NewClient(localRPCClient, m.config.UpstreamConfig) n.rpcClient, err = rpc.NewClient(localRPCClient, n.config.UpstreamConfig)
} }
if err != nil { if err != nil {
m.log.Error("Failed to create an RPC client", "error", err) n.log.Error("Failed to create an RPC client", "error", err)
return RPCClientError(err) return RPCClientError(err)
} }
return nil return nil
} }
// StopNode stop Status node. Stopped node cannot be resumed. // Stop will stop current StatusNode. A stopped node cannot be resumed.
func (m *Manager) StopNode() error { func (n *StatusNode) Stop() error {
m.mu.Lock() n.mu.Lock()
defer m.mu.Unlock() defer n.mu.Unlock()
return m.stopNode() return n.stop()
} }
// stopNode stop Status node. Stopped node cannot be resumed. // stop will stop current StatusNode. A stopped node cannot be resumed.
func (m *Manager) stopNode() error { func (n *StatusNode) stop() error {
if err := m.isNodeAvailable(); err != nil { if err := n.isAvailable(); err != nil {
return err return err
} }
if err := m.node.Stop(); err != nil { if err := n.node.Stop(); err != nil {
return err return err
} }
m.node = nil n.node = nil
m.config = nil n.config = nil
m.lesService = nil n.lesService = nil
m.whisperService = nil n.whisperService = nil
m.rpcClient = nil n.rpcClient = nil
return nil return nil
} }
// ResetChainData removes chain data if node is not running. // ResetChainData removes chain data if node is not running.
func (m *Manager) ResetChainData(config *params.NodeConfig) error { func (n *StatusNode) ResetChainData(config *params.NodeConfig) error {
if m.IsNodeRunning() { if n.IsRunning() {
return ErrNodeExists return ErrNodeExists
} }
m.mu.Lock() n.mu.Lock()
defer m.mu.Unlock() defer n.mu.Unlock()
chainDataDir := filepath.Join(config.DataDir, config.Name, "lightchaindata") chainDataDir := filepath.Join(config.DataDir, config.Name, "lightchaindata")
if _, err := os.Stat(chainDataDir); os.IsNotExist(err) { if _, err := os.Stat(chainDataDir); os.IsNotExist(err) {
// is it really an error, if we want to remove it as next step? // is it really an error, if we want to remove it as next step?
@ -141,190 +140,183 @@ func (m *Manager) ResetChainData(config *params.NodeConfig) error {
} }
err := os.RemoveAll(chainDataDir) err := os.RemoveAll(chainDataDir)
if err == nil { if err == nil {
m.log.Info("Chain data has been removed", "dir", chainDataDir) n.log.Info("Chain data has been removed", "dir", chainDataDir)
} }
return err return err
} }
// IsNodeRunning confirm that node is running // IsRunning confirm that node is running.
func (m *Manager) IsNodeRunning() bool { func (n *StatusNode) IsRunning() bool {
m.mu.RLock() n.mu.RLock()
defer m.mu.RUnlock() defer n.mu.RUnlock()
if err := m.isNodeAvailable(); err != nil { if err := n.isAvailable(); err != nil {
return false return false
} }
return true return true
} }
// Node returns underlying Status node // GethNode returns underlying geth node.
func (m *Manager) Node() (*node.Node, error) { func (n *StatusNode) GethNode() (*node.Node, error) {
m.mu.RLock() n.mu.RLock()
defer m.mu.RUnlock() defer n.mu.RUnlock()
if err := m.isNodeAvailable(); err != nil { if err := n.isAvailable(); err != nil {
return nil, err return nil, err
} }
return m.node, nil return n.node, nil
}
// PopulateStaticPeers connects current node with our publicly available LES/SHH/Swarm cluster
func (m *Manager) PopulateStaticPeers() error {
m.mu.RLock()
defer m.mu.RUnlock()
return m.populateStaticPeers()
} }
// populateStaticPeers connects current node with our publicly available LES/SHH/Swarm cluster // populateStaticPeers connects current node with our publicly available LES/SHH/Swarm cluster
func (m *Manager) populateStaticPeers() error { func (n *StatusNode) populateStaticPeers() error {
if err := m.isNodeAvailable(); err != nil { if err := n.isAvailable(); err != nil {
return err return err
} }
if !m.config.ClusterConfig.Enabled { if !n.config.ClusterConfig.Enabled {
m.log.Info("Static peers are disabled") n.log.Info("Static peers are disabled")
return nil return nil
} }
for _, enode := range m.config.ClusterConfig.StaticNodes { for _, enode := range n.config.ClusterConfig.StaticNodes {
err := m.addPeer(enode) err := n.addPeer(enode)
if err != nil { if err != nil {
m.log.Warn("Static peer addition failed", "error", err) n.log.Warn("Static peer addition failed", "error", err)
continue continue
} }
m.log.Info("Static peer added", "enode", enode) n.log.Info("Static peer added", "enode", enode)
} }
return nil return nil
} }
func (m *Manager) removeStaticPeers() error { func (n *StatusNode) removeStaticPeers() error {
if !m.config.ClusterConfig.Enabled { if !n.config.ClusterConfig.Enabled {
m.log.Info("Static peers are disabled") n.log.Info("Static peers are disabled")
return nil return nil
} }
server := m.node.Server() server := n.node.Server()
if server == nil { if server == nil {
return ErrNoRunningNode return ErrNoRunningNode
} }
for _, enode := range m.config.ClusterConfig.StaticNodes { for _, enode := range n.config.ClusterConfig.StaticNodes {
err := m.removePeer(enode) err := n.removePeer(enode)
if err != nil { if err != nil {
m.log.Warn("Static peer deletion failed", "error", err) n.log.Warn("Static peer deletion failed", "error", err)
return err return err
} }
m.log.Info("Static peer deleted", "enode", enode) n.log.Info("Static peer deleted", "enode", enode)
} }
return nil return nil
} }
// ReconnectStaticPeers removes and adds static peers to a server. // ReconnectStaticPeers removes and adds static peers to a server.
func (m *Manager) ReconnectStaticPeers() error { func (n *StatusNode) ReconnectStaticPeers() error {
m.mu.Lock() n.mu.Lock()
defer m.mu.Unlock() defer n.mu.Unlock()
if err := m.removeStaticPeers(); err != nil { if err := n.removeStaticPeers(); err != nil {
return err return err
} }
return m.populateStaticPeers() return n.populateStaticPeers()
} }
// AddPeer adds new static peer node // AddPeer adds new static peer node
func (m *Manager) AddPeer(url string) error { func (n *StatusNode) AddPeer(url string) error {
m.mu.RLock() n.mu.RLock()
defer m.mu.RUnlock() defer n.mu.RUnlock()
if err := m.isNodeAvailable(); err != nil { if err := n.isAvailable(); err != nil {
return err return err
} }
return m.addPeer(url) return n.addPeer(url)
} }
// addPeer adds new static peer node // addPeer adds new static peer node
func (m *Manager) addPeer(url string) error { func (n *StatusNode) addPeer(url string) error {
// Try to add the url as a static peer and return // Try to add the url as a static peer and return
parsedNode, err := discover.ParseNode(url) parsedNode, err := discover.ParseNode(url)
if err != nil { if err != nil {
return err return err
} }
m.node.Server().AddPeer(parsedNode) n.node.Server().AddPeer(parsedNode)
return nil return nil
} }
func (m *Manager) removePeer(url string) error { func (n *StatusNode) removePeer(url string) error {
parsedNode, err := discover.ParseNode(url) parsedNode, err := discover.ParseNode(url)
if err != nil { if err != nil {
return err return err
} }
m.node.Server().RemovePeer(parsedNode) n.node.Server().RemovePeer(parsedNode)
return nil return nil
} }
// PeerCount returns the number of connected peers. // PeerCount returns the number of connected peers.
func (m *Manager) PeerCount() int { func (n *StatusNode) PeerCount() int {
if !m.IsNodeRunning() { if !n.IsRunning() {
return 0 return 0
} }
return m.node.Server().PeerCount() return n.node.Server().PeerCount()
} }
// NodeConfig exposes reference to running node's configuration // Config exposes reference to running node's configuration
func (m *Manager) NodeConfig() (*params.NodeConfig, error) { func (n *StatusNode) Config() (*params.NodeConfig, error) {
m.mu.RLock() n.mu.RLock()
defer m.mu.RUnlock() defer n.mu.RUnlock()
if err := m.isNodeAvailable(); err != nil { if err := n.isAvailable(); err != nil {
return nil, err return nil, err
} }
return m.config, nil return n.config, nil
} }
// LightEthereumService exposes reference to LES service running on top of the node // LightEthereumService exposes reference to LES service running on top of the node
func (m *Manager) LightEthereumService() (*les.LightEthereum, error) { func (n *StatusNode) LightEthereumService() (*les.LightEthereum, error) {
m.mu.RLock() n.mu.RLock()
defer m.mu.RUnlock() defer n.mu.RUnlock()
if err := m.isNodeAvailable(); err != nil { if err := n.isAvailable(); err != nil {
return nil, err return nil, err
} }
if m.lesService == nil { if n.lesService == nil {
if err := m.node.Service(&m.lesService); err != nil { if err := n.node.Service(&n.lesService); err != nil {
m.log.Warn("Cannot obtain LES service", "error", err) n.log.Warn("Cannot obtain LES service", "error", err)
return nil, ErrInvalidLightEthereumService return nil, ErrInvalidLightEthereumService
} }
} }
if m.lesService == nil { if n.lesService == nil {
return nil, ErrInvalidLightEthereumService return nil, ErrInvalidLightEthereumService
} }
return m.lesService, nil return n.lesService, nil
} }
// WhisperService exposes reference to Whisper service running on top of the node // WhisperService exposes reference to Whisper service running on top of the node
func (m *Manager) WhisperService() (*whisper.Whisper, error) { func (n *StatusNode) WhisperService() (*whisper.Whisper, error) {
m.mu.RLock() n.mu.RLock()
defer m.mu.RUnlock() defer n.mu.RUnlock()
if err := m.isNodeAvailable(); err != nil { if err := n.isAvailable(); err != nil {
return nil, err return nil, err
} }
if m.whisperService == nil { if n.whisperService == nil {
if err := m.node.Service(&m.whisperService); err != nil { if err := n.node.Service(&n.whisperService); err != nil {
m.log.Warn("Cannot obtain whisper service", "error", err) n.log.Warn("Cannot obtain whisper service", "error", err)
return nil, ErrInvalidWhisperService return nil, ErrInvalidWhisperService
} }
} }
if m.whisperService == nil { if n.whisperService == nil {
return nil, ErrInvalidWhisperService return nil, ErrInvalidWhisperService
} }
return m.whisperService, nil return n.whisperService, nil
} }
// AccountManager exposes reference to node's accounts manager // AccountManager exposes reference to node's accounts manager
func (m *Manager) AccountManager() (*accounts.Manager, error) { func (n *StatusNode) AccountManager() (*accounts.Manager, error) {
m.mu.RLock() n.mu.RLock()
defer m.mu.RUnlock() defer n.mu.RUnlock()
if err := m.isNodeAvailable(); err != nil { if err := n.isAvailable(); err != nil {
return nil, err return nil, err
} }
accountManager := m.node.AccountManager() accountManager := n.node.AccountManager()
if accountManager == nil { if accountManager == nil {
return nil, ErrInvalidAccountManager return nil, ErrInvalidAccountManager
} }
@ -332,14 +324,14 @@ func (m *Manager) AccountManager() (*accounts.Manager, error) {
} }
// AccountKeyStore exposes reference to accounts key store // AccountKeyStore exposes reference to accounts key store
func (m *Manager) AccountKeyStore() (*keystore.KeyStore, error) { func (n *StatusNode) AccountKeyStore() (*keystore.KeyStore, error) {
m.mu.RLock() n.mu.RLock()
defer m.mu.RUnlock() defer n.mu.RUnlock()
if err := m.isNodeAvailable(); err != nil { if err := n.isAvailable(); err != nil {
return nil, err return nil, err
} }
accountManager := m.node.AccountManager() accountManager := n.node.AccountManager()
if accountManager == nil { if accountManager == nil {
return nil, ErrInvalidAccountManager return nil, ErrInvalidAccountManager
} }
@ -358,15 +350,15 @@ func (m *Manager) AccountKeyStore() (*keystore.KeyStore, error) {
} }
// RPCClient exposes reference to RPC client connected to the running node. // RPCClient exposes reference to RPC client connected to the running node.
func (m *Manager) RPCClient() *rpc.Client { func (n *StatusNode) RPCClient() *rpc.Client {
m.mu.Lock() n.mu.Lock()
defer m.mu.Unlock() defer n.mu.Unlock()
return m.rpcClient return n.rpcClient
} }
// isNodeAvailable check if we have a node running and make sure is fully started // isAvailable check if we have a node running and make sure is fully started
func (m *Manager) isNodeAvailable() error { func (n *StatusNode) isAvailable() error {
if m.node == nil || m.node.Server() == nil { if n.node == nil || n.node.Server() == nil {
return ErrNoRunningNode return ErrNoRunningNode
} }
return nil return nil
@ -377,18 +369,18 @@ const tickerResolution = time.Second
// EnsureSync waits until blockchain synchronization // EnsureSync waits until blockchain synchronization
// is complete and returns. // is complete and returns.
func (m *Manager) EnsureSync(ctx context.Context) error { func (n *StatusNode) EnsureSync(ctx context.Context) error {
// Don't wait for any blockchain sync for the // Don't wait for any blockchain sync for the
// local private chain as blocks are never mined. // local private chain as blocks are never mined.
if m.config.NetworkID == params.StatusChainNetworkID { if n.config.NetworkID == params.StatusChainNetworkID {
return nil return nil
} }
return m.ensureSync(ctx) return n.ensureSync(ctx)
} }
func (m *Manager) ensureSync(ctx context.Context) error { func (n *StatusNode) ensureSync(ctx context.Context) error {
les, err := m.LightEthereumService() les, err := n.LightEthereumService()
if err != nil { if err != nil {
return fmt.Errorf("failed to get LES service: %v", err) return fmt.Errorf("failed to get LES service: %v", err)
} }
@ -399,8 +391,8 @@ func (m *Manager) ensureSync(ctx context.Context) error {
} }
progress := downloader.Progress() progress := downloader.Progress()
if m.PeerCount() > 0 && progress.CurrentBlock >= progress.HighestBlock { if n.PeerCount() > 0 && progress.CurrentBlock >= progress.HighestBlock {
m.log.Debug("Synchronization completed", "current block", progress.CurrentBlock, "highest block", progress.HighestBlock) n.log.Debug("Synchronization completed", "current block", progress.CurrentBlock, "highest block", progress.HighestBlock)
return nil return nil
} }
@ -415,23 +407,23 @@ func (m *Manager) ensureSync(ctx context.Context) error {
case <-ctx.Done(): case <-ctx.Done():
return errors.New("timeout during node synchronization") return errors.New("timeout during node synchronization")
case <-ticker.C: case <-ticker.C:
if m.PeerCount() == 0 { if n.PeerCount() == 0 {
m.log.Debug("No established connections with any peers, continue waiting for a sync") n.log.Debug("No established connections with any peers, continue waiting for a sync")
continue continue
} }
if downloader.Synchronising() { if downloader.Synchronising() {
m.log.Debug("Synchronization is in progress") n.log.Debug("Synchronization is in progress")
continue continue
} }
progress = downloader.Progress() progress = downloader.Progress()
if progress.CurrentBlock >= progress.HighestBlock { if progress.CurrentBlock >= progress.HighestBlock {
m.log.Info("Synchronization completed", "current block", progress.CurrentBlock, "highest block", progress.HighestBlock) n.log.Info("Synchronization completed", "current block", progress.CurrentBlock, "highest block", progress.HighestBlock)
return nil return nil
} }
m.log.Debug("Synchronization is not finished", "current", progress.CurrentBlock, "highest", progress.HighestBlock) n.log.Debug("Synchronization is not finished", "current", progress.CurrentBlock, "highest", progress.HighestBlock)
case <-progressTicker.C: case <-progressTicker.C:
progress = downloader.Progress() progress = downloader.Progress()
m.log.Warn("Synchronization is not finished", "current", progress.CurrentBlock, "highest", progress.HighestBlock) n.log.Warn("Synchronization is not finished", "current", progress.CurrentBlock, "highest", progress.HighestBlock)
} }
} }
} }

View File

@ -445,7 +445,7 @@ func NotifyUsers(message, payloadJSON, tokensArray *C.char) (outCBytes *C.char)
// AddPeer adds an enode as a peer. // AddPeer adds an enode as a peer.
//export AddPeer //export AddPeer
func AddPeer(enode *C.char) *C.char { func AddPeer(enode *C.char) *C.char {
err := statusAPI.NodeManager().AddPeer(C.GoString(enode)) err := statusAPI.StatusNode().AddPeer(C.GoString(enode))
return makeJSONResponse(err) return makeJSONResponse(err)
} }

View File

@ -255,7 +255,7 @@ func testResetChainData(t *testing.T) bool {
return false return false
} }
EnsureNodeSync(statusAPI.NodeManager()) EnsureNodeSync(statusAPI.StatusNode())
testCompleteTransaction(t) testCompleteTransaction(t)
return true return true
@ -267,7 +267,7 @@ func testStopResumeNode(t *testing.T) bool { //nolint: gocyclo
t.Fatal(err) t.Fatal(err)
} }
whisperService, err := statusAPI.NodeManager().WhisperService() whisperService, err := statusAPI.StatusNode().WhisperService()
if err != nil { if err != nil {
t.Errorf("whisper service not running: %v", err) t.Errorf("whisper service not running: %v", err)
} }
@ -354,7 +354,7 @@ func testStopResumeNode(t *testing.T) bool { //nolint: gocyclo
time.Sleep(10 * time.Second) // allow to start (instead of using blocking version of start, of filter event) time.Sleep(10 * time.Second) // allow to start (instead of using blocking version of start, of filter event)
// now, verify that we still have account logged in // now, verify that we still have account logged in
whisperService, err = statusAPI.NodeManager().WhisperService() whisperService, err = statusAPI.StatusNode().WhisperService()
if err != nil { if err != nil {
t.Errorf("whisper service not running: %v", err) t.Errorf("whisper service not running: %v", err)
} }
@ -386,7 +386,7 @@ func testCreateChildAccount(t *testing.T) bool { //nolint: gocyclo
t.Fatal(err) t.Fatal(err)
} }
keyStore, err := statusAPI.NodeManager().AccountKeyStore() keyStore, err := statusAPI.StatusNode().AccountKeyStore()
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return false return false
@ -517,7 +517,7 @@ func testCreateChildAccount(t *testing.T) bool { //nolint: gocyclo
} }
func testRecoverAccount(t *testing.T) bool { //nolint: gocyclo func testRecoverAccount(t *testing.T) bool { //nolint: gocyclo
keyStore, _ := statusAPI.NodeManager().AccountKeyStore() keyStore, _ := statusAPI.StatusNode().AccountKeyStore()
// create an account // create an account
address, pubKey, mnemonic, err := statusAPI.CreateAccount(TestConfig.Account1.Password) address, pubKey, mnemonic, err := statusAPI.CreateAccount(TestConfig.Account1.Password)
@ -608,7 +608,7 @@ func testRecoverAccount(t *testing.T) bool { //nolint: gocyclo
} }
// time to login with recovered data // time to login with recovered data
whisperService, err := statusAPI.NodeManager().WhisperService() whisperService, err := statusAPI.StatusNode().WhisperService()
if err != nil { if err != nil {
t.Errorf("whisper service not running: %v", err) t.Errorf("whisper service not running: %v", err)
} }
@ -631,7 +631,7 @@ func testRecoverAccount(t *testing.T) bool { //nolint: gocyclo
func testAccountSelect(t *testing.T) bool { //nolint: gocyclo func testAccountSelect(t *testing.T) bool { //nolint: gocyclo
// test to see if the account was injected in whisper // test to see if the account was injected in whisper
whisperService, err := statusAPI.NodeManager().WhisperService() whisperService, err := statusAPI.StatusNode().WhisperService()
if err != nil { if err != nil {
t.Errorf("whisper service not running: %v", err) t.Errorf("whisper service not running: %v", err)
} }
@ -714,7 +714,7 @@ func testAccountSelect(t *testing.T) bool { //nolint: gocyclo
} }
func testAccountLogout(t *testing.T) bool { func testAccountLogout(t *testing.T) bool {
whisperService, err := statusAPI.NodeManager().WhisperService() whisperService, err := statusAPI.StatusNode().WhisperService()
if err != nil { if err != nil {
t.Errorf("whisper service not running: %v", err) t.Errorf("whisper service not running: %v", err)
return false return false
@ -771,7 +771,7 @@ func testCompleteTransaction(t *testing.T) bool {
txQueue := txQueueManager.TransactionQueue() txQueue := txQueueManager.TransactionQueue()
txQueue.Reset() txQueue.Reset()
EnsureNodeSync(statusAPI.NodeManager()) EnsureNodeSync(statusAPI.StatusNode())
// log into account from which transactions will be sent // log into account from which transactions will be sent
if err := statusAPI.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password); err != nil { if err := statusAPI.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password); err != nil {
@ -1439,7 +1439,7 @@ func startTestNode(t *testing.T) <-chan struct{} {
// sync // sync
if syncRequired { if syncRequired {
t.Logf("Sync is required") t.Logf("Sync is required")
EnsureNodeSync(statusAPI.NodeManager()) EnsureNodeSync(statusAPI.StatusNode())
} else { } else {
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
} }

View File

@ -57,11 +57,15 @@ func consumeUntil(events <-chan *p2p.PeerEvent, f func(ev *p2p.PeerEvent) bool,
} }
} }
// TestStaticPeersReconnect : it tests how long it takes to reconnect with
// peers after losing connection. This is something we will have to support
// in order for mobile devices to reconnect fast if network connectivity
// is lost for ~30s.
func (s *PeersTestSuite) TestStaticPeersReconnect() { func (s *PeersTestSuite) TestStaticPeersReconnect() {
// both on rinkeby and ropsten we can expect atleast 2 peers connected // both on rinkeby and ropsten we can expect atleast 2 peers connected
expectedPeersCount := 2 expectedPeersCount := 2
events := make(chan *p2p.PeerEvent, 10) events := make(chan *p2p.PeerEvent, 10)
node, err := s.backend.NodeManager().Node() node, err := s.backend.StatusNode().GethNode()
s.Require().NoError(err) s.Require().NoError(err)
subscription := node.Server().SubscribeEvents(events) subscription := node.Server().SubscribeEvents(events)
@ -92,7 +96,7 @@ func (s *PeersTestSuite) TestStaticPeersReconnect() {
s.Require().NoError(s.controller.Disable()) s.Require().NoError(s.controller.Disable())
before = time.Now() before = time.Now()
go func() { go func() {
s.NoError(s.backend.NodeManager().ReconnectStaticPeers()) s.NoError(s.backend.StatusNode().ReconnectStaticPeers())
}() }()
s.Require().NoError(consumeUntil(events, func(ev *p2p.PeerEvent) bool { s.Require().NoError(consumeUntil(events, func(ev *p2p.PeerEvent) bool {
log.Info("tests", "event", ev) log.Info("tests", "event", ev)

View File

@ -76,7 +76,7 @@ func (s *SyncTestSuite) consumeExpectedEvent(subscription *event.TypeMuxSubscrip
} }
func (s *SyncTestSuite) TestSyncChain() { func (s *SyncTestSuite) TestSyncChain() {
les, err := s.backend.NodeManager().LightEthereumService() les, err := s.backend.StatusNode().LightEthereumService()
s.Require().NoError(err) s.Require().NoError(err)
subscription := les.EventMux().Subscribe( subscription := les.EventMux().Subscribe(
downloader.StartEvent{}, downloader.DoneEvent{}, downloader.FailedEvent{}) downloader.StartEvent{}, downloader.DoneEvent{}, downloader.FailedEvent{})

View File

@ -26,7 +26,7 @@ func (s *AccountsTestSuite) TestRPCEthAccounts() {
err := s.Backend.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password) err := s.Backend.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password)
s.NoError(err) s.NoError(err)
rpcClient := s.Backend.NodeManager().RPCClient() rpcClient := s.Backend.StatusNode().RPCClient()
s.NotNil(rpcClient) s.NotNil(rpcClient)
expectedResponse := `{"jsonrpc":"2.0","id":1,"result":["` + strings.ToLower(TestConfig.Account1.Address) + `"]}` expectedResponse := `{"jsonrpc":"2.0","id":1,"result":["` + strings.ToLower(TestConfig.Account1.Address) + `"]}`
@ -53,7 +53,7 @@ func (s *AccountsTestSuite) TestRPCEthAccountsWithUpstream() {
err = s.Backend.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password) err = s.Backend.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password)
s.NoError(err) s.NoError(err)
rpcClient := s.Backend.NodeManager().RPCClient() rpcClient := s.Backend.StatusNode().RPCClient()
s.NotNil(rpcClient) s.NotNil(rpcClient)
expectedResponse := `{"jsonrpc":"2.0","id":1,"result":["` + strings.ToLower(TestConfig.Account1.Address) + `"]}` expectedResponse := `{"jsonrpc":"2.0","id":1,"result":["` + strings.ToLower(TestConfig.Account1.Address) + `"]}`

View File

@ -84,7 +84,7 @@ func (s *AccountsTestSuite) TestCreateChildAccount() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
keyStore, err := s.Backend.NodeManager().AccountKeyStore() keyStore, err := s.Backend.StatusNode().AccountKeyStore()
s.NoError(err) s.NoError(err)
s.NotNil(keyStore) s.NotNil(keyStore)
@ -132,7 +132,7 @@ func (s *AccountsTestSuite) TestRecoverAccount() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
keyStore, err := s.Backend.NodeManager().AccountKeyStore() keyStore, err := s.Backend.StatusNode().AccountKeyStore()
s.NoError(err) s.NoError(err)
// create an acc // create an acc
@ -219,7 +219,7 @@ func (s *AccountsTestSuite) TestSelectedAccountOnRestart() {
s.NoError(s.Backend.SelectAccount(address2, TestConfig.Account1.Password)) s.NoError(s.Backend.SelectAccount(address2, TestConfig.Account1.Password))
// stop node (and all of its sub-protocols) // stop node (and all of its sub-protocols)
nodeConfig, err := s.Backend.NodeManager().NodeConfig() nodeConfig, err := s.Backend.StatusNode().Config()
s.NoError(err) s.NoError(err)
preservedNodeConfig := *nodeConfig preservedNodeConfig := *nodeConfig
s.NoError(s.Backend.StopNode()) s.NoError(s.Backend.StopNode())

View File

@ -26,7 +26,7 @@ type APIBackendTestSuite struct {
} }
// FIXME(tiabc): There's also a test with the same name in geth/node/manager_test.go // FIXME(tiabc): There's also a test with the same name in geth/node/manager_test.go
// so this test should only check StatusBackend logic with a mocked version of the underlying NodeManager. // so this test should only check StatusBackend logic with a mocked version of the underlying StatusNode.
func (s *APIBackendTestSuite) TestRaceConditions() { func (s *APIBackendTestSuite) TestRaceConditions() {
require := s.Require() require := s.Require()
require.NotNil(s.Backend) require.NotNil(s.Backend)
@ -69,11 +69,11 @@ func (s *APIBackendTestSuite) TestRaceConditions() {
progress <- struct{}{} progress <- struct{}{}
}, },
func(config *params.NodeConfig) { func(config *params.NodeConfig) {
log.Info("NodeManager()") log.Info("StatusNode()")
instance := s.Backend.NodeManager() instance := s.Backend.StatusNode()
s.NotNil(instance) s.NotNil(instance)
s.IsType(&node.Manager{}, instance) s.IsType(&node.StatusNode{}, instance)
s.T().Logf("NodeManager(), result: %v", instance) s.T().Logf("StatusNode(), result: %v", instance)
progress <- struct{}{} progress <- struct{}{}
}, },
func(config *params.NodeConfig) { func(config *params.NodeConfig) {
@ -188,7 +188,7 @@ func (s *APIBackendTestSuite) TestRaceConditions() {
} }
// FIXME(tiabc): There's also a test with the same name in geth/node/manager_test.go // FIXME(tiabc): There's also a test with the same name in geth/node/manager_test.go
// so this test should only check StatusBackend logic with a mocked version of the underlying NodeManager. // so this test should only check StatusBackend logic with a mocked version of the underlying StatusNode.
func (s *APIBackendTestSuite) TestNetworkSwitching() { func (s *APIBackendTestSuite) TestNetworkSwitching() {
// get Ropsten config // get Ropsten config
nodeConfig, err := MakeTestNodeConfig(GetNetworkID()) nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
@ -198,7 +198,7 @@ func (s *APIBackendTestSuite) TestNetworkSwitching() {
s.NoError(s.Backend.StartNode(nodeConfig)) s.NoError(s.Backend.StartNode(nodeConfig))
s.True(s.Backend.IsNodeRunning()) s.True(s.Backend.IsNodeRunning())
firstHash, err := e2e.FirstBlockHash(s.Backend.NodeManager()) firstHash, err := e2e.FirstBlockHash(s.Backend.StatusNode())
s.NoError(err) s.NoError(err)
s.Equal(GetHeadHash(), firstHash) s.Equal(GetHeadHash(), firstHash)
@ -214,7 +214,7 @@ func (s *APIBackendTestSuite) TestNetworkSwitching() {
s.True(s.Backend.IsNodeRunning()) s.True(s.Backend.IsNodeRunning())
// make sure we are on another network indeed // make sure we are on another network indeed
firstHash, err = e2e.FirstBlockHash(s.Backend.NodeManager()) firstHash, err = e2e.FirstBlockHash(s.Backend.StatusNode())
s.NoError(err) s.NoError(err)
s.Equal(GetHeadHash(), firstHash) s.Equal(GetHeadHash(), firstHash)
@ -234,20 +234,20 @@ func (s *APIBackendTestSuite) TestResetChainData() {
s.StartTestBackend(e2e.WithDataDir(path)) s.StartTestBackend(e2e.WithDataDir(path))
defer s.StopTestBackend() defer s.StopTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
require.NoError(s.Backend.ResetChainData()) require.NoError(s.Backend.ResetChainData())
s.True(s.Backend.IsNodeRunning()) // new node, with previous config should be running s.True(s.Backend.IsNodeRunning()) // new node, with previous config should be running
// make sure we can read the first byte, and it is valid (for Rinkeby) // make sure we can read the first byte, and it is valid (for Rinkeby)
firstHash, err := e2e.FirstBlockHash(s.Backend.NodeManager()) firstHash, err := e2e.FirstBlockHash(s.Backend.StatusNode())
s.NoError(err) s.NoError(err)
s.Equal(GetHeadHash(), firstHash) s.Equal(GetHeadHash(), firstHash)
} }
// FIXME(tiabc): There's also a test with the same name in geth/node/manager_test.go // FIXME(tiabc): There's also a test with the same name in geth/node/manager_test.go
// so this test should only check StatusBackend logic with a mocked version of the underlying NodeManager. // so this test should only check StatusBackend logic with a mocked version of the underlying StatusNode.
func (s *APIBackendTestSuite) TestRestartNode() { func (s *APIBackendTestSuite) TestRestartNode() {
require := s.Require() require := s.Require()
require.NotNil(s.Backend) require.NotNil(s.Backend)
@ -260,7 +260,7 @@ func (s *APIBackendTestSuite) TestRestartNode() {
s.NoError(s.Backend.StartNode(nodeConfig)) s.NoError(s.Backend.StartNode(nodeConfig))
s.True(s.Backend.IsNodeRunning()) s.True(s.Backend.IsNodeRunning())
firstHash, err := e2e.FirstBlockHash(s.Backend.NodeManager()) firstHash, err := e2e.FirstBlockHash(s.Backend.StatusNode())
s.NoError(err) s.NoError(err)
s.Equal(GetHeadHash(), firstHash) s.Equal(GetHeadHash(), firstHash)
@ -269,7 +269,7 @@ func (s *APIBackendTestSuite) TestRestartNode() {
s.True(s.Backend.IsNodeRunning()) // new node, with previous config should be running s.True(s.Backend.IsNodeRunning()) // new node, with previous config should be running
// make sure we can read the first byte, and it is valid (for Rinkeby) // make sure we can read the first byte, and it is valid (for Rinkeby)
firstHash, err = e2e.FirstBlockHash(s.Backend.NodeManager()) firstHash, err = e2e.FirstBlockHash(s.Backend.StatusNode())
s.NoError(err) s.NoError(err)
s.Equal(GetHeadHash(), firstHash) s.Equal(GetHeadHash(), firstHash)
} }

View File

@ -39,7 +39,7 @@ func (s *JailRPCTestSuite) TestJailRPCSend() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
// load Status JS and add test command to it // load Status JS and add test command to it
s.jail.SetBaseJS(baseStatusJSCode) s.jail.SetBaseJS(baseStatusJSCode)
@ -97,7 +97,7 @@ func (s *JailRPCTestSuite) TestRegressionGetTransactionReceipt() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
rpcClient := s.Backend.NodeManager().RPCClient() rpcClient := s.Backend.StatusNode().RPCClient()
s.NotNil(rpcClient) s.NotNil(rpcClient)
// note: transaction hash is assumed to be invalid // note: transaction hash is assumed to be invalid
@ -110,7 +110,7 @@ func (s *JailRPCTestSuite) TestContractDeployment() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
// obtain VM for a given chat (to send custom JS to jailed version of Send()) // obtain VM for a given chat (to send custom JS to jailed version of Send())
s.jail.CreateAndInitCell(testChatID) s.jail.CreateAndInitCell(testChatID)
@ -193,7 +193,7 @@ func (s *JailRPCTestSuite) TestJailVMPersistence() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
// log into account from which transactions will be sent // log into account from which transactions will be sent
err := s.Backend.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password) err := s.Backend.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password)

View File

@ -31,13 +31,13 @@ func TestJailTestSuite(t *testing.T) {
} }
type JailTestSuite struct { type JailTestSuite struct {
e2e.NodeManagerTestSuite e2e.StatusNodeTestSuite
Jail jail.Manager Jail jail.Manager
} }
func (s *JailTestSuite) SetupTest() { func (s *JailTestSuite) SetupTest() {
s.NodeManager = node.NewManager() s.StatusNode = node.New()
s.Jail = jail.New(s.NodeManager) s.Jail = jail.New(s.StatusNode)
} }
func (s *JailTestSuite) TearDownTest() { func (s *JailTestSuite) TearDownTest() {

View File

@ -23,11 +23,11 @@ func TestManagerTestSuite(t *testing.T) {
} }
type ManagerTestSuite struct { type ManagerTestSuite struct {
e2e.NodeManagerTestSuite e2e.StatusNodeTestSuite
} }
func (s *ManagerTestSuite) SetupTest() { func (s *ManagerTestSuite) SetupTest() {
s.NodeManager = node.NewManager() s.StatusNode = node.New()
} }
func (s *ManagerTestSuite) TestReferencesWithoutStartedNode() { func (s *ManagerTestSuite) TestReferencesWithoutStartedNode() {
@ -36,66 +36,59 @@ func (s *ManagerTestSuite) TestReferencesWithoutStartedNode() {
initFn func() (interface{}, error) initFn func() (interface{}, error)
expectedErr error expectedErr error
}{ }{
{
"non-null manager, no running node, PopulateStaticPeers()",
func() (interface{}, error) {
return nil, s.NodeManager.PopulateStaticPeers()
},
node.ErrNoRunningNode,
},
{ {
"non-null manager, no running node, AddPeer()", "non-null manager, no running node, AddPeer()",
func() (interface{}, error) { func() (interface{}, error) {
return nil, s.NodeManager.AddPeer("enode://da3bf389a031f33fb55c9f5f54fde8473912402d27fffaa50efd74c0d0515f3a61daf6d52151f2876b19c15828e6f670352bff432b5ec457652e74755e8c864f@51.15.62.116:30303") return nil, s.StatusNode.AddPeer("enode://da3bf389a031f33fb55c9f5f54fde8473912402d27fffaa50efd74c0d0515f3a61daf6d52151f2876b19c15828e6f670352bff432b5ec457652e74755e8c864f@51.15.62.116:30303")
}, },
node.ErrNoRunningNode, node.ErrNoRunningNode,
}, },
{ {
"non-null manager, no running node, get NodeConfig", "non-null manager, no running node, get NodeConfig",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.NodeConfig() return s.StatusNode.Config()
}, },
node.ErrNoRunningNode, node.ErrNoRunningNode,
}, },
{ {
"non-null manager, no running node, get Node", "non-null manager, no running node, get Node",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.Node() return s.StatusNode.GethNode()
}, },
node.ErrNoRunningNode, node.ErrNoRunningNode,
}, },
{ {
"non-null manager, no running node, get LES", "non-null manager, no running node, get LES",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.LightEthereumService() return s.StatusNode.LightEthereumService()
}, },
node.ErrNoRunningNode, node.ErrNoRunningNode,
}, },
{ {
"non-null manager, no running node, get Whisper", "non-null manager, no running node, get Whisper",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.WhisperService() return s.StatusNode.WhisperService()
}, },
node.ErrNoRunningNode, node.ErrNoRunningNode,
}, },
{ {
"non-null manager, no running node, get AccountManager", "non-null manager, no running node, get AccountManager",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.AccountManager() return s.StatusNode.AccountManager()
}, },
node.ErrNoRunningNode, node.ErrNoRunningNode,
}, },
{ {
"non-null manager, no running node, get AccountKeyStore", "non-null manager, no running node, get AccountKeyStore",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.AccountKeyStore() return s.StatusNode.AccountKeyStore()
}, },
node.ErrNoRunningNode, node.ErrNoRunningNode,
}, },
{ {
"non-null manager, no running node, get RPC Client", "non-null manager, no running node, get RPC Client",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.RPCClient(), nil return s.StatusNode.RPCClient(), nil
}, },
nil, nil,
}, },
@ -123,49 +116,49 @@ func (s *ManagerTestSuite) TestReferencesWithStartedNode() {
{ {
"node is running, get NodeConfig", "node is running, get NodeConfig",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.NodeConfig() return s.StatusNode.Config()
}, },
&params.NodeConfig{}, &params.NodeConfig{},
}, },
{ {
"node is running, get Node", "node is running, get Node",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.Node() return s.StatusNode.GethNode()
}, },
&gethnode.Node{}, &gethnode.Node{},
}, },
{ {
"node is running, get LES", "node is running, get LES",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.LightEthereumService() return s.StatusNode.LightEthereumService()
}, },
&les.LightEthereum{}, &les.LightEthereum{},
}, },
{ {
"node is running, get Whisper", "node is running, get Whisper",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.WhisperService() return s.StatusNode.WhisperService()
}, },
&whisper.Whisper{}, &whisper.Whisper{},
}, },
{ {
"node is running, get AccountManager", "node is running, get AccountManager",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.AccountManager() return s.StatusNode.AccountManager()
}, },
&accounts.Manager{}, &accounts.Manager{},
}, },
{ {
"node is running, get AccountKeyStore", "node is running, get AccountKeyStore",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.AccountKeyStore() return s.StatusNode.AccountKeyStore()
}, },
&keystore.KeyStore{}, &keystore.KeyStore{},
}, },
{ {
"node is running, get RPC Client", "node is running, get RPC Client",
func() (interface{}, error) { func() (interface{}, error) {
return s.NodeManager.RPCClient(), nil return s.StatusNode.RPCClient(), nil
}, },
&rpc.Client{}, &rpc.Client{},
}, },
@ -184,67 +177,67 @@ func (s *ManagerTestSuite) TestNodeStartStop() {
s.NoError(err) s.NoError(err)
// try stopping non-started node // try stopping non-started node
s.False(s.NodeManager.IsNodeRunning()) s.False(s.StatusNode.IsRunning())
time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163 time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163
s.Equal(node.ErrNoRunningNode, s.NodeManager.StopNode()) s.Equal(node.ErrNoRunningNode, s.StatusNode.Stop())
// start node // start node
s.False(s.NodeManager.IsNodeRunning()) s.False(s.StatusNode.IsRunning())
s.NoError(s.NodeManager.StartNode(nodeConfig)) s.NoError(s.StatusNode.Start(nodeConfig))
// wait till node is started // wait till node is started
s.True(s.NodeManager.IsNodeRunning()) s.True(s.StatusNode.IsRunning())
// try starting another node (w/o stopping the previously started node) // try starting another node (w/o stopping the previously started node)
s.Equal(node.ErrNodeExists, s.NodeManager.StartNode(nodeConfig)) s.Equal(node.ErrNodeExists, s.StatusNode.Start(nodeConfig))
// now stop node // now stop node
time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163 time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163
s.NoError(s.NodeManager.StopNode()) s.NoError(s.StatusNode.Stop())
s.False(s.NodeManager.IsNodeRunning()) s.False(s.StatusNode.IsRunning())
// start new node with exactly the same config // start new node with exactly the same config
s.NoError(s.NodeManager.StartNode(nodeConfig)) s.NoError(s.StatusNode.Start(nodeConfig))
s.True(s.NodeManager.IsNodeRunning()) s.True(s.StatusNode.IsRunning())
// finally stop the node // finally stop the node
time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163 time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163
s.NoError(s.NodeManager.StopNode()) s.NoError(s.StatusNode.Stop())
} }
func (s *ManagerTestSuite) TestNetworkSwitching() { func (s *ManagerTestSuite) TestNetworkSwitching() {
// get Ropsten config // get Ropsten config
nodeConfig, err := MakeTestNodeConfig(GetNetworkID()) nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err) s.NoError(err)
s.False(s.NodeManager.IsNodeRunning()) s.False(s.StatusNode.IsRunning())
s.NoError(s.NodeManager.StartNode(nodeConfig)) s.NoError(s.StatusNode.Start(nodeConfig))
// wait till node is started // wait till node is started
s.Require().True(s.NodeManager.IsNodeRunning()) s.Require().True(s.StatusNode.IsRunning())
firstHash, err := e2e.FirstBlockHash(s.NodeManager) firstHash, err := e2e.FirstBlockHash(s.StatusNode)
s.NoError(err) s.NoError(err)
s.Equal(GetHeadHash(), firstHash) s.Equal(GetHeadHash(), firstHash)
// now stop node, and make sure that a new node, on different network can be started // now stop node, and make sure that a new node, on different network can be started
time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163 time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163
s.NoError(s.NodeManager.StopNode()) s.NoError(s.StatusNode.Stop())
s.False(s.NodeManager.IsNodeRunning()) s.False(s.StatusNode.IsRunning())
// start new node with completely different config // start new node with completely different config
nodeConfig, err = MakeTestNodeConfig(params.RinkebyNetworkID) nodeConfig, err = MakeTestNodeConfig(params.RinkebyNetworkID)
s.NoError(err) s.NoError(err)
s.NoError(s.NodeManager.StartNode(nodeConfig)) s.NoError(s.StatusNode.Start(nodeConfig))
s.True(s.NodeManager.IsNodeRunning()) s.True(s.StatusNode.IsRunning())
// make sure we are on another network indeed // make sure we are on another network indeed
firstHash, err = e2e.FirstBlockHash(s.NodeManager) firstHash, err = e2e.FirstBlockHash(s.StatusNode)
s.NoError(err) s.NoError(err)
s.Equal(GetHeadHashFromNetworkID(params.RinkebyNetworkID), firstHash) s.Equal(GetHeadHashFromNetworkID(params.RinkebyNetworkID), firstHash)
time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163 time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163
s.NoError(s.NodeManager.StopNode()) s.NoError(s.StatusNode.Stop())
} }
func (s *ManagerTestSuite) TestStartNodeWithUpstreamEnabled() { func (s *ManagerTestSuite) TestStartWithUpstreamEnabled() {
if GetNetworkID() == params.StatusChainNetworkID { if GetNetworkID() == params.StatusChainNetworkID {
s.T().Skip() s.T().Skip()
} }
@ -258,11 +251,11 @@ func (s *ManagerTestSuite) TestStartNodeWithUpstreamEnabled() {
nodeConfig.UpstreamConfig.Enabled = true nodeConfig.UpstreamConfig.Enabled = true
nodeConfig.UpstreamConfig.URL = networkURL nodeConfig.UpstreamConfig.URL = networkURL
s.NoError(s.NodeManager.StartNode(nodeConfig)) s.NoError(s.StatusNode.Start(nodeConfig))
s.True(s.NodeManager.IsNodeRunning()) s.True(s.StatusNode.IsRunning())
time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163 time.Sleep(100 * time.Millisecond) //https://github.com/status-im/status-go/issues/429#issuecomment-339663163
s.NoError(s.NodeManager.StopNode()) s.NoError(s.StatusNode.Stop())
} }
// TODO(adam): race conditions should be tested with -race flag and unit tests, if possible. // TODO(adam): race conditions should be tested with -race flag and unit tests, if possible.
@ -283,84 +276,79 @@ func (s *ManagerTestSuite) TestStartNodeWithUpstreamEnabled() {
// //
// var funcsToTest = []func(*params.NodeConfig){ // var funcsToTest = []func(*params.NodeConfig){
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// log.Info("StartNode()") // log.Info("Start()")
// _, err := s.NodeManager.StartNode(config) // _, err := s.StatusNode.Start(config)
// s.T().Logf("StartNode() for network: %d, error: %v", config.NetworkID, err) // s.T().Logf("Start() for network: %d, error: %v", config.NetworkID, err)
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// _, err := s.NodeManager.StopNode() // _, err := s.StatusNode.Stop()
// s.T().Logf("StopNode() for network: %d, error: %v", config.NetworkID, err) // s.T().Logf("Stop() for network: %d, error: %v", config.NetworkID, err)
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// log.Info("Node()") // log.Info("Node()")
// _, err := s.NodeManager.Node() // _, err := s.StatusNode.GethNode()
// s.T().Logf("Node(), error: %v", err) // s.T().Logf("Node(), error: %v", err)
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// log.Info("IsNodeRunning()") // log.Info("IsRunning()")
// s.T().Logf("IsNodeRunning(), result: %v", s.NodeManager.IsNodeRunning()) // s.T().Logf("IsRunning(), result: %v", s.StatusNode.IsRunning())
// progress <- struct{}{}
// },
// func(config *params.NodeConfig) {
// log.Info("PopulateStaticPeers()")
// s.T().Logf("PopulateBootNodes(), error: %v", s.NodeManager.PopulateStaticPeers())
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// // TODO(adam): quarantined until it uses a different datadir // // TODO(adam): quarantined until it uses a different datadir
// // as otherwise it wipes out cached blockchain data. // // as otherwise it wipes out cached blockchain data.
// // func(config *params.NodeConfig) { // // func(config *params.NodeConfig) {
// // log.Info("ResetChainData()") // // log.Info("ResetChainData()")
// // _, err := s.NodeManager.ResetChainData() // // _, err := s.StatusNode.ResetChainData()
// // s.T().Logf("ResetChainData(), error: %v", err) // // s.T().Logf("ResetChainData(), error: %v", err)
// // progress <- struct{}{} // // progress <- struct{}{}
// // }, // // },
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// log.Info("RestartNode()") // log.Info("RestartNode()")
// _, err := s.NodeManager.RestartNode() // _, err := s.StatusNode.RestartNode()
// s.T().Logf("RestartNode(), error: %v", err) // s.T().Logf("RestartNode(), error: %v", err)
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// log.Info("NodeConfig()") // log.Info("Config()")
// _, err := s.NodeManager.NodeConfig() // _, err := s.StatusNode.Config()
// s.T().Logf("NodeConfig(), error: %v", err) // s.T().Logf("Config(), error: %v", err)
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// log.Info("LightEthereumService()") // log.Info("LightEthereumService()")
// _, err := s.NodeManager.LightEthereumService() // _, err := s.StatusNode.LightEthereumService()
// s.T().Logf("LightEthereumService(), error: %v", err) // s.T().Logf("LightEthereumService(), error: %v", err)
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// log.Info("WhisperService()") // log.Info("WhisperService()")
// _, err := s.NodeManager.WhisperService() // _, err := s.StatusNode.WhisperService()
// s.T().Logf("WhisperService(), error: %v", err) // s.T().Logf("WhisperService(), error: %v", err)
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// log.Info("AccountManager()") // log.Info("AccountManager()")
// _, err := s.NodeManager.AccountManager() // _, err := s.StatusNode.AccountManager()
// s.T().Logf("AccountManager(), error: %v", err) // s.T().Logf("AccountManager(), error: %v", err)
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// log.Info("AccountKeyStore()") // log.Info("AccountKeyStore()")
// _, err := s.NodeManager.AccountKeyStore() // _, err := s.StatusNode.AccountKeyStore()
// s.T().Logf("AccountKeyStore(), error: %v", err) // s.T().Logf("AccountKeyStore(), error: %v", err)
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// func(config *params.NodeConfig) { // func(config *params.NodeConfig) {
// log.Info("RPCClient()") // log.Info("RPCClient()")
// s.NodeManager.RPCClient() // s.StatusNode.RPCClient()
// progress <- struct{}{} // progress <- struct{}{}
// }, // },
// } // }
// //
// // increase StartNode()/StopNode() population // // increase Start()/Stop() population
// for i := 0; i < 5; i++ { // for i := 0; i < 5; i++ {
// funcsToTest = append(funcsToTest, funcsToTest[0], funcsToTest[1]) // funcsToTest = append(funcsToTest, funcsToTest[0], funcsToTest[1])
// } // }
@ -383,7 +371,7 @@ func (s *ManagerTestSuite) TestStartNodeWithUpstreamEnabled() {
// } // }
// //
// time.Sleep(2 * time.Second) // so that we see some logs // time.Sleep(2 * time.Second) // so that we see some logs
// nodeStopped, _ := s.NodeManager.StopNode() // just in case we have a node running // nodeStopped, _ := s.StatusNode.Stop() // just in case we have a node running
// //
// if nodeStopped != nil { // if nodeStopped != nil {
// <-nodeStopped // <-nodeStopped

View File

@ -11,7 +11,7 @@ import (
) )
type RPCClientTestSuite struct { type RPCClientTestSuite struct {
e2e.NodeManagerTestSuite e2e.StatusNodeTestSuite
} }
func TestRPCClientTestSuite(t *testing.T) { func TestRPCClientTestSuite(t *testing.T) {
@ -19,8 +19,8 @@ func TestRPCClientTestSuite(t *testing.T) {
} }
func (s *RPCClientTestSuite) SetupTest() { func (s *RPCClientTestSuite) SetupTest() {
s.NodeManager = node.NewManager() s.StatusNode = node.New()
s.NotNil(s.NodeManager) s.NotNil(s.StatusNode)
} }
func (s *RPCClientTestSuite) TestNewClient() { func (s *RPCClientTestSuite) TestNewClient() {

View File

@ -22,12 +22,12 @@ func TestRPCTestSuite(t *testing.T) {
} }
type RPCTestSuite struct { type RPCTestSuite struct {
e2e.NodeManagerTestSuite e2e.StatusNodeTestSuite
} }
func (s *RPCTestSuite) SetupTest() { func (s *RPCTestSuite) SetupTest() {
s.NodeManager = node.NewManager() s.StatusNode = node.New()
s.NotNil(s.NodeManager) s.NotNil(s.StatusNode)
} }
func (s *RPCTestSuite) TestCallRPC() { func (s *RPCTestSuite) TestCallRPC() {
@ -51,9 +51,9 @@ func (s *RPCTestSuite) TestCallRPC() {
nodeConfig.UpstreamConfig.URL = networkURL nodeConfig.UpstreamConfig.URL = networkURL
} }
s.NoError(s.NodeManager.StartNode(nodeConfig)) s.NoError(s.StatusNode.Start(nodeConfig))
rpcClient := s.NodeManager.RPCClient() rpcClient := s.StatusNode.RPCClient()
s.NotNil(rpcClient) s.NotNil(rpcClient)
type rpcCall struct { type rpcCall struct {
@ -120,7 +120,7 @@ func (s *RPCTestSuite) TestCallRPC() {
case <-done: case <-done:
} }
s.NoError(s.NodeManager.StopNode()) s.NoError(s.StatusNode.Stop())
} }
} }
@ -129,15 +129,15 @@ func (s *RPCTestSuite) TestCallRawResult() {
nodeConfig, err := MakeTestNodeConfig(GetNetworkID()) nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err) s.NoError(err)
s.NoError(s.NodeManager.StartNode(nodeConfig)) s.NoError(s.StatusNode.Start(nodeConfig))
client := s.NodeManager.RPCClient() client := s.StatusNode.RPCClient()
s.NotNil(client) s.NotNil(client)
jsonResult := client.CallRaw(`{"jsonrpc":"2.0","method":"shh_version","params":[],"id":67}`) jsonResult := client.CallRaw(`{"jsonrpc":"2.0","method":"shh_version","params":[],"id":67}`)
s.Equal(`{"jsonrpc":"2.0","id":67,"result":"6.0"}`, jsonResult) s.Equal(`{"jsonrpc":"2.0","id":67,"result":"6.0"}`, jsonResult)
s.NoError(s.NodeManager.StopNode()) s.NoError(s.StatusNode.Stop())
} }
// TestCallRawResultGetTransactionReceipt checks if returned response // TestCallRawResultGetTransactionReceipt checks if returned response
@ -147,15 +147,15 @@ func (s *RPCTestSuite) TestCallRawResultGetTransactionReceipt() {
nodeConfig, err := MakeTestNodeConfig(GetNetworkID()) nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err) s.NoError(err)
s.NoError(s.NodeManager.StartNode(nodeConfig)) s.NoError(s.StatusNode.Start(nodeConfig))
client := s.NodeManager.RPCClient() client := s.StatusNode.RPCClient()
s.NotNil(client) s.NotNil(client)
jsonResult := client.CallRaw(`{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x0ca0d8f2422f62bea77e24ed17db5711a77fa72064cccbb8e53c53b699cd3b34"],"id":5}`) jsonResult := client.CallRaw(`{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x0ca0d8f2422f62bea77e24ed17db5711a77fa72064cccbb8e53c53b699cd3b34"],"id":5}`)
s.Equal(`{"jsonrpc":"2.0","id":5,"error":{"code":-32000,"message":"unknown transaction"}}`, jsonResult) s.Equal(`{"jsonrpc":"2.0","id":5,"error":{"code":-32000,"message":"unknown transaction"}}`, jsonResult)
s.NoError(s.NodeManager.StopNode()) s.NoError(s.StatusNode.Stop())
} }
// TestCallContextResult checks if result passed to CallContext // TestCallContextResult checks if result passed to CallContext
@ -164,9 +164,9 @@ func (s *RPCTestSuite) TestCallContextResult() {
s.StartTestNode() s.StartTestNode()
defer s.StopTestNode() defer s.StopTestNode()
EnsureNodeSync(s.NodeManager) EnsureNodeSync(s.StatusNode)
client := s.NodeManager.RPCClient() client := s.StatusNode.RPCClient()
s.NotNil(client) s.NotNil(client)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)

View File

@ -14,10 +14,10 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )
// NodeManagerTestSuite defines a test suit with NodeManager. // StatusNodeTestSuite defines a test suite with StatusNode.
type NodeManagerTestSuite struct { type StatusNodeTestSuite struct {
suite.Suite suite.Suite
NodeManager *node.Manager StatusNode *node.StatusNode
} }
// All general log messages in this package should be routed through this logger. // All general log messages in this package should be routed through this logger.
@ -37,9 +37,9 @@ func init() {
} }
} }
// StartTestNode initiazes a NodeManager instances with configuration retrieved // StartTestNode initiazes a StatusNode instances with configuration retrieved
// from the test config. // from the test config.
func (s *NodeManagerTestSuite) StartTestNode(opts ...TestNodeOption) { func (s *StatusNodeTestSuite) StartTestNode(opts ...TestNodeOption) {
nodeConfig, err := MakeTestNodeConfig(GetNetworkID()) nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err) s.NoError(err)
@ -51,17 +51,17 @@ func (s *NodeManagerTestSuite) StartTestNode(opts ...TestNodeOption) {
// import account keys // import account keys
s.NoError(importTestAccounts(nodeConfig.KeyStoreDir)) s.NoError(importTestAccounts(nodeConfig.KeyStoreDir))
s.False(s.NodeManager.IsNodeRunning()) s.False(s.StatusNode.IsRunning())
s.NoError(s.NodeManager.StartNode(nodeConfig)) s.NoError(s.StatusNode.Start(nodeConfig))
s.True(s.NodeManager.IsNodeRunning()) s.True(s.StatusNode.IsRunning())
} }
// StopTestNode attempts to stop initialized NodeManager. // StopTestNode attempts to stop initialized StatusNode.
func (s *NodeManagerTestSuite) StopTestNode() { func (s *StatusNodeTestSuite) StopTestNode() {
s.NotNil(s.NodeManager) s.NotNil(s.StatusNode)
s.True(s.NodeManager.IsNodeRunning()) s.True(s.StatusNode.IsRunning())
s.NoError(s.NodeManager.StopNode()) s.NoError(s.StatusNode.Stop())
s.False(s.NodeManager.IsNodeRunning()) s.False(s.StatusNode.IsRunning())
} }
// BackendTestSuite is a test suite with api.StatusBackend initialized // BackendTestSuite is a test suite with api.StatusBackend initialized
@ -117,7 +117,7 @@ func (s *BackendTestSuite) RestartTestNode() {
// WhisperService returns a reference to the Whisper service. // WhisperService returns a reference to the Whisper service.
func (s *BackendTestSuite) WhisperService() *whisper.Whisper { func (s *BackendTestSuite) WhisperService() *whisper.Whisper {
whisperService, err := s.Backend.NodeManager().WhisperService() whisperService, err := s.Backend.StatusNode().WhisperService()
s.NoError(err) s.NoError(err)
s.NotNil(whisperService) s.NotNil(whisperService)
@ -126,7 +126,7 @@ func (s *BackendTestSuite) WhisperService() *whisper.Whisper {
// LightEthereumService returns a reference to the LES service. // LightEthereumService returns a reference to the LES service.
func (s *BackendTestSuite) LightEthereumService() *les.LightEthereum { func (s *BackendTestSuite) LightEthereumService() *les.LightEthereum {
lightEthereum, err := s.Backend.NodeManager().LightEthereumService() lightEthereum, err := s.Backend.StatusNode().LightEthereumService()
s.NoError(err) s.NoError(err)
s.NotNil(lightEthereum) s.NotNil(lightEthereum)

View File

@ -26,10 +26,10 @@ func WithDataDir(path string) TestNodeOption {
} }
} }
// FirstBlockHash validates Attach operation for the NodeManager. // FirstBlockHash validates Attach operation for the StatusNode.
func FirstBlockHash(nodeManager *node.Manager) (string, error) { func FirstBlockHash(statusNode *node.StatusNode) (string, error) {
// obtain RPC client for running node // obtain RPC client for running node
runningNode, err := nodeManager.Node() runningNode, err := statusNode.GethNode()
if err != nil { if err != nil {
return "", err return "", err
} }

View File

@ -37,7 +37,7 @@ func (s *TransactionsTestSuite) TestCallRPCSendTransaction() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
err := s.Backend.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password) err := s.Backend.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password)
s.NoError(err) s.NoError(err)
@ -187,7 +187,7 @@ func (s *TransactionsTestSuite) testSendContractTx(setInputAndDataValue initFunc
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
sampleAddress, _, _, err := s.Backend.AccountManager().CreateAccount(TestConfig.Account1.Password) sampleAddress, _, _, err := s.Backend.AccountManager().CreateAccount(TestConfig.Account1.Password)
s.NoError(err) s.NoError(err)
@ -282,7 +282,7 @@ func (s *TransactionsTestSuite) TestSendEther() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
// create an account // create an account
sampleAddress, _, _, err := s.Backend.AccountManager().CreateAccount(TestConfig.Account1.Password) sampleAddress, _, _, err := s.Backend.AccountManager().CreateAccount(TestConfig.Account1.Password)
@ -419,7 +419,7 @@ func (s *TransactionsTestSuite) TestDoubleCompleteQueuedTransactions() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
// log into account from which transactions will be sent // log into account from which transactions will be sent
s.NoError(s.Backend.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password)) s.NoError(s.Backend.SelectAccount(TestConfig.Account1.Address, TestConfig.Account1.Password))
@ -493,7 +493,7 @@ func (s *TransactionsTestSuite) TestDiscardQueuedTransaction() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
// reset queue // reset queue
s.Backend.TxQueueManager().TransactionQueue().Reset() s.Backend.TxQueueManager().TransactionQueue().Reset()
@ -583,7 +583,7 @@ func (s *TransactionsTestSuite) TestDiscardMultipleQueuedTransactions() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
// reset queue // reset queue
s.Backend.TxQueueManager().TransactionQueue().Reset() s.Backend.TxQueueManager().TransactionQueue().Reset()
@ -780,7 +780,7 @@ func (s *TransactionsTestSuite) TestCompleteMultipleQueuedTransactionsUpstream()
func (s *TransactionsTestSuite) setupLocalNode() { func (s *TransactionsTestSuite) setupLocalNode() {
s.StartTestBackend() s.StartTestBackend()
EnsureNodeSync(s.Backend.NodeManager()) EnsureNodeSync(s.Backend.StatusNode())
} }
func (s *TransactionsTestSuite) setupUpstreamNode() { func (s *TransactionsTestSuite) setupUpstreamNode() {

View File

@ -17,11 +17,11 @@ func TestMailServiceSuite(t *testing.T) {
} }
type MailServiceSuite struct { type MailServiceSuite struct {
e2e.NodeManagerTestSuite e2e.StatusNodeTestSuite
} }
func (s *MailServiceSuite) SetupTest() { func (s *MailServiceSuite) SetupTest() {
s.NodeManager = node.NewManager() s.StatusNode = node.New()
} }
// TestShhRequestMessagesRPCMethodAvailability tests if `shh_requestMessages` is available // TestShhRequestMessagesRPCMethodAvailability tests if `shh_requestMessages` is available
@ -34,7 +34,7 @@ func (s *MailServiceSuite) TestShhRequestMessagesRPCMethodAvailability() {
}) })
defer s.StopTestNode() defer s.StopTestNode()
client := s.NodeManager.RPCClient() client := s.StatusNode.RPCClient()
r.NotNil(client) r.NotNil(client)
// This error means that the method is available through inproc communication // This error means that the method is available through inproc communication

View File

@ -31,23 +31,23 @@ func (s *WhisperMailboxSuite) TestRequestMessageFromMailboxAsync() {
// Start mailbox and status node. // Start mailbox and status node.
mailboxBackend, stop := s.startMailboxBackend() mailboxBackend, stop := s.startMailboxBackend()
defer stop() defer stop()
mailboxNode, err := mailboxBackend.NodeManager().Node() mailboxNode, err := mailboxBackend.StatusNode().GethNode()
s.Require().NoError(err) s.Require().NoError(err)
mailboxEnode := mailboxNode.Server().NodeInfo().Enode mailboxEnode := mailboxNode.Server().NodeInfo().Enode
sender, stop := s.startBackend("sender") sender, stop := s.startBackend("sender")
defer stop() defer stop()
node, err := sender.NodeManager().Node() node, err := sender.StatusNode().GethNode()
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotEqual(mailboxEnode, node.Server().NodeInfo().Enode) s.Require().NotEqual(mailboxEnode, node.Server().NodeInfo().Enode)
err = sender.NodeManager().AddPeer(mailboxEnode) err = sender.StatusNode().AddPeer(mailboxEnode)
s.Require().NoError(err) s.Require().NoError(err)
// Wait async processes on adding peer. // Wait async processes on adding peer.
time.Sleep(time.Second) time.Sleep(time.Second)
senderWhisperService, err := sender.NodeManager().WhisperService() senderWhisperService, err := sender.StatusNode().WhisperService()
s.Require().NoError(err) s.Require().NoError(err)
// Mark mailbox node trusted. // Mark mailbox node trusted.
@ -63,7 +63,7 @@ func (s *WhisperMailboxSuite) TestRequestMessageFromMailboxAsync() {
MailServerKeyID, err := senderWhisperService.AddSymKeyFromPassword(password) MailServerKeyID, err := senderWhisperService.AddSymKeyFromPassword(password)
s.Require().NoError(err) s.Require().NoError(err)
rpcClient := sender.NodeManager().RPCClient() rpcClient := sender.StatusNode().RPCClient()
s.Require().NotNil(rpcClient) s.Require().NotNil(rpcClient)
// Create topic. // Create topic.
@ -138,30 +138,30 @@ func (s *WhisperMailboxSuite) TestRequestMessagesInGroupChat() {
defer stop() defer stop()
// Add mailbox to static peers. // Add mailbox to static peers.
mailboxNode, err := mailboxBackend.NodeManager().Node() mailboxNode, err := mailboxBackend.StatusNode().GethNode()
s.Require().NoError(err) s.Require().NoError(err)
mailboxEnode := mailboxNode.Server().NodeInfo().Enode mailboxEnode := mailboxNode.Server().NodeInfo().Enode
err = aliceBackend.NodeManager().AddPeer(mailboxEnode) err = aliceBackend.StatusNode().AddPeer(mailboxEnode)
s.Require().NoError(err) s.Require().NoError(err)
err = bobBackend.NodeManager().AddPeer(mailboxEnode) err = bobBackend.StatusNode().AddPeer(mailboxEnode)
s.Require().NoError(err) s.Require().NoError(err)
err = charlieBackend.NodeManager().AddPeer(mailboxEnode) err = charlieBackend.StatusNode().AddPeer(mailboxEnode)
s.Require().NoError(err) s.Require().NoError(err)
// Wait async processes on adding peer. // Wait async processes on adding peer.
time.Sleep(time.Second) time.Sleep(time.Second)
// Get whisper service. // Get whisper service.
aliceWhisperService, err := aliceBackend.NodeManager().WhisperService() aliceWhisperService, err := aliceBackend.StatusNode().WhisperService()
s.Require().NoError(err) s.Require().NoError(err)
bobWhisperService, err := bobBackend.NodeManager().WhisperService() bobWhisperService, err := bobBackend.StatusNode().WhisperService()
s.Require().NoError(err) s.Require().NoError(err)
charlieWhisperService, err := charlieBackend.NodeManager().WhisperService() charlieWhisperService, err := charlieBackend.StatusNode().WhisperService()
s.Require().NoError(err) s.Require().NoError(err)
// Get rpc client. // Get rpc client.
aliceRPCClient := aliceBackend.NodeManager().RPCClient() aliceRPCClient := aliceBackend.StatusNode().RPCClient()
bobRPCClient := bobBackend.NodeManager().RPCClient() bobRPCClient := bobBackend.StatusNode().RPCClient()
charlieRPCClient := charlieBackend.NodeManager().RPCClient() charlieRPCClient := charlieBackend.StatusNode().RPCClient()
// Bob and charlie add the mailserver key. // Bob and charlie add the mailserver key.
password := "status-offline-inbox" password := "status-offline-inbox"
@ -286,11 +286,11 @@ func (s *WhisperMailboxSuite) TestSendMessageWithoutSubscription() {
time.Sleep((whisper.DefaultSyncAllowance + 1) * time.Second) time.Sleep((whisper.DefaultSyncAllowance + 1) * time.Second)
// Get whisper service. // Get whisper service.
aliceWhisperService, err := aliceBackend.NodeManager().WhisperService() aliceWhisperService, err := aliceBackend.StatusNode().WhisperService()
s.Require().NoError(err) s.Require().NoError(err)
// Get rpc client. // Get rpc client.
aliceRPCClient := aliceBackend.NodeManager().RPCClient() aliceRPCClient := aliceBackend.StatusNode().RPCClient()
// Generate group chat symkey and topic. // Generate group chat symkey and topic.
groupChatKeyID, err := aliceWhisperService.GenerateSymKey() groupChatKeyID, err := aliceWhisperService.GenerateSymKey()

View File

@ -27,10 +27,10 @@ func (s *WhisperTestSuite) TestWhisperFilterRace() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
whisperService, err := s.Backend.NodeManager().WhisperService() whisperService, err := s.Backend.StatusNode().WhisperService()
s.NoError(err) s.NoError(err)
accountManager := account.NewManager(s.Backend.NodeManager()) accountManager := account.NewManager(s.Backend.StatusNode())
s.NotNil(accountManager) s.NotNil(accountManager)
whisperAPI := whisper.NewPublicWhisperAPI(whisperService) whisperAPI := whisper.NewPublicWhisperAPI(whisperService)
@ -92,7 +92,7 @@ func (s *WhisperTestSuite) TestSelectAccount() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
whisperService, err := s.Backend.NodeManager().WhisperService() whisperService, err := s.Backend.StatusNode().WhisperService()
s.NoError(err) s.NoError(err)
// create an acc // create an acc
@ -116,7 +116,7 @@ func (s *WhisperTestSuite) TestLogout() {
s.StartTestBackend() s.StartTestBackend()
defer s.StopTestBackend() defer s.StopTestBackend()
whisperService, err := s.Backend.NodeManager().WhisperService() whisperService, err := s.Backend.StatusNode().WhisperService()
s.NoError(err) s.NoError(err)
// create an account // create an account
@ -167,7 +167,7 @@ func (s *WhisperTestSuite) TestSelectedAccountOnRestart() {
s.False(whisperService.HasKeyPair(pubKey1), "identity should be removed, but it is still present in whisper") s.False(whisperService.HasKeyPair(pubKey1), "identity should be removed, but it is still present in whisper")
// stop node (and all of its sub-protocols) // stop node (and all of its sub-protocols)
nodeConfig, err := s.Backend.NodeManager().NodeConfig() nodeConfig, err := s.Backend.StatusNode().Config()
s.NoError(err) s.NoError(err)
preservedNodeConfig := *nodeConfig preservedNodeConfig := *nodeConfig
s.NoError(s.Backend.StopNode()) s.NoError(s.Backend.StopNode())

View File

@ -103,7 +103,7 @@ func LoadFromFile(filename string) string {
// of unrelated methods. // of unrelated methods.
type LightEthereumProvider interface { type LightEthereumProvider interface {
// NodeConfig returns reference to running node's configuration // NodeConfig returns reference to running node's configuration
NodeConfig() (*params.NodeConfig, error) Config() (*params.NodeConfig, error)
// LightEthereumService exposes reference to LES service running on top of the node // LightEthereumService exposes reference to LES service running on top of the node
LightEthereumService() (*les.LightEthereum, error) LightEthereumService() (*les.LightEthereum, error)
// PeerCount returns number of connected peers // PeerCount returns number of connected peers
@ -113,7 +113,7 @@ type LightEthereumProvider interface {
// EnsureNodeSync waits until node synchronzation is done to continue // EnsureNodeSync waits until node synchronzation is done to continue
// with tests afterwards. Panics in case of an error or a timeout. // with tests afterwards. Panics in case of an error or a timeout.
func EnsureNodeSync(lesProvider LightEthereumProvider) { func EnsureNodeSync(lesProvider LightEthereumProvider) {
nc, err := lesProvider.NodeConfig() nc, err := lesProvider.Config()
if err != nil { if err != nil {
panic("can't retrieve NodeConfig") panic("can't retrieve NodeConfig")
} }