dns_test.go 703 B

123456789101112131415161718192021222324252627282930
  1. package command_test
  2. import (
  3. "testing"
  4. "github.com/v2ray/v2ray-core/common/alloc"
  5. v2net "github.com/v2ray/v2ray-core/common/net"
  6. netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
  7. . "github.com/v2ray/v2ray-core/proxy/vmess/command"
  8. v2testing "github.com/v2ray/v2ray-core/testing"
  9. "github.com/v2ray/v2ray-core/testing/assert"
  10. )
  11. func TestCacheDnsIPv4(t *testing.T) {
  12. v2testing.Current(t)
  13. cd := &CacheDns{
  14. Address: v2net.IPAddress([]byte{1, 2, 3, 4}),
  15. }
  16. buffer := alloc.NewBuffer().Clear()
  17. defer buffer.Release()
  18. cd.Marshal(buffer)
  19. cd2 := &CacheDns{}
  20. err := cd2.Unmarshal(buffer.Value)
  21. assert.Error(err).IsNil()
  22. netassert.Address(cd.Address).Equals(cd2.Address)
  23. }