From 4a7400ef2a4252d64b2b66241ec08eb23f097ff6 Mon Sep 17 00:00:00 2001 From: v2ray Date: Sun, 7 Aug 2016 09:08:30 +0200 Subject: [PATCH] test case for srtp --- .../internet/authenticators/srtp/srtp_test.go | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 transport/internet/authenticators/srtp/srtp_test.go diff --git a/transport/internet/authenticators/srtp/srtp_test.go b/transport/internet/authenticators/srtp/srtp_test.go new file mode 100644 index 000000000..db25e99e8 --- /dev/null +++ b/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()) +}