mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 13:26:23 +00:00
libs/service: regularize Stop semantics and concurrency primitives (#7809)
This commit is contained in:
@@ -550,7 +550,6 @@ func (n *nodeImpl) OnStart(ctx context.Context) error {
|
||||
// OnStop stops the Node. It implements service.Service.
|
||||
func (n *nodeImpl) OnStop() {
|
||||
n.logger.Info("Stopping Node")
|
||||
|
||||
for _, es := range n.eventSinks {
|
||||
if err := es.Stop(); err != nil {
|
||||
n.logger.Error("failed to stop event sink", "err", err)
|
||||
|
||||
@@ -55,11 +55,10 @@ func TestNodeStartStop(t *testing.T) {
|
||||
n, ok := ns.(*nodeImpl)
|
||||
require.True(t, ok)
|
||||
t.Cleanup(func() {
|
||||
if n.IsRunning() {
|
||||
bcancel()
|
||||
n.Wait()
|
||||
}
|
||||
bcancel()
|
||||
n.Wait()
|
||||
})
|
||||
t.Cleanup(leaktest.CheckTimeout(t, time.Second))
|
||||
|
||||
require.NoError(t, n.Start(ctx))
|
||||
// wait for the node to produce a block
|
||||
@@ -98,6 +97,7 @@ func getTestNode(ctx context.Context, t *testing.T, conf *config.Config, logger
|
||||
ns.Wait()
|
||||
}
|
||||
})
|
||||
|
||||
t.Cleanup(leaktest.CheckTimeout(t, time.Second))
|
||||
|
||||
return n
|
||||
@@ -568,6 +568,7 @@ func TestNodeNewSeedNode(t *testing.T) {
|
||||
logger,
|
||||
)
|
||||
t.Cleanup(ns.Wait)
|
||||
t.Cleanup(leaktest.CheckTimeout(t, time.Second))
|
||||
|
||||
require.NoError(t, err)
|
||||
n, ok := ns.(*seedNodeImpl)
|
||||
|
||||
Reference in New Issue
Block a user