prysm-pulse/beacon-chain/p2p/encoder/varint_test.go
Preston Van Loon c0627e29a8 Add varint prefixing to ssz network encoder (#3210)
* Add varint prefixing to ssz network encoder

* fix spacing

* fix comments

* fix comments

* Update varint.go
2019-08-14 16:18:32 -05:00

22 lines
418 B
Go

package encoder
import (
"bytes"
"testing"
"github.com/gogo/protobuf/proto"
)
func TestReadVarint(t *testing.T) {
data := []byte("foobar data")
prefixedData := append(proto.EncodeVarint(uint64(len(data))), data...)
vi, err := readVarint(bytes.NewBuffer(prefixedData))
if err != nil {
t.Fatal(err)
}
if vi != uint64(len(data)) {
t.Errorf("Received wrong varint. Wanted %d, got %d", len(data), vi)
}
}