浏览代码

test case for srtp

v2ray 9 年之前
父节点
当前提交
4a7400ef2a
共有 1 个文件被更改,包括 21 次插入0 次删除
  1. 21 0
      transport/internet/authenticators/srtp/srtp_test.go

+ 21 - 0
transport/internet/authenticators/srtp/srtp_test.go

@@ -0,0 +1,21 @@
+package srtp_test
+
+import (
+	"testing"
+
+	"github.com/v2ray/v2ray-core/common/alloc"
+	"github.com/v2ray/v2ray-core/testing/assert"
+	. "github.com/v2ray/v2ray-core/transport/internet/authenticators/srtp"
+)
+
+func TestSRTPOpenSeal(t *testing.T) {
+	assert := assert.On(t)
+
+	content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
+	payload := alloc.NewLocalBuffer(2048).Clear().Append(content)
+	srtp := ObfuscatorSRTP{}
+	srtp.Seal(payload)
+	assert.Int(payload.Len()).GreaterThan(len(content))
+	assert.Bool(srtp.Open(payload)).IsTrue()
+	assert.Bytes(content).Equals(payload.Bytes())
+}