1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-23 10:37:09 -05:00
v2fly/transport/internet/headers/utp/utp_test.go

27 lines
594 B
Go
Raw Normal View History

2016-08-08 15:23:07 -04:00
package utp_test
import (
2017-12-16 17:31:05 -05:00
"context"
2016-08-08 15:23:07 -04:00
"testing"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/common/buf"
. "github.com/v2fly/v2ray-core/v5/transport/internet/headers/utp"
2016-08-08 15:23:07 -04:00
)
2016-12-08 10:27:41 -05:00
func TestUTPWrite(t *testing.T) {
2016-08-08 15:23:07 -04:00
content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
2017-12-16 17:31:05 -05:00
utpRaw, err := New(context.Background(), &Config{})
2019-02-02 16:19:30 -05:00
common.Must(err)
2017-12-16 17:31:05 -05:00
utp := utpRaw.(*UTP)
2016-12-08 10:27:41 -05:00
2018-03-11 18:45:24 -04:00
payload := buf.New()
2018-11-02 16:34:04 -04:00
utp.Serialize(payload.Extend(utp.Size()))
2018-04-19 16:56:55 -04:00
payload.Write(content)
2016-12-06 05:03:42 -05:00
2019-02-02 16:19:30 -05:00
if payload.Len() != int32(len(content))+utp.Size() {
t.Error("unexpected payload length: ", payload.Len())
}
2016-08-08 15:23:07 -04:00
}