1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/transport/internet/headers/utp/utp_test.go
2021-02-17 04:31:50 +08:00

27 lines
594 B
Go

package utp_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/utp"
)
func TestUTPWrite(t *testing.T) {
content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
utpRaw, err := New(context.Background(), &Config{})
common.Must(err)
utp := utpRaw.(*UTP)
payload := buf.New()
utp.Serialize(payload.Extend(utp.Size()))
payload.Write(content)
if payload.Len() != int32(len(content))+utp.Size() {
t.Error("unexpected payload length: ", payload.Len())
}
}