github.com/imannamdari/v2ray-core/v5@v5.0.5/transport/internet/headers/utp/utp_test.go (about) 1 package utp_test 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/imannamdari/v2ray-core/v5/common" 8 "github.com/imannamdari/v2ray-core/v5/common/buf" 9 . "github.com/imannamdari/v2ray-core/v5/transport/internet/headers/utp" 10 ) 11 12 func TestUTPWrite(t *testing.T) { 13 content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'} 14 utpRaw, err := New(context.Background(), &Config{}) 15 common.Must(err) 16 17 utp := utpRaw.(*UTP) 18 19 payload := buf.New() 20 utp.Serialize(payload.Extend(utp.Size())) 21 payload.Write(content) 22 23 if payload.Len() != int32(len(content))+utp.Size() { 24 t.Error("unexpected payload length: ", payload.Len()) 25 } 26 }