1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00
v2fly/transport/internet/headers/srtp/srtp_test.go
2021-02-17 04:31:50 +08:00

28 lines
652 B
Go

package srtp_test
import (
"context"
"testing"
"github.com/v2fly/v2ray-core/v4/common"
"github.com/v2fly/v2ray-core/v4/common/buf"
. "github.com/v2fly/v2ray-core/v4/transport/internet/headers/srtp"
)
func TestSRTPWrite(t *testing.T) {
content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
srtpRaw, err := New(context.Background(), &Config{})
common.Must(err)
srtp := srtpRaw.(*SRTP)
payload := buf.New()
srtp.Serialize(payload.Extend(srtp.Size()))
payload.Write(content)
expectedLen := int32(len(content)) + srtp.Size()
if payload.Len() != expectedLen {
t.Error("expected ", expectedLen, " of bytes, but got ", payload.Len())
}
}