MCPcopy Create free account
hub / github.com/chain/Core / TestVarstrListWithEOF

Function TestVarstrListWithEOF

encoding/blockchain/blockchain_test.go:226–241  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

224}
225
226func TestVarstrListWithEOF(t *testing.T) {
227 var buf bytes.Buffer
228 WriteVarint31(&buf, 3)
229 WriteVarstr31(&buf, []byte{0x01})
230 WriteVarstr31(&buf, []byte{0x02})
231 WriteVarstr31(&buf, []byte{0x03})
232
233 want := [][]byte{[]byte{0x01}, []byte{0x02}, []byte{0x03}}
234 got, err := ReadVarstrList(NewReader(buf.Bytes()))
235 if !reflect.DeepEqual(got, want) {
236 t.Errorf("got %#v, want %#v", got, want)
237 }
238 if err != nil && err != io.EOF {
239 t.Errorf("got %s want nil or io.EOF", err)
240 }
241}
242
243// TestTooLongVarstrList tests decoding a VarstrList that has a leading
244// element count much longer than the actual list. Reading such a

Callers

nothing calls this directly

Calls 5

WriteVarint31Function · 0.85
WriteVarstr31Function · 0.85
ReadVarstrListFunction · 0.85
NewReaderFunction · 0.85
BytesMethod · 0.45

Tested by

no test coverage detected