dns_test.go 603 B

123456789101112131415161718192021222324
  1. package dns_test
  2. import (
  3. "net"
  4. "testing"
  5. "github.com/v2ray/v2ray-core/app/dns"
  6. apptesting "github.com/v2ray/v2ray-core/app/testing"
  7. netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
  8. v2testing "github.com/v2ray/v2ray-core/testing"
  9. )
  10. func TestDnsAdd(t *testing.T) {
  11. v2testing.Current(t)
  12. domain := "v2ray.com"
  13. cache := dns.NewCache(nil)
  14. ip := cache.Get(&apptesting.Context{}, domain)
  15. netassert.IP(ip).IsNil()
  16. cache.Add(&apptesting.Context{}, domain, []byte{1, 2, 3, 4})
  17. ip = cache.Get(&apptesting.Context{}, domain)
  18. netassert.IP(ip).Equals(net.IP([]byte{1, 2, 3, 4}))
  19. }