ota_test.go 787 B

123456789101112131415161718192021222324
  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. "github.com/v2ray/v2ray-core/testing/assert"
  7. )
  8. func TestNormalChunkReading(t *testing.T) {
  9. assert := assert.On(t)
  10. buffer := alloc.NewBuffer().Clear().AppendBytes(
  11. 0, 8, 39, 228, 69, 96, 133, 39, 254, 26, 201, 70, 11, 12, 13, 14, 15, 16, 17, 18)
  12. reader := NewChunkReader(buffer, NewAuthenticator(ChunkKeyGenerator(
  13. []byte{21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36})))
  14. payload, err := reader.Read()
  15. assert.Error(err).IsNil()
  16. assert.Bytes(payload.Value).Equals([]byte{11, 12, 13, 14, 15, 16, 17, 18})
  17. payload.PrependBytes(3, 4)
  18. assert.Bytes(payload.Value).Equals([]byte{3, 4, 11, 12, 13, 14, 15, 16, 17, 18})
  19. }