Test Invalid Chunk Store
This commit is contained in:
parent
369a0bc809
commit
e252422463
|
@ -28,7 +28,7 @@ func TestManifest(t *testing.T) {
|
||||||
|
|
||||||
t.Logf("%v", manifest)
|
t.Logf("%v", manifest)
|
||||||
|
|
||||||
// Try to tread the chunk
|
// Try to read the chunk
|
||||||
_, err = manifest.GetChunkBytes(1)
|
_, err = manifest.GetChunkBytes(1)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("chunk fetch should have thrown an error")
|
t.Fatalf("chunk fetch should have thrown an error")
|
||||||
|
@ -43,6 +43,11 @@ func TestManifest(t *testing.T) {
|
||||||
t.Fatalf("chunk fetch error: %v", err)
|
t.Fatalf("chunk fetch error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err = manifest.GetChunkBytes(0)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("chunk fetch error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
json, _ := json.Marshal(manifest)
|
json, _ := json.Marshal(manifest)
|
||||||
t.Logf("%s", json)
|
t.Logf("%s", json)
|
||||||
|
|
||||||
|
@ -112,7 +117,21 @@ func TestManifestLarge(t *testing.T) {
|
||||||
t.Fatalf("could not store chunk %v %v", i, err)
|
t.Fatalf("could not store chunk %v %v", i, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Attempt to store the chunk in an invalid position...
|
||||||
|
_, err = cwtchPngOutManifest.StoreChunk(uint64(i+1), contents)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("incorrect chunk store")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attempt to store an invalid chunk...should trigger an error
|
||||||
|
_, err = cwtchPngOutManifest.StoreChunk(uint64(len(cwtchPngManifest.Chunks)), []byte{0xff})
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("incorrect chunk store")
|
||||||
|
}
|
||||||
|
|
||||||
err = cwtchPngOutManifest.VerifyFile()
|
err = cwtchPngOutManifest.VerifyFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not verify file %v", err)
|
t.Fatalf("could not verify file %v", err)
|
||||||
|
|
Loading…
Reference in New Issue