Ported tests all pass

This commit is contained in:
Kovid Goyal
2023-07-19 13:44:40 +05:30
parent bbbc33d4dc
commit edc1669ced
4 changed files with 32 additions and 17 deletions

View File

@@ -11,6 +11,7 @@ package rsync
import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
"hash"
"io"
@@ -314,9 +315,9 @@ func (r *rsync) ApplyDelta(alignedTarget io.Writer, target io.ReadSeeker, op Ope
return err
}
case OpHash:
expected := r.checksummer.Sum(nil)
if !bytes.Equal(expected, op.Data) {
return fmt.Errorf("Failed to verify overall file checksum. This usually happens if some data was corrupted in transit or one of the involved files was altered while the transfer was in progress.")
actual := r.checksummer.Sum(nil)
if !bytes.Equal(actual, op.Data) {
return fmt.Errorf("Failed to verify overall file checksum actual: %s != expected: %s. This usually happens if some data was corrupted in transit or one of the involved files was altered while the transfer was in progress.", hex.EncodeToString(actual), hex.EncodeToString(op.Data))
}
}
return nil

View File

@@ -85,7 +85,7 @@ func run_roundtrip_test(t *testing.T, src_data, changed []byte, num_of_patches,
// Now try with serialization
using_serialization = true
p = NewPatcher(int64(len(src_data)))
p = NewPatcher(int64(len(changed)))
signature_of_changed := bytes.Buffer{}
ss_it := p.CreateSignatureIterator(bytes.NewReader(changed), &signature_of_changed)
var err error