|
|
|
@ -1797,7 +1797,7 @@ func TestPosixVerifyFile(t *testing.T) { |
|
|
|
|
if err := posixStorage.WriteAll(volName, fileName, bytes.NewBuffer(data)); err != nil { |
|
|
|
|
t.Fatal(err) |
|
|
|
|
} |
|
|
|
|
if err := posixStorage.VerifyFile(volName, fileName, false, algo, hashBytes, 0); err != nil { |
|
|
|
|
if err := posixStorage.VerifyFile(volName, fileName, size, algo, hashBytes, 0); err != nil { |
|
|
|
|
t.Fatal(err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1805,7 +1805,14 @@ func TestPosixVerifyFile(t *testing.T) { |
|
|
|
|
if err := posixStorage.AppendFile(volName, fileName, []byte("a")); err != nil { |
|
|
|
|
t.Fatal(err) |
|
|
|
|
} |
|
|
|
|
if err := posixStorage.VerifyFile(volName, fileName, false, algo, hashBytes, 0); err == nil { |
|
|
|
|
|
|
|
|
|
// Check if VerifyFile reports the incorrect file length (the correct length is `size+1`)
|
|
|
|
|
if err := posixStorage.VerifyFile(volName, fileName, size, algo, hashBytes, 0); err == nil { |
|
|
|
|
t.Fatal("expected to fail bitrot check") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Check if bitrot fails
|
|
|
|
|
if err := posixStorage.VerifyFile(volName, fileName, size+1, algo, hashBytes, 0); err == nil { |
|
|
|
|
t.Fatal("expected to fail bitrot check") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1833,7 +1840,7 @@ func TestPosixVerifyFile(t *testing.T) { |
|
|
|
|
t.Fatal(err) |
|
|
|
|
} |
|
|
|
|
w.Close() |
|
|
|
|
if err := posixStorage.VerifyFile(volName, fileName, false, algo, nil, shardSize); err != nil { |
|
|
|
|
if err := posixStorage.VerifyFile(volName, fileName, size, algo, nil, shardSize); err != nil { |
|
|
|
|
t.Fatal(err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1847,7 +1854,10 @@ func TestPosixVerifyFile(t *testing.T) { |
|
|
|
|
t.Fatal(err) |
|
|
|
|
} |
|
|
|
|
f.Close() |
|
|
|
|
if err := posixStorage.VerifyFile(volName, fileName, false, algo, nil, shardSize); err == nil { |
|
|
|
|
if err := posixStorage.VerifyFile(volName, fileName, size, algo, nil, shardSize); err == nil { |
|
|
|
|
t.Fatal("expected to fail bitrot check") |
|
|
|
|
} |
|
|
|
|
if err := posixStorage.VerifyFile(volName, fileName, size+1, algo, nil, shardSize); err == nil { |
|
|
|
|
t.Fatal("expected to fail bitrot check") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|