1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| package utp_test
|
| import (
| "context"
| "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"
| )
|
| 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())
| }
| }
|
|