Skip to content

Commit 8ac1eb3

Browse files
Chain-Foxnibty
authored andcommitted
p2p: add channel buffers to avoid goroutine leaks in tests (ethereum#24929)
1 parent 3e489d3 commit 8ac1eb3

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
@@ -312,7 +312,7 @@ func TestUDPv4_findnodeMultiReply(t *testing.T) {
312312
test.table.db.UpdateLastPingReceived(rid, test.remoteaddr.IP, time.Now())
313313

314314
// queue a pending findnode request
315-
resultc, errc := make(chan []*node), make(chan error)
315+
resultc, errc := make(chan []*node, 1), make(chan error, 1)
316316
go func() {
317317
rid := encodePubkey(&test.remotekey.PublicKey).id()
318318
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
@@ -598,7 +598,7 @@ func TestHTTPSnapshot(t *testing.T) {
598598
network, s := testHTTPServer(t)
599599
defer s.Close()
600600

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

0 commit comments

Comments
 (0)