2016-08-08 21:23:07 +02:00
|
|
|
package utp_test
|
|
|
|
|
|
|
|
|
|
import (
|
2017-12-16 23:31:05 +01:00
|
|
|
"context"
|
2016-08-08 21:23:07 +02:00
|
|
|
"testing"
|
|
|
|
|
|
2016-12-09 11:35:27 +01:00
|
|
|
"v2ray.com/core/common/buf"
|
2016-12-08 16:27:41 +01:00
|
|
|
. "v2ray.com/core/transport/internet/headers/utp"
|
2017-10-26 21:44:22 +02:00
|
|
|
. "v2ray.com/ext/assert"
|
2016-08-08 21:23:07 +02:00
|
|
|
)
|
|
|
|
|
|
2016-12-08 16:27:41 +01:00
|
|
|
func TestUTPWrite(t *testing.T) {
|
2017-10-24 16:15:35 +02:00
|
|
|
assert := With(t)
|
2016-08-08 21:23:07 +02:00
|
|
|
|
|
|
|
|
content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
|
2017-12-16 23:31:05 +01:00
|
|
|
utpRaw, err := New(context.Background(), &Config{})
|
|
|
|
|
assert(err, IsNil)
|
|
|
|
|
|
|
|
|
|
utp := utpRaw.(*UTP)
|
2016-12-08 16:27:41 +01:00
|
|
|
|
2016-12-09 12:08:25 +01:00
|
|
|
payload := buf.NewLocal(2048)
|
|
|
|
|
payload.AppendSupplier(utp.Write)
|
2016-12-06 11:03:42 +01:00
|
|
|
payload.Append(content)
|
|
|
|
|
|
2017-10-26 21:44:22 +02:00
|
|
|
assert(payload.Len(), Equals, len(content)+utp.Size())
|
2016-08-08 21:23:07 +02:00
|
|
|
}
|