@ -21,6 +21,7 @@ import (
"fmt"
"net/netip"
"slices"
"sync"
"testing"
"github.com/ethereum/go-ethereum/crypto"
@ -67,7 +68,11 @@ func TestUDPv4_Lookup(t *testing.T) {
func TestUDPv4_LookupIterator ( t * testing . T ) {
t . Parallel ( )
test := newUDPTest ( t )
defer test . close ( )
var wg sync . WaitGroup
defer func ( ) {
test . close ( )
wg . Wait ( )
} ( )
// Seed table with initial nodes.
bootnodes := make ( [ ] * enode . Node , len ( lookupTestnet . dists [ 256 ] ) )
@ -75,7 +80,11 @@ func TestUDPv4_LookupIterator(t *testing.T) {
bootnodes [ i ] = lookupTestnet . node ( 256 , i )
}
fillTable ( test . table , bootnodes , true )
go serveTestnet ( test , lookupTestnet )
wg . Add ( 1 )
go func ( ) {
serveTestnet ( test , lookupTestnet )
wg . Done ( )
} ( )
// Create the iterator and collect the nodes it yields.
iter := test . udp . RandomNodes ( )
@ -102,7 +111,11 @@ func TestUDPv4_LookupIterator(t *testing.T) {
func TestUDPv4_LookupIteratorClose ( t * testing . T ) {
t . Parallel ( )
test := newUDPTest ( t )
defer test . close ( )
var wg sync . WaitGroup
defer func ( ) {
test . close ( )
wg . Wait ( )
} ( )
// Seed table with initial nodes.
bootnodes := make ( [ ] * enode . Node , len ( lookupTestnet . dists [ 256 ] ) )
@ -110,7 +123,12 @@ func TestUDPv4_LookupIteratorClose(t *testing.T) {
bootnodes [ i ] = lookupTestnet . node ( 256 , i )
}
fillTable ( test . table , bootnodes , true )
go serveTestnet ( test , lookupTestnet )
wg . Add ( 1 )
go func ( ) {
serveTestnet ( test , lookupTestnet )
wg . Done ( )
} ( )
it := test . udp . RandomNodes ( )
if ok := it . Next ( ) ; ! ok || it . Node ( ) == nil {