Skip to content

test: tighten suite per #37 (E2E protobuf, stats isolation, dedup, parametrize)#42

Merged
eric-becker merged 4 commits into
mainfrom
feat/issue-37-test-tightening
May 2, 2026
Merged

test: tighten suite per #37 (E2E protobuf, stats isolation, dedup, parametrize)#42
eric-becker merged 4 commits into
mainfrom
feat/issue-37-test-tightening

Conversation

@eric-becker
Copy link
Copy Markdown
Owner

@eric-becker eric-becker commented May 2, 2026

Summary

Picks up the test-suite tightening checklist in #37, scoped to the items that
remained applicable after the integration harness landed in #40.

Audit results:

Item Outcome
Real-protobuf zerohop E2E unit test DoneTestProcessMessageUnmockedProtobuf previously only had the anonymized-fixture smoke path; #40's harness is a separate Docker process and doesn't cover the in-process path.
TestAntifloodStats per-test fresh stats Done — replaced the setup_method that mutated module state with a fixture that monkeypatches a fresh AntifloodStats instance.
Move 3 health-shape tests out of test_container_smoke.py Done — deleted; test_health.py already covers JSON validity, stats keys, and 404 against an in-process server (no Docker rebuild).
Collapse TestLoadConfigDefaults into parametrize Done — 8 cases collapsed into test_default_value; 3 cases that don't fit a key → value shape kept standalone.
Collapse test_log_setup.py happy-path tests Skipped — issue marks "Lower priority… don't cost much."
Replace mocked TestProcessMessage with synthetic envelopes Skipped — issue marks "Bigger refactor; only worth doing if you're already in that area." Item 1 closes the protobuf-coverage gap that was the main motivation.

One conventional commit per item so each is independently reviewable.

Test plan

  • python -m pytest tests/ --ignore=tests/test_container_smoke.py --ignore=tests/integration -q → 201 passed locally
  • ruff check src/ tests/ → clean
  • CI lint + unit tests across Python 3.11/3.12/3.13 pass
  • CI smoke job passes (only 3 Docker-specific tests now)
  • CI integration job passes
  • CI manifests job passes

Closes #37.

🤖 Generated with Claude Code

Eric Becker added 4 commits May 2, 2026 07:48
The TestProcessMessageUnmockedProtobuf suite previously covered only
the anonymized-fixture smoke path (envelopes whose ciphertext no longer
decrypts). Add a synthetic-envelope test that builds a real encrypted
ServiceEnvelope with hop_limit=3, drives it through process_message,
and verifies the returned ACTION_MODIFY payload re-parses with
hop_limit=0 and an inner Data message that still decrypts cleanly.

Extends the shared _build_encrypted_envelope helper in test_portnum.py
with a hop_limit kwarg so both portnum-extraction and zerohop tests
can construct envelopes with the field set.

Refs #37.
The previous setup_method reset the live module-level
floodgate.zerohop.stats instance in place, which is safe under
sequential pytest but would race under pytest-xdist. Replace it with
a fixture that constructs a fresh AntifloodStats and monkeypatches it
onto the module for the lifetime of each test, then yields it for the
test to operate on directly.

Refs #37.
test_health_body_is_valid_json, test_health_body_has_stats, and
test_unknown_path_returns_404 are already covered by test_health.py
against an in-process health server. Running them again under the
smoke marker forces a Docker rebuild for assertions that don't need
the container, costing ~30s on every smoke job. Smoke is now scoped
to Docker-specific facts only: image builds, /health responds, and
the container runs as a non-root user.

Refs #37.
Eight TestLoadConfigDefaults methods asserted "the default value of
key X is Y" individually. Collapse them into one parametrized
test_default_value, leaving the cases that genuinely diverge from the
key->value pattern (eight-preset assertion, derived-set assertions)
as their own methods.

Refs #37.
@eric-becker eric-becker merged commit a8ddca3 into main May 2, 2026
8 checks passed
@eric-becker eric-becker deleted the feat/issue-37-test-tightening branch May 2, 2026 08:09
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.

test: tighten test suite (reduce bloat, add missing protobuf E2E)

1 participant