@@ -47,6 +47,8 @@ func TestNodeLifeCycle(t *testing.T) {
4747 if err != nil {
4848 t .Fatalf ("failed to create protocol stack: %v" , err )
4949 }
50+ defer stack .Close ()
51+
5052 // Ensure that a stopped node can be stopped again
5153 for i := 0 ; i < 3 ; i ++ {
5254 if err := stack .Stop (); err != ErrNodeStopped {
@@ -89,6 +91,8 @@ func TestNodeUsedDataDir(t *testing.T) {
8991 if err != nil {
9092 t .Fatalf ("failed to create original protocol stack: %v" , err )
9193 }
94+ defer original .Close ()
95+
9296 if err := original .Start (); err != nil {
9397 t .Fatalf ("failed to start original protocol stack: %v" , err )
9498 }
@@ -99,6 +103,8 @@ func TestNodeUsedDataDir(t *testing.T) {
99103 if err != nil {
100104 t .Fatalf ("failed to create duplicate protocol stack: %v" , err )
101105 }
106+ defer duplicate .Close ()
107+
102108 if err := duplicate .Start (); err != ErrDatadirUsed {
103109 t .Fatalf ("duplicate datadir failure mismatch: have %v, want %v" , err , ErrDatadirUsed )
104110 }
@@ -110,6 +116,8 @@ func TestServiceRegistry(t *testing.T) {
110116 if err != nil {
111117 t .Fatalf ("failed to create protocol stack: %v" , err )
112118 }
119+ defer stack .Close ()
120+
113121 // Register a batch of unique services and ensure they start successfully
114122 services := []ServiceConstructor {NewNoopServiceA , NewNoopServiceB , NewNoopServiceC }
115123 for i , constructor := range services {
@@ -142,6 +150,8 @@ func TestServiceLifeCycle(t *testing.T) {
142150 if err != nil {
143151 t .Fatalf ("failed to create protocol stack: %v" , err )
144152 }
153+ defer stack .Close ()
154+
145155 // Register a batch of life-cycle instrumented services
146156 services := map [string ]InstrumentingWrapper {
147157 "A" : InstrumentedServiceMakerA ,
@@ -192,6 +202,8 @@ func TestServiceRestarts(t *testing.T) {
192202 if err != nil {
193203 t .Fatalf ("failed to create protocol stack: %v" , err )
194204 }
205+ defer stack .Close ()
206+
195207 // Define a service that does not support restarts
196208 var (
197209 running bool
@@ -240,6 +252,8 @@ func TestServiceConstructionAbortion(t *testing.T) {
240252 if err != nil {
241253 t .Fatalf ("failed to create protocol stack: %v" , err )
242254 }
255+ defer stack .Close ()
256+
243257 // Define a batch of good services
244258 services := map [string ]InstrumentingWrapper {
245259 "A" : InstrumentedServiceMakerA ,
@@ -287,6 +301,8 @@ func TestServiceStartupAbortion(t *testing.T) {
287301 if err != nil {
288302 t .Fatalf ("failed to create protocol stack: %v" , err )
289303 }
304+ defer stack .Close ()
305+
290306 // Register a batch of good services
291307 services := map [string ]InstrumentingWrapper {
292308 "A" : InstrumentedServiceMakerA ,
@@ -340,6 +356,8 @@ func TestServiceTerminationGuarantee(t *testing.T) {
340356 if err != nil {
341357 t .Fatalf ("failed to create protocol stack: %v" , err )
342358 }
359+ defer stack .Close ()
360+
343361 // Register a batch of good services
344362 services := map [string ]InstrumentingWrapper {
345363 "A" : InstrumentedServiceMakerA ,
@@ -415,6 +433,8 @@ func TestServiceRetrieval(t *testing.T) {
415433 if err != nil {
416434 t .Fatalf ("failed to create protocol stack: %v" , err )
417435 }
436+ defer stack .Close ()
437+
418438 if err := stack .Register (NewNoopService ); err != nil {
419439 t .Fatalf ("noop service registration failed: %v" , err )
420440 }
@@ -450,6 +470,8 @@ func TestProtocolGather(t *testing.T) {
450470 if err != nil {
451471 t .Fatalf ("failed to create protocol stack: %v" , err )
452472 }
473+ defer stack .Close ()
474+
453475 // Register a batch of services with some configured number of protocols
454476 services := map [string ]struct {
455477 Count int
@@ -506,6 +528,8 @@ func TestAPIGather(t *testing.T) {
506528 if err != nil {
507529 t .Fatalf ("failed to create protocol stack: %v" , err )
508530 }
531+ defer stack .Close ()
532+
509533 // Register a batch of services with some configured APIs
510534 calls := make (chan string , 1 )
511535 makeAPI := func (result string ) * OneMethodAPI {
0 commit comments