1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-04 09:17:32 -05:00
v2fly/transport/internet/kcp/crypt_test.go
2021-02-17 04:31:50 +08:00

39 lines
814 B
Go

package kcp_test
import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/v2fly/v2ray-core/v4/common"
. "github.com/v2fly/v2ray-core/v4/transport/internet/kcp"
)
func TestSimpleAuthenticator(t *testing.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)
common.Must(err)
if r := cmp.Diff(c, payload); r != "" {
t.Error(r)
}
}
func TestSimpleAuthenticator2(t *testing.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)
common.Must(err)
if r := cmp.Diff(c, payload); r != "" {
t.Error(r)
}
}