You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/proxy/shadowsocks/ota_test.go

38 lines
1.1 KiB

package shadowsocks_test
import (
"testing"
6 years ago
"github.com/google/go-cmp/cmp"
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
. "v2ray.com/core/proxy/shadowsocks"
)
func TestNormalChunkReading(t *testing.T) {
8 years ago
buffer := buf.New()
buffer.Write([]byte{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.ReadMultiBuffer()
6 years ago
common.Must(err)
if diff := cmp.Diff(payload[0].Bytes(), []byte{11, 12, 13, 14, 15, 16, 17, 18}); diff != "" {
t.Error(diff)
}
}
8 years ago
func TestNormalChunkWriting(t *testing.T) {
buffer := buf.New()
8 years ago
writer := NewChunkWriter(buffer, NewAuthenticator(ChunkKeyGenerator(
[]byte{21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36})))
b := buf.New()
b.Write([]byte{11, 12, 13, 14, 15, 16, 17, 18})
common.Must(writer.WriteMultiBuffer(buf.MultiBuffer{b}))
6 years ago
if diff := cmp.Diff(buffer.Bytes(), []byte{0, 8, 39, 228, 69, 96, 133, 39, 254, 26, 201, 70, 11, 12, 13, 14, 15, 16, 17, 18}); diff != "" {
t.Error(diff)
}
8 years ago
}