1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00
v2fly/transport/internet/kcp/crypt_test.go
Darien Raymond 6c9a60100d format code
2017-10-26 21:44:22 +02:00

37 lines
736 B
Go

package kcp_test
import (
"testing"
. "v2ray.com/core/transport/internet/kcp"
. "v2ray.com/ext/assert"
)
func TestSimpleAuthenticator(t *testing.T) {
assert := With(t)
cache := make([]byte, 512)
payload := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
auth := NewSimpleAuthenticator()
b := auth.Seal(cache[:0], nil, payload, nil)
c, err := auth.Open(cache[:0], nil, b, nil)
assert(err, IsNil)
assert(c, Equals, payload)
}
func TestSimpleAuthenticator2(t *testing.T) {
assert := With(t)
cache := make([]byte, 512)
payload := []byte{'a', 'b'}
auth := NewSimpleAuthenticator()
b := auth.Seal(cache[:0], nil, payload, nil)
c, err := auth.Open(cache[:0], nil, b, nil)
assert(err, IsNil)
assert(c, Equals, payload)
}