diff --git a/cli/server/server.go b/cli/server/server.go index bcea6b115..e1b9c5edf 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -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() } diff --git a/internal/testcli/executor.go b/internal/testcli/executor.go index d65823334..20fa01a64 100644 --- a/internal/testcli/executor.go +++ b/internal/testcli/executor.go @@ -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() diff --git a/pkg/network/server.go b/pkg/network/server.go index 0ce3697d5..b6661b2a4 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -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())) diff --git a/pkg/network/server_test.go b/pkg/network/server_test.go index edd1968b1..4b95eee4a 100644 --- a/pkg/network/server_test.go +++ b/pkg/network/server_test.go @@ -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 }) } diff --git a/pkg/services/rpcsrv/subscription_test.go b/pkg/services/rpcsrv/subscription_test.go index 2aece5b6e..ba654a5b3 100644 --- a/pkg/services/rpcsrv/subscription_test.go +++ b/pkg/services/rpcsrv/subscription_test.go @@ -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()