2016-08-07 03:08:30 -04:00
|
|
|
package srtp_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/srtp"
|
2016-08-07 03:08:30 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSRTPOpenSeal(t *testing.T) {
|
|
|
|
assert := assert.On(t)
|
|
|
|
|
|
|
|
content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
|
2016-12-06 05:03:42 -05:00
|
|
|
payload := alloc.NewLocalBuffer(2048)
|
|
|
|
payload.Append(content)
|
|
|
|
|
2016-08-07 09:05:05 -04:00
|
|
|
srtp := SRTP{}
|
2016-08-07 03:08:30 -04:00
|
|
|
srtp.Seal(payload)
|
|
|
|
assert.Int(payload.Len()).GreaterThan(len(content))
|
|
|
|
assert.Bool(srtp.Open(payload)).IsTrue()
|
|
|
|
assert.Bytes(content).Equals(payload.Bytes())
|
|
|
|
}
|