Skip to content

Commit 2d2417b

Browse files
Chain-Foxblakehhuynh
authored andcommitted
p2p: add channel buffers to avoid goroutine leaks in tests (ethereum#24929)
1 parent 81135ba commit 2d2417b

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

p2p/discover/v4_udp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func TestUDPv4_findnodeMultiReply(t *testing.T) {
313313
test.table.db.UpdateLastPingReceived(rid, test.remoteaddr.IP, time.Now())
314314

315315
// queue a pending findnode request
316-
resultc, errc := make(chan []*node), make(chan error)
316+
resultc, errc := make(chan []*node, 1), make(chan error, 1)
317317
go func() {
318318
rid := encodePubkey(&test.remotekey.PublicKey).id()
319319
ns, err := test.udp.findnode(rid, test.remoteaddr, testTarget)

p2p/dnsdisc/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func TestIteratorEmptyTree(t *testing.T) {
265265
resolver.add(tree1.ToTXT("n"))
266266

267267
// Start the iterator.
268-
node := make(chan *enode.Node)
268+
node := make(chan *enode.Node, 1)
269269
it, err := c.NewIterator(url)
270270
if err != nil {
271271
t.Fatal(err)

p2p/simulations/examples/ping-pong.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const (
139139
func (p *pingPongService) Run(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
140140
log := p.log.New("peer.id", peer.ID())
141141

142-
errC := make(chan error)
142+
errC := make(chan error, 1)
143143
go func() {
144144
for range time.Tick(10 * time.Second) {
145145
log.Info("sending ping")

p2p/simulations/http_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ func TestHTTPSnapshot(t *testing.T) {
596596
network, s := testHTTPServer(t)
597597
defer s.Close()
598598

599-
var eventsDone = make(chan struct{})
599+
var eventsDone = make(chan struct{}, 1)
600600
count := 1
601601
eventsDoneChan := make(chan *Event)
602602
eventSub := network.Events().Subscribe(eventsDoneChan)

0 commit comments

Comments
 (0)