summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/contentenc/file_header.go7
-rw-r--r--tests/matrix/matrix_test.go8
2 files changed, 9 insertions, 6 deletions
diff --git a/internal/contentenc/file_header.go b/internal/contentenc/file_header.go
index 62d24cb..5f8bd63 100644
--- a/internal/contentenc/file_header.go
+++ b/internal/contentenc/file_header.go
@@ -7,6 +7,7 @@ package contentenc
import (
"bytes"
"encoding/binary"
+ "encoding/hex"
"fmt"
"log"
@@ -52,11 +53,13 @@ func ParseHeader(buf []byte) (*FileHeader, error) {
var h FileHeader
h.Version = binary.BigEndian.Uint16(buf[0:headerVersionLen])
if h.Version != CurrentVersion {
- return nil, fmt.Errorf("ParseHeader: invalid version, want=%d have=%d", CurrentVersion, h.Version)
+ return nil, fmt.Errorf("ParseHeader: invalid version, want=%d have=%d. Hexdump: %s",
+ CurrentVersion, h.Version, hex.EncodeToString(buf))
}
h.ID = buf[headerVersionLen:]
if bytes.Equal(h.ID, allZeroFileID) {
- return nil, fmt.Errorf("ParseHeader: file id is all-zero")
+ return nil, fmt.Errorf("ParseHeader: file id is all-zero. Hexdump: %s",
+ hex.EncodeToString(buf))
}
return &h, nil
}
diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go
index 33d2ab2..65dd691 100644
--- a/tests/matrix/matrix_test.go
+++ b/tests/matrix/matrix_test.go
@@ -98,13 +98,13 @@ func testWriteN(t *testing.T, fn string, n int) string {
}
d := make([]byte, n)
- written, err := file.Write(d)
- if err != nil || written != len(d) {
- t.Errorf("err=\"%s\", written=%d", err, written)
+ _, err := file.Write(d)
+ if err != nil {
+ t.Fatal(err)
}
err = file.Close()
if err != nil {
- t.Error(err)
+ t.Fatal(err)
}
test_helpers.VerifySize(t, test_helpers.DefaultPlainDir+"/"+fn, n)