nameserver_local_test.go 483 B

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