github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/app/dns/nameserver_local_test.go (about)

     1  package dns_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  	"time"
     7  
     8  	. "github.com/v2fly/v2ray-core/v5/app/dns"
     9  	"github.com/v2fly/v2ray-core/v5/common"
    10  	"github.com/v2fly/v2ray-core/v5/common/net"
    11  	"github.com/v2fly/v2ray-core/v5/features/dns"
    12  )
    13  
    14  func TestLocalNameServer(t *testing.T) {
    15  	s := NewLocalNameServer()
    16  	ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
    17  	ips, err := s.QueryIP(ctx, "google.com", net.IP{}, dns.IPOption{
    18  		IPv4Enable: true,
    19  		IPv6Enable: true,
    20  	}, false)
    21  	cancel()
    22  	common.Must(err)
    23  	if len(ips) == 0 {
    24  		t.Error("expect some ips, but got 0")
    25  	}
    26  }