2016-02-05 10:38:45 +00:00
|
|
|
package shadowsocks_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/v2ray/v2ray-core/common/alloc"
|
|
|
|
. "github.com/v2ray/v2ray-core/proxy/shadowsocks"
|
|
|
|
"github.com/v2ray/v2ray-core/testing/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNormalChunkReading(t *testing.T) {
|
2016-05-24 19:55:46 +00:00
|
|
|
assert := assert.On(t)
|
2016-02-05 10:38:45 +00:00
|
|
|
|
|
|
|
buffer := alloc.NewBuffer().Clear().AppendBytes(
|
|
|
|
0, 8, 39, 228, 69, 96, 133, 39, 254, 26, 201, 70, 11, 12, 13, 14, 15, 16, 17, 18)
|
|
|
|
reader := NewChunkReader(buffer, NewAuthenticator(ChunkKeyGenerator(
|
|
|
|
[]byte{21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36})))
|
|
|
|
payload, err := reader.Read()
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
assert.Bytes(payload.Value).Equals([]byte{11, 12, 13, 14, 15, 16, 17, 18})
|
2016-07-13 09:38:14 +00:00
|
|
|
|
|
|
|
payload.PrependBytes(3, 4)
|
|
|
|
assert.Bytes(payload.Value).Equals([]byte{3, 4, 11, 12, 13, 14, 15, 16, 17, 18})
|
2016-02-05 10:38:45 +00:00
|
|
|
}
|