Skip to content

test(receiver): EDG-GOODBYE.4 partial-cutoff + hung-sender goodbye tests - #5618

Merged
oferchen merged 1 commit into
test/edg-goodbye-contractfrom
test/edg-goodbye-4-partial-cutoff-timeout
Jun 11, 2026
Merged

oferchen merged 1 commit into
test/edg-goodbye-contractfrom
test/edg-goodbye-4-partial-cutoff-timeout

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Locks the receiver-side half of the EDG-GOODBYE contract introduced by #5600. EDG-GOODBYE.1/.2/.3 in crates/protocol/tests/goodbye_contract.rs pin the wire shape the sender must emit; this PR adds EDG-GOODBYE.4, which pins what the receiver must do when the sender misbehaves.

Stacked on top of #5600 - merge that one first.

Scenarios (each asserts the receiver returns a typed io::Error, never panics):

  • EOF mid-byte inside the legacy 4-byte NDX_DONE (UnexpectedEof from read_expected_ndx_done on proto 29).
  • EOF after a modern 0xFF prefix on proto 32 handle_goodbye (UnexpectedEof).
  • Immediate EOF before any goodbye byte on both proto 29 and 32 (UnexpectedEof).
  • Well-framed positive NDX (5) in place of NDX_DONE on proto 32 (InvalidData with the expected NDX_DONE message preserved).
  • Legacy garbage rejection via read_expected_ndx_done on proto 29 (InvalidData with the context string preserved).
  • Hung sender that never produces bytes - bounded with mpsc::recv_timeout(2s); guards against a receiver that silently declares success on zero input. Accepts TimedOut or UnexpectedEof if a future change adds an internal deadline (does not lock implementation choice).
  • EOF inside the NDX_DEL_STATS varint payload (UnexpectedEof from DeleteStats::read_from).
  • Happy-path sanity check that a well-formed NDX_DONE still drives the handshake cleanly.

Protocol-coverage rationale

handle_goodbye only reads on proto >= 31; on proto 28/29 the read-side counterpart is read_expected_ndx_done called by exchange_phase_done. The legacy-codec EOF and garbage tests therefore target read_expected_ndx_done directly; the modern-codec tests target handle_goodbye directly. Audit doc explains this.

Upstream reference

main.c:893-924 read_final_goodbye() - exits with RERR_PROTOCOL on a non-NDX_DONE final read, and propagates I/O errors from read_int / read_ndx_and_attrs on short reads. Our equivalents are io::ErrorKind::InvalidData and io::ErrorKind::UnexpectedEof.

Test plan

  • fmt + clippy (CI).
  • Linux nextest stable runs the new module under crate::transfer::receiver::tests::errors_and_timeouts::goodbye_partial_cutoff::*.
  • Windows + macOS stable runs the same module - all tests are pure in-process I/O on Cursor / a parked thread; no platform-specific paths.
  • Hung-sender test wall-clock bounded to 2s (mpsc::recv_timeout) so a regression that silently succeeds fails fast.
  • Confirm handle_goodbye_proto32_accepts_well_formed_ndx_done still passes (happy-path sanity).

Locks the receiver-side half of the EDG-GOODBYE contract. While
EDG-GOODBYE.1/.2/.3 in crates/protocol/tests/goodbye_contract.rs pin
the wire shape the sender must emit, EDG-GOODBYE.4 pins what the
receiver must do when the sender misbehaves.

Eight scenarios are covered by tests in
crates/transfer/src/receiver/tests/errors_and_timeouts/goodbye_partial_cutoff.rs,
each asserting the receiver returns a typed io::Error rather than
panic:

- EOF mid-byte inside the legacy 4-byte NDX_DONE (UnexpectedEof from
  read_expected_ndx_done on proto 29).
- EOF after a modern 0xFF prefix on proto 32 handle_goodbye
  (UnexpectedEof).
- Immediate EOF before any goodbye byte on both proto 29 and 32
  (UnexpectedEof).
- Well-framed positive NDX (5) in place of NDX_DONE on proto 32
  (InvalidData with the expected NDX_DONE message preserved).
- Legacy garbage rejection via read_expected_ndx_done on proto 29
  (InvalidData with the context string preserved).
- Hung sender that never produces bytes - bounded with
  mpsc::recv_timeout(2s); guards against a receiver that silently
  declares success on zero input, and accepts TimedOut or
  UnexpectedEof if a future change adds an internal deadline.
- EOF inside the NDX_DEL_STATS varint payload (UnexpectedEof from
  DeleteStats::read_from).
- Happy-path sanity check that well-formed NDX_DONE still drives the
  handshake cleanly.

Protocol-coverage note: handle_goodbye only reads on proto >= 31; on
proto 28/29 the read-side counterpart is read_expected_ndx_done
called by exchange_phase_done. The legacy-codec EOF / garbage tests
therefore target read_expected_ndx_done directly; the modern-codec
tests target handle_goodbye directly.

Updates docs/audits/edg-goodbye-contract.md with a new
"Timeout + partial-cutoff (EDG-GOODBYE.4)" section that enumerates
the covered cases and the regressions they guard against.

Upstream reference: main.c:893-924 read_final_goodbye() - exits
with RERR_PROTOCOL on a non-NDX_DONE final read and propagates I/O
errors from read_int / read_ndx_and_attrs on short reads.
@github-actions github-actions Bot added the test label Jun 10, 2026
@oferchen
oferchen merged commit aa0d927 into test/edg-goodbye-contract Jun 11, 2026
36 of 37 checks passed
@oferchen
oferchen deleted the test/edg-goodbye-4-partial-cutoff-timeout branch June 11, 2026 03:11
oferchen added a commit that referenced this pull request Aug 24, 2026
…off-timeout

test(receiver): EDG-GOODBYE.4 partial-cutoff + hung-sender goodbye tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant