nameserver_test.go 466 B

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