test: fix 3 stale test files drifted from security hardening (21 failures)#6658
Merged
Merged
Conversation
Three integration tests broke against intended hardening (red main, not regressions): 1. test_tx_handler_limits (16): /tx/pending + /wallet/<a>/history GET endpoints are admin-gated since #6295. Tests called them anonymously and got 401 before reaching the limit/validation logic under test. Fixture now sets RC_ADMIN_KEY (via monkeypatch, auto-restored) and sends X-Admin-Key on every request. 2. test_wallet_network_utils (4): _fetch_with_retry now uses allow_redirects=False + resp.is_redirect (SSRF/redirect hardening). Bare MagicMock responses have a truthy is_redirect, so the code treated them as redirects and returned None. Mocks now set is_redirect = False. 3. test_utxo_security_audit::test_genesis_rerun_blocked (1): check_existing_genesis keys off tx_type='genesis', but the test inserted a mining_reward tx at height 0. Now inserts a real genesis-typed tx, mirroring test_rollback_then_remigrate_idempotent. All production code is correct; only the tests were stale. 52/52 pass in these files (was 21 failing). Verified self-contained (no external env). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Contributor
✅ BCOS v2 Scan Results
What does this mean?The BCOS (Beacon Certified Open Source) engine scans for:
BCOS v2 Engine - Free & Open Source (MIT) - Elyan Labs |
darlina-bounty-codex
approved these changes
May 30, 2026
Contributor
darlina-bounty-codex
left a comment
There was a problem hiding this comment.
I reviewed the three touched test files against the current route/helper behavior.
Local validation:
py_compilepassed fortests/test_tx_handler_limits.py,tests/test_wallet_network_utils.py, andtests/test_utxo_security_audit.pyusing the bundled Python runtime.git diff --check origin/main...HEAD -- tests/test_tx_handler_limits.py tests/test_wallet_network_utils.py tests/test_utxo_security_audit.pypassed for the touched files.- I could not run the pytest target set in this environment because
pytestis not installed in the bundled Python runtime.
Technical observations:
- The
test_tx_handler_limitsfixture change is directionally correct: these endpoints are now admin-gated byrequire_admin(), which readsX-Admin-KeyandRC_ADMIN_KEY. Settingclient.environ_base["HTTP_X_ADMIN_KEY"]exercises the intended limit/validation paths instead of failing early at the auth gate, whilemonkeypatchkeeps the key scoped to the test. - Setting
MagicMock.is_redirect = Falsein the wallet network tests is needed after the redirect guard because unspecifiedMagicMockattributes are truthy. Without the explicit false value, these success-path mocks can accidentally simulate a redirect and test the wrong branch. - The genesis rerun test correction matches the actual invariant better:
check_existing_genesisis keyed totx_type='genesis', so inserting a real genesis transaction is a more direct regression test than using amining_rewardtransaction at height 0. It also lines up with the later rollback/remigrate setup pattern.
I do not see a blocker in the touched test changes. If maintainers want tighter follow-up coverage later, a focused negative test for wrong/missing X-Admin-Key on one of these GET routes would document the auth gate separately, but that is outside this stale-test-fix PR.
I received RTC compensation for this review.
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.
Fixes 3 stale test files (21 failures) on red main — all test-only, production code unchanged:
52/52 pass in these files (was 21 failing), verified against current main, self-contained.
Remaining ~31 failures triaged separately (mostly same auth-drift pattern + a stale miners/checksums.sha256 for the linux miner that affects real installer integrity).
🤖 Generated with Claude Code