github.com/xtls/xray-core@v1.8.12-0.20240518155711-3168d27b0bdb/app/dns/nameserver_local_test.go (about)

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