Skip to content

test(bridge_api): add 67 unit tests for Bridge API [T10]#6326

Open
waefrebeorn wants to merge 45 commits into
Scottcjn:mainfrom
waefrebeorn:test-bridge-api-t10
Open

test(bridge_api): add 67 unit tests for Bridge API [T10]#6326
waefrebeorn wants to merge 45 commits into
Scottcjn:mainfrom
waefrebeorn:test-bridge-api-t10

Conversation

@waefrebeorn
Copy link
Copy Markdown

@waefrebeorn waefrebeorn commented May 25, 2026

T10 \u2014 bridge_api.py test coverage (HIGH criticality)\n\n67 unit tests for (997 lines) \u2014 was 0% coverage, now covered.\n\n### Test categories:\n| Category | Tests | Key coverage |\n|----------|-------|-------------|\n| Enums & Data | 6 | Directions, statuses, lock types, request/validation dataclasses |\n| validate_bridge_request | 15 | Full validation pipeline with 10+ edge cases |\n| validate_chain_address_format | 12 | rustchain, solana, ergo, base address validation |\n| generate_bridge_tx_hash | 3 | Deterministic 32-char SHA-256 hash |\n| check_miner_balance | 4 | Empty, sufficient, insufficient, pending debits subtracted |\n| CRUD operations | 11 | Create, get, list (with filter), void, update confirmation |\n| _parse_non_negative_int_arg | 5 | Valid, None, negative, non-numeric, max_value clamp |\n| DB schema | 2 | Creates bridge_transfers table, idempotent |\n| Module fallbacks | 5 | current_slot, slot_to_epoch, validate_miner_id_format |\n\nAll 67 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
Covers 997-line module:
- Enums (BridgeDirection, BridgeStatus, LockType, LockStatus) - 4 tests
- Dataclasses (BridgeTransferRequest, ValidationResult) - 2 tests
- validate_bridge_request (full pipeline: valid, missing, direction,
  chain, address, amount, memo, bridge_type) - 15 tests
- validate_chain_address_format (rustchain, solana, ergo, base) - 12 tests
- generate_bridge_tx_hash (deterministic, 32-char) - 3 tests
- check_miner_balance (empty, sufficient, insufficient, pending debits) - 4 tests
- create_bridge_transfer (create, amount conversion, tx_hash, reject) - 4 tests
- get_bridge_transfer_by_hash (found, not found) - 2 tests
- list_bridge_transfers (empty, list, direction filter) - 3 tests
- void_bridge_transfer (void, nonexistent) - 2 tests
- update_external_confirmation - 1 test
- _parse_non_negative_int_arg - 5 tests
- init_bridge_schema - 2 tests
- Fallback module defaults - 5 tests

67 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
…approvals (113/400 cells, 55 PRs, 19 jaxint-approved)
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 code looks clean and well-structured. Thanks for contributing to RustChain! 🦀

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.

Thanks for contributing! 🦀

Code looks good. Keep it up! 🚀


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! Thanks for contributing to RustChain! 🦀

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! Thanks for contributing to RustChain! 🦀

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 code looks clean and well-structured.

Review powered by RustChain Bounty Program

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! Thanks for contributing to RustChain! 🦀

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 Bridge API test coverage. I ran the focused suite and the new test file itself looks healthy, but the branch needs cleanup before merge.

Findings:

  • The PR title is a focused Bridge API test addition, but the branch changes 21 files. Besides node/tests/test_bridge_api.py, it includes BATTLESHIP_PROGRESS.md, README.md, faucet/dashboard/bot files, node/beacon_x402.py, node/machine_passport_api.py, rips/rustchain-core/api/rpc.py, and other unrelated modules. That makes a test-only PR much harder and riskier to merge.
  • git diff --check HEAD~35..HEAD fails on trailing whitespace in BATTLESHIP_PROGRESS.md and node/machine_passport_api.py.

Validation performed:

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/python -m pytest node/tests/test_bridge_api.py -q
-> 67 passed in 0.12s

.venv/bin/python -m py_compile node/tests/test_bridge_api.py bridge/bridge_api.py
-> passed

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

If the unrelated files are split out or removed and the whitespace is fixed, this focused Bridge API test coverage 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