writer_test.go 586 B

1234567891011121314151617181920212223
  1. package io_test
  2. import (
  3. "testing"
  4. "github.com/v2ray/v2ray-core/common/alloc"
  5. . "github.com/v2ray/v2ray-core/proxy/vmess/io"
  6. v2testing "github.com/v2ray/v2ray-core/testing"
  7. "github.com/v2ray/v2ray-core/testing/assert"
  8. )
  9. func TestAuthenticate(t *testing.T) {
  10. v2testing.Current(t)
  11. buffer := alloc.NewBuffer().Clear()
  12. buffer.AppendBytes(1, 2, 3, 4)
  13. Authenticate(buffer)
  14. assert.Bytes(buffer.Value).Equals([]byte{0, 8, 87, 52, 168, 125, 1, 2, 3, 4})
  15. b2, err := NewAuthChunkReader(buffer).Read()
  16. assert.Error(err).IsNil()
  17. assert.Bytes(b2.Value).Equals([]byte{1, 2, 3, 4})
  18. }