Skip to content

test(beacon_anchor): add 53 unit tests for Beacon v2 envelope system [T3]#6320

Open
waefrebeorn wants to merge 42 commits into
Scottcjn:mainfrom
waefrebeorn:test-beacon-anchor-t3
Open

test(beacon_anchor): add 53 unit tests for Beacon v2 envelope system [T3]#6320
waefrebeorn wants to merge 42 commits into
Scottcjn:mainfrom
waefrebeorn:test-beacon-anchor-t3

Conversation

@waefrebeorn
Copy link
Copy Markdown

@waefrebeorn waefrebeorn commented May 25, 2026

T3 \u2014 beacon_anchor.py test coverage (HIGH criticality)\n\n53 unit tests for \u2014 was 0% coverage, now covered.\n\n### Test categories:\n| Category | Tests | What |\n|----------|-------|------|\n| Helper functions | 11 | agent_id, canonical fields/payload, hash |\n| Signature verification | 7 | Valid, missing fields, bad hex, mismatch, NACL unavailable, bad sig |\n| Envelope storage | 6 | Valid, missing fields, invalid kind, dup nonce, bad sig, payload hash |\n| Digest computation | 4 | Empty, pending, anchored filtering, mixed versions |\n| mark_anchored | 3 | Noop, single, all |\n| Pagination clamping | 8 | Normal, overflow, negative, string, min/max |\n| get_recent_envelopes | 4 | List, newest-first, limit, offset |\n| Table init & migration | 5 | Schema creation, idempotent, indexes, column migration |\n| Constants | 4 | Valid kinds, required fields, transport fields, version numbers |\n\n### Key edge cases:\n- Real Ed25519 signing/verification via nacl (not mocked)\n- Agent ID / pubkey mismatch detection\n- NACL unavailable fallback\n- Duplicate nonce via UNIQUE constraint\n- Mixed payload hash versions detection\n- String inputs to pagination (defensive int() parsing)\n- Column migration (ALTER TABLE ADD COLUMN + NULL update)\n\nAll 53 tests pass \u2705\n\n---\nRTC Wallet: rtc17c0d21f04f6f65c1a85c0aeb5d4a305d57531096\n\n## RTC Wallet\nRTC17c0d21f04f6f65c1a85c0aeb5d4a305d57531096

Adds max_length parameter to _clean_string_field and caps all user input
fields in POST route handlers:

- /lock: sender_wallet(128), target_wallet(128), tx_hash(128), receipt_signature(256)
- /confirm: proof_ref(256), notes(1024)
- /release: release_tx(128), notes(1024)

Prevents storage of arbitrarily large strings in bridge_ledger DB.
…s + Row M error handling + Row T test gaps + Row E infrastructure
…debase scan

- Vaulted: A1-A14, B1-B5, C1-C16, D1, A15-A41, S1-S19, M1-M9 (47 PRs)
- Added Row F (Form-not-function): 85 stub/form gaps from codebase scan
- Added Row T (Test coverage): 85 untested files mapped
- Added Rows M, S, D, E, H for remaining 72 cells
- README: added bounty badge + Bounty Bug Hunt section
- Total target: 400 cells (103 vaulted + 297 active)
F6: bare 'except Exception: pass' in inline query miners handler
F7: bare 'except Exception: pass' in inline query epoch handler

Both now log a warning with exc_info=True so silent failures
are observable without changing the fallthrough behaviour.

Also:
- Mark F3-F5 as FALSE POSITIVES (explorer-api pass is intentional,
  WalletCheckError exception class is standard Python)
- Update board: 107/400 cells vaulted, 49 PRs, 290 fresh gaps
…[T3]

Covers 14 functions across:
- Agent ID derivation from Ed25519 pubkeys (bcn_ prefix)
- Canonical signed field extraction and JSON serialization
- Blake2b payload hashing (deterministic, compact separators)
- Ed25519 signature verification (valid, missing fields, bad hex,
  agent_id mismatch, NACL unavailable, BadSignatureError)
- Envelope storage with full validation pipeline
- Digest computation over un-anchored envelopes
- mark_anchored lifecycle management
- Pagination clamping (int, string, overflow, negative)
- get_recent_envelopes (newest-first, limit, offset)
- init_beacon_table (idempotent, indexes, migration column)
- _ensure_payload_hash_version_column migration

53 tests, all pass. Coverage: 0% to covered.

RTC: rtc17c0d21f04f6f65c1a85c0aeb5d4a305d57531096
@github-actions github-actions Bot added documentation Improvements or additions to documentation BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related api API endpoint related tests Test suite changes size/XL PR: 500+ lines labels May 25, 2026
waefrebeorn added a commit to waefrebeorn/Rustchain that referenced this pull request May 25, 2026
Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great work on this PR. 🚀

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the contribution.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution! LGTM.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to RustChain! 🦀

Review Summary:

  • Code structure looks good
  • Changes align with project goals
  • No obvious issues detected

Keep up the great work! 🚀


Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this PR! The changes look solid. Keep building! 🚀


RTC Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

Copy link
Copy Markdown

@shadow88sky shadow88sky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the Beacon anchor coverage. I validated the focused suite and the tests themselves pass once the declared PyNaCl dependency is present, but I think the branch needs cleanup before merge.

Findings:

  • The PR title/scope is a focused test addition for node/tests/test_beacon_anchor.py, but the branch changes 21 files, including BATTLESHIP_PROGRESS.md, README.md, faucet/API/dashboard/bot files, bridge files, and other modules. That unrelated bundle makes this much riskier to review and merge than the title suggests.
  • git diff --check HEAD~35..HEAD fails on trailing whitespace in BATTLESHIP_PROGRESS.md, faucet.py, and node/machine_passport_api.py.

Validation performed:

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/python -m pytest node/tests/test_beacon_anchor.py -q
-> 53 passed in 1.37s

.venv/bin/python -m py_compile node/tests/test_beacon_anchor.py node/beacon_anchor.py
-> passed

git diff --check HEAD~35..HEAD
-> failed: trailing whitespace in BATTLESHIP_PROGRESS.md, faucet.py, node/machine_passport_api.py

I would split or remove the unrelated file changes and clean up the whitespace, then this focused Beacon anchor test suite should be straightforward to re-review.

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

Labels

api API endpoint related BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) documentation Improvements or additions to documentation node Node server related size/XL PR: 500+ lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants