github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/transport/internet/headers/srtp/srtp_test.go (about) 1 package srtp_test 2 3 import ( 4 "context" 5 "testing" 6 7 "v2ray.com/core/common" 8 "v2ray.com/core/common/buf" 9 . "v2ray.com/core/transport/internet/headers/srtp" 10 ) 11 12 func TestSRTPWrite(t *testing.T) { 13 content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'} 14 srtpRaw, err := New(context.Background(), &Config{}) 15 common.Must(err) 16 17 srtp := srtpRaw.(*SRTP) 18 19 payload := buf.New() 20 srtp.Serialize(payload.Extend(srtp.Size())) 21 payload.Write(content) 22 23 expectedLen := int32(len(content)) + srtp.Size() 24 if payload.Len() != expectedLen { 25 t.Error("expected ", expectedLen, " of bytes, but got ", payload.Len()) 26 } 27 }