mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-29 06:37:17 +00:00
c0627e29a8
* Add varint prefixing to ssz network encoder * fix spacing * fix comments * fix comments * Update varint.go
22 lines
418 B
Go
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)
|
|
}
|
|
}
|