1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-09 05:26:39 -04:00
v2fly/proxy/vmess/io/writer_test.go

24 lines
586 B
Go
Raw Normal View History

2016-02-01 06:22:29 -05:00
package io_test
import (
"testing"
"github.com/v2ray/v2ray-core/common/alloc"
. "github.com/v2ray/v2ray-core/proxy/vmess/io"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)
func TestAuthenticate(t *testing.T) {
v2testing.Current(t)
buffer := alloc.NewBuffer().Clear()
buffer.AppendBytes(1, 2, 3, 4)
Authenticate(buffer)
assert.Bytes(buffer.Value).Equals([]byte{0, 8, 87, 52, 168, 125, 1, 2, 3, 4})
b2, err := NewAuthChunkReader(buffer).Read()
assert.Error(err).IsNil()
assert.Bytes(b2.Value).Equals([]byte{1, 2, 3, 4})
}