Skip to content

test: stop test_utxo_security_audit overwriting RC_ADMIN_KEY (unblocks CI) - #8467

Merged
Scottcjn merged 1 commit into
mainfrom
fix/ci-short-admin-key-collection-exit
Sep 18, 2026
Merged

Scottcjn merged 1 commit into
mainfrom
fix/ci-short-admin-key-collection-exit

Conversation

@Scottcjn

Copy link
Copy Markdown
Owner

The CI test job has failed on every Rustchain PR since 9/14. It wasn't flakiness: pytest collection itself was aborting.

Cause

#8393 added this at import time in tests/test_utxo_security_audit.py:

os.environ["RC_ADMIN_KEY"] = "test-rollback-admin-key-2819"   # 28 chars

The node refuses any key shorter than 32 characters with sys.exit(1) (rip200.py:8870). So the first later test module that imports the node (test_vintage_g5_and_qube.py) raised SystemExit, pytest reported INTERNALERROR, and zero tests ran. I found this by bisecting over the 465 test files collected before the crashing one. The overwrite also leaked into later tests that send conftest's "0"*32 key, so they got 401s (test_wallet_review_holds ×2, test_miner_headerkey_schema).

Fix

Use the suite-wide key that tests/conftest.py already sets (via setdefault, so the file still runs on its own), and pass the same value to rollback_genesis(). The change is one file.

Verification

I ran the exact CI command locally, with the CI env and tests/requirements.txt:

Result
main collection INTERNALERROR (SystemExit: 1), 0 tests run
this PR 4009 passed, 2 failed, 45 skipped

The lint step (ruff check tests --select E9,F63,F7,F82) passes.

The 2 remaining failures (pre-existing, out of scope)

test_utxo_dual_write_double_spend and test_utxo_transfer_spends_account_mirror fail on their own on main too. The security property still holds: the mirror box is not spent. But the endpoint now returns 400 "Insufficient UTXO balance" (balance 100, requested 99) instead of 409 ACCOUNT_MIRROR_BOX_NOT_SPENDABLE. Coin selection filters mirror boxes out before the specific check can fire, so users get a misleading error. That's worth a follow-up; it isn't fixed here.

This should merge before #8465 and other PRs, so their CI results mean something again.

🤖 Generated with Claude Code

…s CI)

#8393 set os.environ["RC_ADMIN_KEY"] = "test-rollback-admin-key-2819" at
import time. That value is 28 chars; the node sys.exit(1)s on a key < 32
chars, so every later test module that imports the node aborted pytest
collection and the CI "test" job has failed on every PR since 9/14. The
overwrite also leaked into later tests that send conftest's key (401s).

Use the suite-wide key from tests/conftest.py (setdefault, so the file
still runs standalone) and pass that same value to rollback_genesis().

Local run of the exact CI command (CI env + tests/requirements.txt):
  before: collection INTERNALERROR (SystemExit: 1), 0 tests run
  after:  4009 passed, 2 failed
The 2 remaining failures (test_utxo_dual_write_double_spend,
test_utxo_transfer_spends_account_mirror) fail standalone on main and are
unrelated: mirror boxes are now filtered before the 409
ACCOUNT_MIRROR_BOX_NOT_SPENDABLE check, so the endpoint returns 400
"Insufficient UTXO balance" instead. The box is still not spent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Scott <scottbphone12@gmail.com>
@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) tests Test suite changes size/S PR: 11-50 lines labels Sep 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ BCOS v2 Scan Results

Metric Value
Trust Score 36/100
Certificate ID BCOS-0e151b69
Tier L1 (not met)

BCOS Badge

What does this mean?

The BCOS (Beacon Certified Open Source) engine scans for:

  • SPDX license header compliance
  • Known CVE vulnerabilities (OSV database)
  • Static analysis findings (Semgrep)
  • SBOM completeness
  • Dependency freshness
  • Test infrastructure evidence
  • Review attestation tier

Full report | What is BCOS?


BCOS v2 Engine - Free & Open Source (MIT) - Elyan Labs

@github-actions

Copy link
Copy Markdown
Contributor

RTC Reward

This merged PR earned 5 RTC — sent to Scottcjn.

RustChain Bounty Program

Scottcjn added a commit that referenced this pull request Sep 18, 2026
…isleading 400 (#8468)

Since #8395, account-mirror boxes are excluded inside
get_coin_select_candidates() before candidate bounding, so the
mirror_candidate_ids branch in /utxo/transfer can never fire. A sender
whose funds are mirror-locked got 400 "Insufficient UTXO balance" while
the same response reported balance_nrtc >= requested_nrtc.

On a failed selection, decide from wallet totals: if the spendable
(non-mirror) funds fall short but the mirror-locked ones would cover the
request, return the 409 with the box ids; otherwise the plain 400, now
with spendable_nrtc. Totals are wallet-wide (SQL SUM), not the bounded
candidate list, so #8395's false-409 cannot return. No state change: this
only runs after coin selection has already failed.

Fixes the two long-failing tests (test_utxo_dual_write_double_spend,
test_utxo_transfer_spends_account_mirror) and adds a guard that a request
beyond the whole wallet stays a plain 400. Full CI suite (with #8467's
collection fix applied locally): 4012 passed, 0 failed.

Signed-off-by: Scott <scottbphone12@gmail.com>
Co-authored-by: Scott <scottbphone12@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Scottcjn pushed a commit that referenced this pull request Sep 27, 2026
Branch was based on aa584b3 and predates #8467 (test_utxo_security_audit
overwrote RC_ADMIN_KEY), which made the node module sys.exit(1) at import
during pytest collection (tests/test_vintage_g5_and_qube.py) and crashed the
whole CI test job. Bringing main in picks up that fix; no change to the PR's
own diff.

Signed-off-by: Scott <scottbphone12@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scottcjn pushed a commit that referenced this pull request Sep 27, 2026
Picks up main's CI fixes (e.g. #8467 RC_ADMIN_KEY test leak and the
refreshed installer checksum manifest) that the stale branch was missing.

Signed-off-by: Scott <scottbphone12@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scottcjn pushed a commit that referenced this pull request Sep 27, 2026
Picks up main's CI fixes (e.g. #8467 RC_ADMIN_KEY test leak and the
refreshed installer checksum manifest) that the stale branch was missing.

Signed-off-by: Scott <scottbphone12@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants