From b24e808a8a5e2e29e2ff744c9c7798211f1fd4f8 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 25 May 2018 12:50:33 +0200 Subject: [PATCH] fix pipe related tests --- app/proxyman/mux/mux_test.go | 2 +- common/buf/reader_test.go | 6 +++--- common/buf/writer_test.go | 2 +- transport/internet/udp/dispatcher_test.go | 4 ++-- transport/pipe/pipe_test.go | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/proxyman/mux/mux_test.go b/app/proxyman/mux/mux_test.go index c8508dc2..0bbd1202 100644 --- a/app/proxyman/mux/mux_test.go +++ b/app/proxyman/mux/mux_test.go @@ -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) diff --git a/common/buf/reader_test.go b/common/buf/reader_test.go index f5ea1e10..347985b5 100644 --- a/common/buf/reader_test.go +++ b/common/buf/reader_test.go @@ -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') diff --git a/common/buf/writer_test.go b/common/buf/writer_test.go index dbd324ab..09b01559 100644 --- a/common/buf/writer_test.go +++ b/common/buf/writer_test.go @@ -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) diff --git a/transport/internet/udp/dispatcher_test.go b/transport/internet/udp/dispatcher_test.go index 4d332342..f7a93bd0 100644 --- a/transport/internet/udp/dispatcher_test.go +++ b/transport/internet/udp/dispatcher_test.go @@ -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 { diff --git a/transport/pipe/pipe_test.go b/transport/pipe/pipe_test.go index 10063ba1..5a823c77 100644 --- a/transport/pipe/pipe_test.go +++ b/transport/pipe/pipe_test.go @@ -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)