func TestVarintNoClose(t *testing.T) { buf := bytes.NewBuffer(nil) writer := io.NewDelimitedWriter(buf) reader := io.NewDelimitedReader(buf, 1024*1024) if err := iotest(writer, reader); err != nil { t.Error(err) } }
//issue 32 func TestVarintMaxSize(t *testing.T) { buf := newBuffer() writer := io.NewDelimitedWriter(buf) reader := io.NewDelimitedReader(buf, 20) if err := iotest(writer, reader); err != goio.ErrShortBuffer { t.Error(err) } else { t.Logf("%s", err) } }
func TestVarintNormal(t *testing.T) { buf := newBuffer() writer := io.NewDelimitedWriter(buf) reader := io.NewDelimitedReader(buf, 1024*1024) if err := iotest(writer, reader); err != nil { t.Error(err) } if !buf.closed { t.Fatalf("did not close buffer") } }
func (ids *IDService) RequestHandler(s inet.Stream) { defer s.Close() c := s.Conn() bwc := ids.Host.GetBandwidthReporter() s = mstream.WrapStream(s, ID, bwc) w := ggio.NewDelimitedWriter(s) mes := pb.Identify{} ids.populateMessage(&mes, s.Conn()) w.WriteMsg(&mes) log.Debugf("%s sent message to %s %s", ID, c.RemotePeer(), c.RemoteMultiaddr()) }