test: tighten suite per #37 (E2E protobuf, stats isolation, dedup, parametrize)#42
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
TestProcessMessageUnmockedProtobufpreviously only had the anonymized-fixture smoke path; #40's harness is a separate Docker process and doesn't cover the in-process path.TestAntifloodStatsper-test fresh statssetup_methodthat mutated module state with a fixture that monkeypatches a freshAntifloodStatsinstance.test_container_smoke.pytest_health.pyalready covers JSON validity, stats keys, and 404 against an in-process server (no Docker rebuild).TestLoadConfigDefaultsinto parametrizetest_default_value; 3 cases that don't fit akey → valueshape kept standalone.test_log_setup.pyhappy-path testsTestProcessMessagewith synthetic envelopesOne 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 locallyruff check src/ tests/→ cleanCloses #37.
🤖 Generated with Claude Code