Skip to content

Fix incorrect test data in 5 negative tests and 1 positive test#2

Open
paddybyers wants to merge 1 commit intomainfrom
format-validity-fixes
Open

Fix incorrect test data in 5 negative tests and 1 positive test#2
paddybyers wants to merge 1 commit intomainfrom
format-validity-fixes

Conversation

@paddybyers
Copy link
Copy Markdown
Member

Summary

Five targeted-negative test cases had incorrect delta binaries that caused decoders to reject them for the wrong reason (or accept them when they should be rejected). One targeted-positive test had incorrect metadata.

Changes

Delta binary fixes

  • invalid_magic_0/delta.vcdiff: Changed 3rd magic byte from 0xC4 to 0xC5 so the magic is actually invalid. Previously the magic bytes were valid, so decoders would parse the header successfully and fail later on a format error instead of a magic error.
  • invalid_version/delta.vcdiff: Swapped bytes 3 and 4 so the version byte (0x01) is in the correct position after valid magic. Previously byte 3 was the invalid version and byte 4 was 0x00, but the magic occupied bytes 0-2, so the version was at offset 3 — which happened to be correct, but the bytes were in the wrong order causing the magic check to fail first.
  • truncated_source_length/delta.vcdiff: Fixed to have a valid 5-byte header followed by a window indicator with VCD_SOURCE flag set, then a varint that truncates mid-read.
  • truncated_source_position/delta.vcdiff: Fixed to have a valid 5-byte header followed by a window indicator with VCD_SOURCE flag set, a complete source segment length, then a varint that truncates mid-read.

Metadata fixes

  • truncated_magic_3_bytes/metadata.json: Changed expected error from ErrInvalidMagic to ErrInvalidFormat. Three valid magic bytes followed by EOF is a format/truncation error, not a magic error — the magic itself is valid.
  • invalid_magic_0/metadata.json: Updated description to match the binary fix.
  • empty-files/metadata.json: Corrected window_count from 0 to 1. The delta contains one window that produces zero target bytes.

Verification

All four existing implementations pass after these fixes:

  • vcdiff-go: all tests pass
  • vcdiff-py: all tests pass
  • vcdiff-dart: all tests pass
  • vcdiff-kotlin: all tests pass

Fix delta binaries and metadata for targeted-negative tests that had
incorrect bytes, causing decoders to reject them for the wrong reason
(or accept them when they should be rejected):

- invalid_magic_0/delta.vcdiff: changed 3rd magic byte from 0xC4 to
  0xC5 so the magic is actually invalid
- invalid_magic_0/metadata.json: updated description to match fix
- invalid_version/delta.vcdiff: swapped bytes 3 and 4 so the version
  byte (0x01) is in the correct position after valid magic
- truncated_source_length/delta.vcdiff: fixed to have valid header
  with a window that truncates during source segment length
- truncated_source_position/delta.vcdiff: fixed to have valid header
  with a window that truncates during source segment position
- truncated_magic_3_bytes/metadata.json: changed expected error from
  ErrInvalidMagic to ErrInvalidFormat (3 valid magic bytes followed
  by EOF is a format error, not a magic error); updated description
- empty-files/metadata.json: corrected window_count from 0 to 1
  (the delta contains one window that produces zero target bytes)

Verified all four implementations still pass after these fixes:
- vcdiff-go: all tests pass
- vcdiff-py: all tests pass
- vcdiff-dart: all tests pass
- vcdiff-kotlin: all tests pass
@paddybyers paddybyers requested a review from ttypic February 8, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant