Compare commits

...

8 Commits

Author SHA1 Message Date
jwasinger b0f56d21f7
Merge 0b2ff286f1 into 07d7fe2b33 2025-02-19 18:48:26 +08:00
Jared Wasinger 0b2ff286f1 go mod tidy 2025-01-27 10:17:00 -08:00
Jared Wasinger 1e30cbb1f4 fix 2025-01-27 05:19:41 -08:00
Jared Wasinger ecb7036cc9 use goleak package 2025-01-27 05:19:39 -08:00
Jared Wasinger 7c39107280 relax leveldb stack-trace regexp to match binaries compiled on all systems 2025-01-27 05:18:13 -08:00
Jared Wasinger 9c2eda3de2 strip trailing newline on go-routines dump 2025-01-27 05:18:13 -08:00
Jared Wasinger 55395c150a ignore false-alarm "leak" from leveldb 2025-01-27 05:18:13 -08:00
Jared Wasinger 6000495a13 ethclient/simulated: add test to check if simulated backend leaks goroutines 2025-01-27 05:18:13 -08:00
3 changed files with 22 additions and 0 deletions

View File

@ -25,6 +25,8 @@ import (
"testing" "testing"
"time" "time"
"go.uber.org/goleak"
"github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/holiman/uint256" "github.com/holiman/uint256"
@ -350,3 +352,20 @@ func TestAdjustTimeAfterFork(t *testing.T) {
t.Errorf("failed to build block on fork") t.Errorf("failed to build block on fork")
} }
} }
func createAndCloseSimBackend() {
genesisData := types.GenesisAlloc{}
simulatedBackend := NewBackend(genesisData)
defer simulatedBackend.Close()
}
// TestCheckSimBackendGoroutineLeak checks whether creation of a simulated backend leaks go-routines. Any long-lived go-routines
// spawned by global variables are not considered leaked.
func TestCheckSimBackendGoroutineLeak(t *testing.T) {
createAndCloseSimBackend()
ignoreCur := goleak.IgnoreCurrent()
// ignore this leveldb function: this go-routine is guaranteed to be terminated 1 second after closing db handle
ignoreLdb := goleak.IgnoreAnyFunction("github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain")
createAndCloseSimBackend()
goleak.VerifyNone(t, ignoreCur, ignoreLdb)
}

1
go.mod
View File

@ -63,6 +63,7 @@ require (
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/urfave/cli/v2 v2.25.7 github.com/urfave/cli/v2 v2.25.7
go.uber.org/automaxprocs v1.5.2 go.uber.org/automaxprocs v1.5.2
go.uber.org/goleak v1.3.0
golang.org/x/crypto v0.32.0 golang.org/x/crypto v0.32.0
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/sync v0.10.0 golang.org/x/sync v0.10.0

2
go.sum
View File

@ -535,6 +535,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME= go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME=
go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=