Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: fix goroutine leaks in unit tests by adding 1-elem channel buffer #20666

Merged
merged 2 commits into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/mclock/simclock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestSimulatedSleep(t *testing.T) {
var (
c Simulated
timeout = 1 * time.Hour
done = make(chan AbsTime)
done = make(chan AbsTime, 1)
)
go func() {
c.Sleep(timeout)
Expand Down
2 changes: 1 addition & 1 deletion eth/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ func TestBroadcastMalformedBlock(t *testing.T) {
malformedEverything.TxHash[0]++

// Keep listening to broadcasts and notify if any arrives
notify := make(chan struct{})
notify := make(chan struct{}, 1)
go func() {
if _, err := sink.app.ReadMsg(); err == nil {
notify <- struct{}{}
Expand Down
4 changes: 2 additions & 2 deletions p2p/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestServerDial(t *testing.T) {
t.Fatalf("could not setup listener: %v", err)
}
defer listener.Close()
accepted := make(chan net.Conn)
accepted := make(chan net.Conn, 1)
go func() {
conn, err := listener.Accept()
if err != nil {
Expand Down Expand Up @@ -670,7 +670,7 @@ func TestServerInboundThrottle(t *testing.T) {
conn.Close()

// Dial again. This time the server should close the connection immediately.
connClosed := make(chan struct{})
connClosed := make(chan struct{}, 1)
conn, err = net.DialTimeout("tcp", srv.ListenAddr, timeout)
if err != nil {
t.Fatalf("could not dial: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion rpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func TestClientSubscribeClose(t *testing.T) {

var (
nc = make(chan int)
errc = make(chan error)
errc = make(chan error, 1)
sub *ClientSubscription
err error
)
Expand Down