Unverified Commit 7083218d authored by Raúl Kripalani's avatar Raúl Kripalani Committed by GitHub

interoperable uvarints. (#21)

parent 0a87fa50
......@@ -6,6 +6,7 @@ import (
"sync"
pool "github.com/libp2p/go-buffer-pool"
"github.com/multiformats/go-varint"
)
// varintWriter is the underlying type that implements the Writer interface.
......@@ -115,7 +116,7 @@ func (s *varintReader) NextMsgLen() (int, error) {
func (s *varintReader) nextMsgLen() (int, error) {
if s.next == -1 {
length, err := binary.ReadUvarint(s.br)
length, err := varint.ReadUvarint(s.br)
if err != nil {
return 0, err
}
......
......@@ -5,6 +5,8 @@ import (
"encoding/binary"
"io"
"testing"
"github.com/multiformats/go-varint"
)
func TestVarintReadWrite(t *testing.T) {
......@@ -46,7 +48,7 @@ func SubtestVarintWrite(t *testing.T, msg []byte) {
bb := buf.Bytes()
sbr := simpleByteReader{R: buf}
length, err := binary.ReadUvarint(&sbr)
length, err := varint.ReadUvarint(&sbr)
if err != nil {
t.Fatal(err)
}
......@@ -57,7 +59,7 @@ func SubtestVarintWrite(t *testing.T, msg []byte) {
}
lbuf := make([]byte, binary.MaxVarintLen64)
n := binary.PutUvarint(lbuf, length)
n := varint.PutUvarint(lbuf, length)
bblen := int(length) + n
t.Logf("checking wrote (%d + %d) bytes", length, n)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment