nameserver_local_test.go 531 B

12345678910111213141516171819202122232425
  1. package dns_test
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. . "github.com/v2fly/v2ray-core/v4/app/dns"
  7. "github.com/v2fly/v2ray-core/v4/common"
  8. "github.com/v2fly/v2ray-core/v4/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. }