mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
fix pipe related tests
This commit is contained in:
parent
213f827406
commit
b24e808a8a
@ -30,7 +30,7 @@ func readAll(reader buf.Reader) (buf.MultiBuffer, error) {
|
|||||||
func TestReaderWriter(t *testing.T) {
|
func TestReaderWriter(t *testing.T) {
|
||||||
assert := With(t)
|
assert := With(t)
|
||||||
|
|
||||||
pReader, pWriter := pipe.New()
|
pReader, pWriter := pipe.New(pipe.WithSizeLimit(1024))
|
||||||
|
|
||||||
dest := net.TCPDestination(net.DomainAddress("v2ray.com"), 80)
|
dest := net.TCPDestination(net.DomainAddress("v2ray.com"), 80)
|
||||||
writer := NewWriter(1, dest, pWriter, protocol.TransferTypeStream)
|
writer := NewWriter(1, dest, pWriter, protocol.TransferTypeStream)
|
||||||
|
@ -38,7 +38,7 @@ func TestAdaptiveReader(t *testing.T) {
|
|||||||
func TestBytesReaderWriteTo(t *testing.T) {
|
func TestBytesReaderWriteTo(t *testing.T) {
|
||||||
assert := With(t)
|
assert := With(t)
|
||||||
|
|
||||||
pReader, pWriter := pipe.New()
|
pReader, pWriter := pipe.New(pipe.WithSizeLimit(1024))
|
||||||
reader := &BufferedReader{Reader: pReader}
|
reader := &BufferedReader{Reader: pReader}
|
||||||
b1 := New()
|
b1 := New()
|
||||||
b1.AppendBytes('a', 'b', 'c')
|
b1.AppendBytes('a', 'b', 'c')
|
||||||
@ -47,7 +47,7 @@ func TestBytesReaderWriteTo(t *testing.T) {
|
|||||||
assert(pWriter.WriteMultiBuffer(NewMultiBufferValue(b1, b2)), IsNil)
|
assert(pWriter.WriteMultiBuffer(NewMultiBufferValue(b1, b2)), IsNil)
|
||||||
pWriter.Close()
|
pWriter.Close()
|
||||||
|
|
||||||
pReader2, pWriter2 := pipe.New()
|
pReader2, pWriter2 := pipe.New(pipe.WithSizeLimit(1024))
|
||||||
writer := NewBufferedWriter(pWriter2)
|
writer := NewBufferedWriter(pWriter2)
|
||||||
writer.SetBuffered(false)
|
writer.SetBuffered(false)
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ func TestBytesReaderWriteTo(t *testing.T) {
|
|||||||
func TestBytesReaderMultiBuffer(t *testing.T) {
|
func TestBytesReaderMultiBuffer(t *testing.T) {
|
||||||
assert := With(t)
|
assert := With(t)
|
||||||
|
|
||||||
pReader, pWriter := pipe.New()
|
pReader, pWriter := pipe.New(pipe.WithSizeLimit(1024))
|
||||||
reader := &BufferedReader{Reader: pReader}
|
reader := &BufferedReader{Reader: pReader}
|
||||||
b1 := New()
|
b1 := New()
|
||||||
b1.AppendBytes('a', 'b', 'c')
|
b1.AppendBytes('a', 'b', 'c')
|
||||||
|
@ -34,8 +34,8 @@ func TestWriter(t *testing.T) {
|
|||||||
func TestBytesWriterReadFrom(t *testing.T) {
|
func TestBytesWriterReadFrom(t *testing.T) {
|
||||||
assert := With(t)
|
assert := With(t)
|
||||||
|
|
||||||
pReader, pWriter := pipe.New()
|
|
||||||
const size = 50000
|
const size = 50000
|
||||||
|
pReader, pWriter := pipe.New(pipe.WithSizeLimit(size))
|
||||||
reader := bufio.NewReader(io.LimitReader(rand.Reader, size))
|
reader := bufio.NewReader(io.LimitReader(rand.Reader, size))
|
||||||
writer := NewBufferedWriter(pWriter)
|
writer := NewBufferedWriter(pWriter)
|
||||||
writer.SetBuffered(false)
|
writer.SetBuffered(false)
|
||||||
|
@ -34,8 +34,8 @@ func TestSameDestinationDispatching(t *testing.T) {
|
|||||||
assert := With(t)
|
assert := With(t)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
uplinkReader, uplinkWriter := pipe.New()
|
uplinkReader, uplinkWriter := pipe.New(pipe.WithSizeLimit(1024))
|
||||||
downlinkReader, downlinkWriter := pipe.New()
|
downlinkReader, downlinkWriter := pipe.New(pipe.WithSizeLimit(1024))
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestPipeReadWrite(t *testing.T) {
|
func TestPipeReadWrite(t *testing.T) {
|
||||||
assert := With(t)
|
assert := With(t)
|
||||||
|
|
||||||
pReader, pWriter := New()
|
pReader, pWriter := New(WithSizeLimit(1024))
|
||||||
payload := []byte{'a', 'b', 'c', 'd'}
|
payload := []byte{'a', 'b', 'c', 'd'}
|
||||||
b := buf.New()
|
b := buf.New()
|
||||||
b.Write(payload)
|
b.Write(payload)
|
||||||
@ -29,7 +29,7 @@ func TestPipeReadWrite(t *testing.T) {
|
|||||||
func TestPipeCloseError(t *testing.T) {
|
func TestPipeCloseError(t *testing.T) {
|
||||||
assert := With(t)
|
assert := With(t)
|
||||||
|
|
||||||
pReader, pWriter := New()
|
pReader, pWriter := New(WithSizeLimit(1024))
|
||||||
payload := []byte{'a', 'b', 'c', 'd'}
|
payload := []byte{'a', 'b', 'c', 'd'}
|
||||||
b := buf.New()
|
b := buf.New()
|
||||||
b.Write(payload)
|
b.Write(payload)
|
||||||
@ -44,7 +44,7 @@ func TestPipeCloseError(t *testing.T) {
|
|||||||
func TestPipeClose(t *testing.T) {
|
func TestPipeClose(t *testing.T) {
|
||||||
assert := With(t)
|
assert := With(t)
|
||||||
|
|
||||||
pReader, pWriter := New()
|
pReader, pWriter := New(WithSizeLimit(1024))
|
||||||
payload := []byte{'a', 'b', 'c', 'd'}
|
payload := []byte{'a', 'b', 'c', 'd'}
|
||||||
b := buf.New()
|
b := buf.New()
|
||||||
b.Write(payload)
|
b.Write(payload)
|
||||||
|
Loading…
Reference in New Issue
Block a user