WIP: TFChain WebSocket auto-reconnect and health endpoint #13

Closed
mik-tf wants to merge 0 commits from fix/tfchain-reconnect into development
Member

Summary

  • TFChain WebSocket auto-reconnect: Arc<RwLock<Client>> with background health check every 30s, automatic reconnect on failure
  • Health endpoint: GET /api/health returns chain status, network, latest block number (or 503 if disconnected)
  • Enhanced smoke tests: 32 tests (was 21) — validates response fields/values, not just HTTP status codes
  • E2E post-login data verification: 7 new tests confirm real TFChain + Hero Ledger data loads after wallet login (Connected state, TFChain address, TFT balance, SPORE balance, Mycelium Ledger status)
  • Shared login helper: Extract login flow into e2e/tests/helpers/login.ts to eliminate duplication across 3 test files

Test Status

Suite Count Status
Cargo unit/integration 56 All pass
TFChain smoke tests 32 All pass
Gateway smoke tests 7 All pass
E2E Playwright 13 All pass

Files Changed

Backend (reconnect + health):

  • crates/backend/Cargo.toml — tokio sync+time features
  • crates/backend/src/state.rsArc<RwLock<Client>>, check_chain_health(), reconnect()
  • crates/backend/src/api.rs — read locks on all handlers, API clone for submits, health_check endpoint
  • crates/backend/src/main.rs — background health task, /api/health route

Smoke tests:

  • scripts/smoke-test.sh — 11 new tests (health, balance numerics, transfer prepare fields/errors)

E2E tests:

  • e2e/tests/helpers/login.ts — shared login helper (new)
  • e2e/tests/post-login-data.spec.ts — 7 data verification tests (new)
  • e2e/tests/wallet-connect.spec.ts — refactored to use helper
  • e2e/tests/vault-flow.spec.ts — refactored to use helper

Closes #12

🤖 Generated with Claude Code

## Summary - **TFChain WebSocket auto-reconnect**: `Arc<RwLock<Client>>` with background health check every 30s, automatic reconnect on failure - **Health endpoint**: `GET /api/health` returns chain status, network, latest block number (or 503 if disconnected) - **Enhanced smoke tests**: 32 tests (was 21) — validates response fields/values, not just HTTP status codes - **E2E post-login data verification**: 7 new tests confirm real TFChain + Hero Ledger data loads after wallet login (Connected state, TFChain address, TFT balance, SPORE balance, Mycelium Ledger status) - **Shared login helper**: Extract login flow into `e2e/tests/helpers/login.ts` to eliminate duplication across 3 test files ## Test Status | Suite | Count | Status | |-------|-------|--------| | Cargo unit/integration | 56 | All pass | | TFChain smoke tests | 32 | All pass | | Gateway smoke tests | 7 | All pass | | E2E Playwright | 13 | All pass | ## Files Changed **Backend (reconnect + health):** - `crates/backend/Cargo.toml` — tokio sync+time features - `crates/backend/src/state.rs` — `Arc<RwLock<Client>>`, `check_chain_health()`, `reconnect()` - `crates/backend/src/api.rs` — read locks on all handlers, API clone for submits, `health_check` endpoint - `crates/backend/src/main.rs` — background health task, `/api/health` route **Smoke tests:** - `scripts/smoke-test.sh` — 11 new tests (health, balance numerics, transfer prepare fields/errors) **E2E tests:** - `e2e/tests/helpers/login.ts` — shared login helper (new) - `e2e/tests/post-login-data.spec.ts` — 7 data verification tests (new) - `e2e/tests/wallet-connect.spec.ts` — refactored to use helper - `e2e/tests/vault-flow.spec.ts` — refactored to use helper Closes #12 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat: add TFChain WebSocket auto-reconnect and health endpoint
All checks were successful
Test / check (pull_request) Successful in 2m2s
b8aac78f9f
The backend WebSocket connection to TFChain would die permanently on
disconnect (os error 54). Now:

- Client wrapped in RwLock for safe reconnection
- Background task checks chain health every 30s, auto-reconnects on failure
- GET /api/health returns chain status + latest block number (503 if disconnected)
- Submit handlers clone the API handle to avoid blocking reconnect during finalization
- Enhanced smoke tests: health endpoint, balance numerics, transfer prepare fields

32/32 smoke tests pass, 56/56 cargo tests pass, 6/6 E2E tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat: add post-login E2E data verification tests
All checks were successful
Test / check (pull_request) Successful in 2m58s
d0cc834965
Add 7 new E2E tests that verify real TFChain + Hero Ledger data loads
after wallet login — not just crash absence. Extract shared login helper
to eliminate code duplication across 3 test files. Total: 13 E2E tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mik-tf closed this pull request 2026-02-27 17:44:07 +00:00
All checks were successful
Test / check (pull_request) Successful in 2m58s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mycelium/www_migrate_mycelium!13
No description provided.