Skip to content

[SOLUTION] Add protocol frame codec recovery tests for $50 bounty#25

Open
feezy1357 wants to merge 4 commits into
Peter7896:mainfrom
feezy1357:main
Open

[SOLUTION] Add protocol frame codec recovery tests for $50 bounty#25
feezy1357 wants to merge 4 commits into
Peter7896:mainfrom
feezy1357:main

Conversation

@feezy1357

Copy link
Copy Markdown

Solution for [$50 BOUNTY] Add protocol frame codec recovery tests

Changes

Added comprehensive recovery and regression tests to backend/src/protocol/codec.rs:

Truncated frame rejection (no panic):

  • Truncated header (partial 24-byte header)
  • Truncated payload (missing last bytes)
  • Empty input, single byte, header-only frame

Invalid size rejection:

  • Oversized payload (>16MB) → MessageTooLarge error

Version validation:

  • Version below minimum → UnsupportedVersion
  • Version above maximum → UnsupportedVersion

Integrity checks:

  • Checksum mismatch → ChecksumMismatch error
  • Frame without checksum flag has checksum = None

Decoder state preservation:

  • Failed decode does not corrupt decoder
  • Error clears consumed data correctly

Recovery after failure:

  • Valid frame decodes successfully after checksum failure
  • Valid frame decodes after oversized frame rejection
  • Interleaved valid/invalid/valid all handled

Determinism:

  • Same input produces same output (tested 5x)

All tests are deterministic and platform-independent.

Closes #2

jackjin1997 and others added 4 commits June 17, 2026 04:39
Adds comprehensive tests for AuthMiddleware, RateLimitMiddleware,
token bucket, middleware ordering, and the full middleware chain.

- AuthMiddleware tests: missing/empty/valid/invalid tokens
- RateLimitMiddleware tests: under/over limit, per-client buckets
- Middleware ordering: auth before rate limiting
- Token bucket unit tests: initial state, refill, empty
- Token extraction: Bearer, API-Key, precedence

Fixes jackjin1997#2
Adds comprehensive recovery and regression tests:
- Reject truncated headers/payloads without panicking
- Reject excessive payload lengths with clear errors
- Reject unsupported versions
- Verify checksum mismatch yields clear errors
- Assert failed decode doesn't corrupt decoder state
- Confirm valid frame after invalid input still decodable
- Deterministic tests runnable on all platforms

Fixes Peter7896#2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[$50 BOUNTY] [Rust] Add protocol frame codec recovery tests

2 participants