forked from TrueCloudLab/neoneo-go
network: do not use error channel to start network srv
It's obsolete thing, we have looger and it perfectly suits our needs. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
37f7c9d9a7
commit
55ab38ed81
5 changed files with 8 additions and 20 deletions
|
@ -489,7 +489,7 @@ func startServer(ctx *cli.Context) error {
|
|||
rpcServer := rpcsrv.New(chain, cfg.ApplicationConfiguration.RPC, serv, oracleSrv, log, errChan)
|
||||
serv.AddService(&rpcServer)
|
||||
|
||||
go serv.Start(errChan)
|
||||
go serv.Start()
|
||||
if !cfg.ApplicationConfiguration.RPC.StartWhenSynchronized {
|
||||
rpcServer.Start()
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ func NewTestChain(t *testing.T, f func(*config.Config), run bool) (*core.Blockch
|
|||
})
|
||||
require.NoError(t, err)
|
||||
netSrv.AddConsensusService(cons, cons.OnPayload, cons.OnTransaction)
|
||||
go netSrv.Start(make(chan error, 1))
|
||||
go netSrv.Start()
|
||||
errCh := make(chan error, 2)
|
||||
rpcServer := rpcsrv.New(chain, cfg.ApplicationConfiguration.RPC, netSrv, nil, logger, errCh)
|
||||
rpcServer.Start()
|
||||
|
|
|
@ -265,7 +265,7 @@ func (s *Server) ID() uint32 {
|
|||
|
||||
// Start will start the server and its underlying transport. Calling it twice
|
||||
// is an error.
|
||||
func (s *Server) Start(errChan chan error) {
|
||||
func (s *Server) Start() {
|
||||
s.log.Info("node started",
|
||||
zap.Uint32("blockHeight", s.chain.BlockHeight()),
|
||||
zap.Uint32("headerHeight", s.chain.HeaderHeight()))
|
||||
|
|
|
@ -87,20 +87,11 @@ func TestNewServer(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func startWithChannel(s *Server) chan error {
|
||||
ch := make(chan error)
|
||||
go func() {
|
||||
s.Start(ch)
|
||||
close(ch)
|
||||
}()
|
||||
return ch
|
||||
}
|
||||
|
||||
func TestServerStartAndShutdown(t *testing.T) {
|
||||
t.Run("no consensus", func(t *testing.T) {
|
||||
s := newTestServer(t, ServerConfig{})
|
||||
|
||||
ch := startWithChannel(s)
|
||||
go s.Start()
|
||||
p := newLocalPeer(t, s)
|
||||
s.register <- p
|
||||
require.Eventually(t, func() bool { return 1 == s.PeerCount() }, time.Second, time.Millisecond*10)
|
||||
|
@ -109,7 +100,6 @@ func TestServerStartAndShutdown(t *testing.T) {
|
|||
assert.Nil(t, s.txCallback)
|
||||
|
||||
s.Shutdown()
|
||||
<-ch
|
||||
|
||||
require.True(t, s.transports[0].(*fakeTransp).closed.Load())
|
||||
err, ok := p.droppedWith.Load().(error)
|
||||
|
@ -121,14 +111,13 @@ func TestServerStartAndShutdown(t *testing.T) {
|
|||
cons := new(fakeConsensus)
|
||||
s.AddConsensusService(cons, cons.OnPayload, cons.OnTransaction)
|
||||
|
||||
ch := startWithChannel(s)
|
||||
go s.Start()
|
||||
p := newLocalPeer(t, s)
|
||||
s.register <- p
|
||||
|
||||
assert.True(t, s.services["fake"].(*fakeConsensus).started.Load())
|
||||
|
||||
s.Shutdown()
|
||||
<-ch
|
||||
|
||||
require.True(t, s.services["fake"].(*fakeConsensus).stopped.Load())
|
||||
})
|
||||
|
@ -401,10 +390,9 @@ func startTestServer(t *testing.T, protocolCfg ...func(*config.Blockchain)) *Ser
|
|||
}
|
||||
|
||||
func startWithCleanup(t *testing.T, s *Server) {
|
||||
ch := startWithChannel(s)
|
||||
go s.Start()
|
||||
t.Cleanup(func() {
|
||||
s.Shutdown()
|
||||
<-ch
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ func TestSubscriptions(t *testing.T) {
|
|||
defer chain.Close()
|
||||
defer rpcSrv.Shutdown()
|
||||
|
||||
go rpcSrv.coreServer.Start(make(chan error))
|
||||
go rpcSrv.coreServer.Start()
|
||||
defer rpcSrv.coreServer.Shutdown()
|
||||
|
||||
for _, feed := range subFeeds {
|
||||
|
@ -374,7 +374,7 @@ func TestFilteredNotaryRequestSubscriptions(t *testing.T) {
|
|||
}
|
||||
|
||||
chain, rpcSrv, c, respMsgs, finishedFlag := initCleanServerAndWSClient(t)
|
||||
go rpcSrv.coreServer.Start(make(chan error, 1))
|
||||
go rpcSrv.coreServer.Start()
|
||||
|
||||
defer chain.Close()
|
||||
defer rpcSrv.Shutdown()
|
||||
|
|
Loading…
Reference in a new issue