v2ray-core/app/dns/dns_test.go

25 lines
603 B
Go
Raw Normal View History

2015-12-06 11:00:10 +01:00
package dns_test
import (
"net"
"testing"
"github.com/v2ray/v2ray-core/app/dns"
2015-12-10 23:55:39 +01:00
apptesting "github.com/v2ray/v2ray-core/app/testing"
2015-12-06 11:00:10 +01:00
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
v2testing "github.com/v2ray/v2ray-core/testing"
)
func TestDnsAdd(t *testing.T) {
v2testing.Current(t)
domain := "v2ray.com"
2015-12-10 22:08:36 +01:00
cache := dns.NewCache(nil)
2015-12-10 23:55:39 +01:00
ip := cache.Get(&apptesting.Context{}, domain)
2015-12-06 11:00:10 +01:00
netassert.IP(ip).IsNil()
2015-12-10 23:55:39 +01:00
cache.Add(&apptesting.Context{}, domain, []byte{1, 2, 3, 4})
ip = cache.Get(&apptesting.Context{}, domain)
2015-12-06 11:00:10 +01:00
netassert.IP(ip).Equals(net.IP([]byte{1, 2, 3, 4}))
}