| 171 | } |
| 172 | |
| 173 | func verifySizeAndHash(t *testing.T, blob *blob.Blob) { |
| 174 | hash := sha1.New() |
| 175 | r, err := blob.ReadAll(ctxbg) |
| 176 | if err != nil { |
| 177 | t.Fatal(err) |
| 178 | } |
| 179 | n, err := io.Copy(hash, r) |
| 180 | if err != nil { |
| 181 | t.Fatal(err) |
| 182 | } |
| 183 | |
| 184 | if uint32(n) != blob.Size() { |
| 185 | t.Fatalf("read %d bytes from blob %v; want %v", n, blob.Ref(), blob.Size()) |
| 186 | } |
| 187 | |
| 188 | if !blob.SizedRef().HashMatches(hash) { |
| 189 | t.Fatalf("read wrong bytes from blobref %v (digest mismatch)", blob.Ref()) |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // Tests that we can correctly switch over to the next pack if we |
| 194 | // still need to stream more blobs when a pack reaches EOF. |