mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
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)
|
||
|
}
|
||
|
}
|