(c *C)
| 307 | } |
| 308 | |
| 309 | func (s *IndexSuite) TestDecodeInvalidHash(c *C) { |
| 310 | idx := s.readSimpleIndex(c) |
| 311 | |
| 312 | buf := bytes.NewBuffer(nil) |
| 313 | e := NewEncoder(buf) |
| 314 | |
| 315 | err := e.encode(idx, false) |
| 316 | c.Assert(err, IsNil) |
| 317 | |
| 318 | err = e.encodeRawExtension("TEST", []byte("testdata")) |
| 319 | c.Assert(err, IsNil) |
| 320 | |
| 321 | h := hash.New(crypto.SHA1) |
| 322 | err = binary.Write(e.w, h.Sum(nil)) |
| 323 | c.Assert(err, IsNil) |
| 324 | |
| 325 | idx = &Index{} |
| 326 | d := NewDecoder(buf) |
| 327 | err = d.Decode(idx) |
| 328 | c.Assert(err, ErrorMatches, ErrInvalidChecksum.Error()) |
| 329 | } |
| 330 | |
| 331 | func TestDecodeV4StripLength(t *testing.T) { |
| 332 | t.Parallel() |
nothing calls this directly
no test coverage detected