File tree 3 files changed +22
-0
lines changed
3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ import (
25
25
"testing"
26
26
"time"
27
27
28
+ "go.uber.org/goleak"
29
+
28
30
"github.com/ethereum/go-ethereum/crypto/kzg4844"
29
31
"github.com/holiman/uint256"
30
32
@@ -350,3 +352,20 @@ func TestAdjustTimeAfterFork(t *testing.T) {
350
352
t .Errorf ("failed to build block on fork" )
351
353
}
352
354
}
355
+
356
+ func createAndCloseSimBackend () {
357
+ genesisData := types.GenesisAlloc {}
358
+ simulatedBackend := NewBackend (genesisData )
359
+ defer simulatedBackend .Close ()
360
+ }
361
+
362
+ // TestCheckSimBackendGoroutineLeak checks whether creation of a simulated backend leaks go-routines. Any long-lived go-routines
363
+ // spawned by global variables are not considered leaked.
364
+ func TestCheckSimBackendGoroutineLeak (t * testing.T ) {
365
+ createAndCloseSimBackend ()
366
+ ignoreCur := goleak .IgnoreCurrent ()
367
+ // ignore this leveldb function: this go-routine is guaranteed to be terminated 1 second after closing db handle
368
+ ignoreLdb := goleak .IgnoreAnyFunction ("github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain" )
369
+ createAndCloseSimBackend ()
370
+ goleak .VerifyNone (t , ignoreCur , ignoreLdb )
371
+ }
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ require (
63
63
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
64
64
github.com/urfave/cli/v2 v2.27.5
65
65
go.uber.org/automaxprocs v1.5.2
66
+ go.uber.org/goleak v1.3.0
66
67
golang.org/x/crypto v0.32.0
67
68
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
68
69
golang.org/x/sync v0.10.0
Original file line number Diff line number Diff line change @@ -528,6 +528,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
528
528
go.opencensus.io v0.22.4 /go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw =
529
529
go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME =
530
530
go.uber.org/automaxprocs v1.5.2 /go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0 =
531
+ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto =
532
+ go.uber.org/goleak v1.3.0 /go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE =
531
533
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 /go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4 =
532
534
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 /go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w =
533
535
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 /go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI =
You can’t perform that action at this time.
0 commit comments