lib/protocol: Hide repeated data blocks in a given file (#7319)

This commit is contained in:
Jakob Borg
2021-02-02 20:15:14 +01:00
committed by GitHub
parent a7d9268e4d
commit 3b7a57d108
2 changed files with 55 additions and 15 deletions
+19 -2
View File
@@ -82,13 +82,30 @@ func TestEnDecryptFileInfo(t *testing.T) {
ModifiedS: 8080,
Blocks: []BlockInfo{
{
Size: 45,
Hash: []byte{1, 2, 3},
Offset: 0,
Size: 45,
Hash: []byte{1, 2, 3},
},
{
Offset: 45,
Size: 45,
Hash: []byte{1, 2, 3},
},
},
}
enc := encryptFileInfo(fi, &key)
if bytes.Equal(enc.Blocks[0].Hash, enc.Blocks[1].Hash) {
t.Error("block hashes should not repeat when on different offsets")
}
again := encryptFileInfo(fi, &key)
if !bytes.Equal(enc.Blocks[0].Hash, again.Blocks[0].Hash) {
t.Error("block hashes should remain stable (0)")
}
if !bytes.Equal(enc.Blocks[1].Hash, again.Blocks[1].Hash) {
t.Error("block hashes should remain stable (1)")
}
dec, err := DecryptFileInfo(enc, &key)
if err != nil {
t.Error(err)