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

Function TestTooLongVarstring31

encoding/blockchain/blockchain_test.go:189–198  ·  view source on GitHub ↗

TestTooLongVarstring31 tests decoding a varstring31 with a leading length too long to fit in memory. Reading such a varstring31 should not try to allocate more memory than feasible.

(t *testing.T)

Source from the content-addressed store, hash-verified

187// length too long to fit in memory. Reading such a varstring31 should
188// not try to allocate more memory than feasible.
189func TestTooLongVarstring31(t *testing.T) {
190 var buf bytes.Buffer
191 WriteVarint31(&buf, 0x7fffffff)
192 buf.Write([]byte{0x01, 0x02, 0x03})
193
194 _, err := ReadVarstr31(NewReader(buf.Bytes()))
195 if err != io.ErrUnexpectedEOF {
196 t.Errorf("got %s, want io.ErrUnexpectedEOF", err)
197 }
198}
199
200func TestVarstrList(t *testing.T) {
201 for i := 0; i < 4; i++ {

Callers

nothing calls this directly

Calls 5

WriteVarint31Function · 0.85
ReadVarstr31Function · 0.85
NewReaderFunction · 0.85
WriteMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected