| Layer | Tool | Command | Notes |
|---|---|---|---|
| Contracts | cargo test |
cd contracts && cargo test |
Unit + integration, reentrancy snapshots, yield math |
| Backend | cargo test |
cd backend && cargo test |
API, KYC webhooks, inactivity watchdog, DB query guards |
| Frontend unit | Vitest | cd frontend && pnpm test |
Component + store tests |
| Frontend e2e | Playwright | cd frontend && pnpm test:e2e |
Full user flows with mocked anchor service |
| Security/lint | Clippy + ESLint | see Lint below | Gates on CI |
cd contracts
cargo testKey coverage areas:
- Reentrancy attack failing via the RAII guard (snapshot-based regression test).
- Yield accrual and basis-point splits across beneficiary configurations.
- Access-control role enforcement.
- Loan NFT transfer restrictions while loans are active.
cd backend
cargo test --no-default-featuresIntegration tests live in backend/tests/:
api_tests.rs— routing, CORS origin validation, plan flows.kyc_webhook_test.rs— HMAC signature verification and payload handling.inactivity_watchdog_db_test.rs— watchdog behaviour against a test database.db_query_guards_test.rs— query timeout/slow-query guards.middleware_tests.rs— rate limiting, geo-restriction, security headers.
Tests use
postgres://postgres:postgres@localhost:5432/xourcex_testwhen an integration database is required. Start one withdocker compose up -d postgres.
cd frontend
pnpm install # base deps
pnpm test # unit tests (Vitest)
pnpm install --optional
pnpm test:e2e # e2e (Playwright) — requires optional depsComponent tests include the inactivity timer card and wallet modal. E2E fixtures mock
wallets and the anchor service (frontend/tests/e2e/fixtures, frontend/tests/mocks).
# Rust
cd backend && cargo clippy --all-targets --all-features -- -D warnings
cd contracts && cargo clippy --all-targets --all-features -- -D warnings
# Frontend
cd frontend && pnpm lintcargo fmt/Prettier formatting is enforced as well (make fmt).
GitHub Actions runs the contractual matrix on every push/PR:
backend.yml,contracts.yml,frontend.yml— build + test for each layer.sast.yml— CodeQL static analysis.
See make test for a local shortcut.