1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

fix pipe related tests

This commit is contained in:
Darien Raymond 2018-05-25 12:50:33 +02:00
parent 213f827406
commit b24e808a8a
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
5 changed files with 10 additions and 10 deletions

View File

@ -30,7 +30,7 @@ func readAll(reader buf.Reader) (buf.MultiBuffer, error) {
func TestReaderWriter(t *testing.T) {
assert := With(t)
pReader, pWriter := pipe.New()
pReader, pWriter := pipe.New(pipe.WithSizeLimit(1024))
dest := net.TCPDestination(net.DomainAddress("v2ray.com"), 80)
writer := NewWriter(1, dest, pWriter, protocol.TransferTypeStream)

View File

@ -38,7 +38,7 @@ func TestAdaptiveReader(t *testing.T) {
func TestBytesReaderWriteTo(t *testing.T) {
assert := With(t)
pReader, pWriter := pipe.New()
pReader, pWriter := pipe.New(pipe.WithSizeLimit(1024))
reader := &BufferedReader{Reader: pReader}
b1 := New()
b1.AppendBytes('a', 'b', 'c')
@ -47,7 +47,7 @@ func TestBytesReaderWriteTo(t *testing.T) {
assert(pWriter.WriteMultiBuffer(NewMultiBufferValue(b1, b2)), IsNil)
pWriter.Close()
pReader2, pWriter2 := pipe.New()
pReader2, pWriter2 := pipe.New(pipe.WithSizeLimit(1024))
writer := NewBufferedWriter(pWriter2)
writer.SetBuffered(false)
@ -65,7 +65,7 @@ func TestBytesReaderWriteTo(t *testing.T) {
func TestBytesReaderMultiBuffer(t *testing.T) {
assert := With(t)
pReader, pWriter := pipe.New()
pReader, pWriter := pipe.New(pipe.WithSizeLimit(1024))
reader := &BufferedReader{Reader: pReader}
b1 := New()
b1.AppendBytes('a', 'b', 'c')

View File

@ -34,8 +34,8 @@ func TestWriter(t *testing.T) {
func TestBytesWriterReadFrom(t *testing.T) {
assert := With(t)
pReader, pWriter := pipe.New()
const size = 50000
pReader, pWriter := pipe.New(pipe.WithSizeLimit(size))
reader := bufio.NewReader(io.LimitReader(rand.Reader, size))
writer := NewBufferedWriter(pWriter)
writer.SetBuffered(false)

View File

@ -34,8 +34,8 @@ func TestSameDestinationDispatching(t *testing.T) {
assert := With(t)
ctx, cancel := context.WithCancel(context.Background())
uplinkReader, uplinkWriter := pipe.New()
downlinkReader, downlinkWriter := pipe.New()
uplinkReader, uplinkWriter := pipe.New(pipe.WithSizeLimit(1024))
downlinkReader, downlinkWriter := pipe.New(pipe.WithSizeLimit(1024))
go func() {
for {

View File

@ -15,7 +15,7 @@ import (
func TestPipeReadWrite(t *testing.T) {
assert := With(t)
pReader, pWriter := New()
pReader, pWriter := New(WithSizeLimit(1024))
payload := []byte{'a', 'b', 'c', 'd'}
b := buf.New()
b.Write(payload)
@ -29,7 +29,7 @@ func TestPipeReadWrite(t *testing.T) {
func TestPipeCloseError(t *testing.T) {
assert := With(t)
pReader, pWriter := New()
pReader, pWriter := New(WithSizeLimit(1024))
payload := []byte{'a', 'b', 'c', 'd'}
b := buf.New()
b.Write(payload)
@ -44,7 +44,7 @@ func TestPipeCloseError(t *testing.T) {
func TestPipeClose(t *testing.T) {
assert := With(t)
pReader, pWriter := New()
pReader, pWriter := New(WithSizeLimit(1024))
payload := []byte{'a', 'b', 'c', 'd'}
b := buf.New()
b.Write(payload)