p2p: add channel buffers to avoid goroutine leaks in tests (#24929)
This commit is contained in:
parent
220bdd3277
commit
e6d4aedb8c
@ -313,7 +313,7 @@ func TestUDPv4_findnodeMultiReply(t *testing.T) {
|
|||||||
test.table.db.UpdateLastPingReceived(rid, test.remoteaddr.IP, time.Now())
|
test.table.db.UpdateLastPingReceived(rid, test.remoteaddr.IP, time.Now())
|
||||||
|
|
||||||
// queue a pending findnode request
|
// queue a pending findnode request
|
||||||
resultc, errc := make(chan []*node), make(chan error)
|
resultc, errc := make(chan []*node, 1), make(chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
rid := encodePubkey(&test.remotekey.PublicKey).id()
|
rid := encodePubkey(&test.remotekey.PublicKey).id()
|
||||||
ns, err := test.udp.findnode(rid, test.remoteaddr, testTarget)
|
ns, err := test.udp.findnode(rid, test.remoteaddr, testTarget)
|
||||||
|
@ -265,7 +265,7 @@ func TestIteratorEmptyTree(t *testing.T) {
|
|||||||
resolver.add(tree1.ToTXT("n"))
|
resolver.add(tree1.ToTXT("n"))
|
||||||
|
|
||||||
// Start the iterator.
|
// Start the iterator.
|
||||||
node := make(chan *enode.Node)
|
node := make(chan *enode.Node, 1)
|
||||||
it, err := c.NewIterator(url)
|
it, err := c.NewIterator(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -139,7 +139,7 @@ const (
|
|||||||
func (p *pingPongService) Run(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
|
func (p *pingPongService) Run(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
|
||||||
log := p.log.New("peer.id", peer.ID())
|
log := p.log.New("peer.id", peer.ID())
|
||||||
|
|
||||||
errC := make(chan error)
|
errC := make(chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
for range time.Tick(10 * time.Second) {
|
for range time.Tick(10 * time.Second) {
|
||||||
log.Info("sending ping")
|
log.Info("sending ping")
|
||||||
|
@ -596,7 +596,7 @@ func TestHTTPSnapshot(t *testing.T) {
|
|||||||
network, s := testHTTPServer(t)
|
network, s := testHTTPServer(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
var eventsDone = make(chan struct{})
|
var eventsDone = make(chan struct{}, 1)
|
||||||
count := 1
|
count := 1
|
||||||
eventsDoneChan := make(chan *Event)
|
eventsDoneChan := make(chan *Event)
|
||||||
eventSub := network.Events().Subscribe(eventsDoneChan)
|
eventSub := network.Events().Subscribe(eventsDoneChan)
|
||||||
|
Loading…
Reference in New Issue
Block a user