ota_test.go 723 B

12345678910111213141516171819202122
  1. package shadowsocks_test
  2. import (
  3. "testing"
  4. "github.com/v2ray/v2ray-core/common/alloc"
  5. . "github.com/v2ray/v2ray-core/proxy/shadowsocks"
  6. v2testing "github.com/v2ray/v2ray-core/testing"
  7. "github.com/v2ray/v2ray-core/testing/assert"
  8. )
  9. func TestNormalChunkReading(t *testing.T) {
  10. v2testing.Current(t)
  11. buffer := alloc.NewBuffer().Clear().AppendBytes(
  12. 0, 8, 39, 228, 69, 96, 133, 39, 254, 26, 201, 70, 11, 12, 13, 14, 15, 16, 17, 18)
  13. reader := NewChunkReader(buffer, NewAuthenticator(ChunkKeyGenerator(
  14. []byte{21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36})))
  15. payload, err := reader.Read()
  16. assert.Error(err).IsNil()
  17. assert.Bytes(payload.Value).Equals([]byte{11, 12, 13, 14, 15, 16, 17, 18})
  18. }