2016-08-08 15:23:07 -04:00
|
|
|
package utp_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-08-20 14:55:45 -04:00
|
|
|
"v2ray.com/core/common/alloc"
|
|
|
|
"v2ray.com/core/testing/assert"
|
|
|
|
. "v2ray.com/core/transport/internet/authenticators/utp"
|
2016-08-08 15:23:07 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestUTPOpenSeal(t *testing.T) {
|
|
|
|
assert := assert.On(t)
|
|
|
|
|
|
|
|
content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
|
|
|
|
payload := alloc.NewLocalBuffer(2048).Clear().Append(content)
|
|
|
|
utp := UTP{}
|
|
|
|
utp.Seal(payload)
|
|
|
|
assert.Int(payload.Len()).GreaterThan(len(content))
|
|
|
|
assert.Bool(utp.Open(payload)).IsTrue()
|
|
|
|
assert.Bytes(content).Equals(payload.Bytes())
|
|
|
|
}
|