mirror of https://github.com/v2ray/v2ray-core
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.
37 lines
736 B
37 lines
736 B
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)
|
|
}
|