QA Overview
This guide describes how to test the Verifluence platform end-to-end — covering environment setup, the three test layers, and the key user flows to verify before any release.
Test Layers
| Layer | Tool | Scope |
|---|---|---|
| Smart contract | Foundry (forge test) | HTLC deposit / allocation / withdrawal / refund logic |
| API | Manual / curl | REST endpoints, auth, DB side-effects |
| Frontend | Manual (browser) | Full user flows per role |
There are currently no automated API or frontend test suites. Contract tests are the only automated coverage.
1. Smart Contract Tests
The HTLC contract has a full Foundry test suite (test/HTLC.t.sol).
bash
# Run all tests
forge test
# Verbose output with gas report
forge test -vvv --gas-report
# Run a specific test
forge test --match-test test_allocate_single_slot -vvvCoverage areas:
| Group | Tests |
|---|---|
| Deposits | ETH and ERC-20 (USDC), edge cases |
| Allocations | Single/multi-slot, variable amounts, permission checks |
| Withdrawals | Single-slot, multi-slot, batch |
| Refunds | Allocation-level and deposit-level |
| Integration | Full lifecycle (deposit → allocate → withdraw → refund) |
| Fuzz | Random inputs on core operations |
All tests must pass before any contract deployment or upgrade.
2. Local Environment Setup
Prerequisites
- Node.js ≥ 20, pnpm
- Foundry (
forge,anvil) - PostgreSQL (local or remote)
- Pusher account (for real-time notifications)
Start the stack
bash
# 1. Install dependencies
pnpm install
# 2. Copy and fill in env files
cp api/.env.example api/.env
cp frontend/.env.example frontend/.env
# 3. Start a local Ethereum node
anvil
# 4. Deploy the HTLC contract to Anvil
forge script script/DeployAnvil.s.sol --broadcast --rpc-url http://127.0.0.1:8545
# 5. Start the API
pnpm --filter api dev # http://localhost:3000
# 6. Start the frontend
pnpm dev:frontend # http://localhost:6020Key env vars (API)
| Variable | Purpose |
|---|---|
DATABASE_URL | PostgreSQL connection string |
KICK_CLIENT_ID / SECRET | Kick OAuth for streamer login |
X_CLIENT_ID / SECRET | Twitter/X OAuth |
PUSHER_* | Real-time notification channels |
RESEND_API_KEY | Transactional email |
S3_* | KYC document storage (Hetzner) |
ADMIN_SECRET | Admin-only endpoint access |
Key env vars (Frontend)
| Variable | Purpose |
|---|---|
VITE_NETWORK_SEPOLIA | Network config string (chainId, contract address, RPC URL, explorer) |
VITE_DEFAULT_NETWORK | ANVIL for local, SEPOLIA for staging/prod |
VITE_API_URL | API base URL (empty = Vite proxy) |
3. Manual Test Flows
Operator flow
- Sign in — log in with a test operator account
- Create campaign — set name, category, budget cap, dates
- Deposit funds — connect MetaMask (Sepolia or Anvil), deposit USDC into escrow; confirm the deposit ID is stored
- Invite or approve a streamer — send an operator-initiated offer or accept a streamer application
- Negotiate terms — step through at least one round of counter-offers; verify term state updates
- Allocate funds — open the allocation modal from the Negotiations page (Waiting Funding tab), allocate to the agreed streamer; confirm on-chain tx completes and the deal row is created
- Refund — after timelock expires, reclaim an unclaimed allocation; verify available balance increases
Streamer flow
- Sign up / log in — OAuth via Kick or X
- Complete profile — add wallet address (required for payouts)
- Apply to campaign — submit application with message
- Accept operator invite — if invited, accept the offer to start negotiation
- Negotiate terms — counter-propose, then agree
- View deal — confirm allocation appears in wallet view with correct amounts
- Submit stream proof — submit session evidence for a slot
- Claim payout — withdraw earnings; verify wallet balance increases on-chain
Negotiation edge cases
| Scenario | Expected behaviour |
|---|---|
| Operator-initiated offer → allocation | Allocation modal opens without "Could not locate application record" error |
| Streamer-initiated offer → allocation | Same — both paths must work |
| Agreed negotiation, streamer has no wallet | Allocation blocked with clear error |
| Connected wallet ≠ deposit sender | Allocation blocked with wallet mismatch error |
| Insufficient unallocated balance | Allocation blocked with available-vs-requested breakdown |
4. Staging / Production Checklist
Before deploying to production (Sepolia + Cloudflare Pages):
- [ ]
forge testpasses with zero failures - [ ] RPC URL resolves and responds (
https://rpc.ankr.com/eth_sepolia) - [ ] Google Fonts load without CSP errors (
fonts.googleapis.com+fonts.gstatic.comin_headers) - [ ] MetaMask connects on Sepolia (chain ID 11155111)
- [ ] Full operator flow completes (deposit → allocate)
- [ ] Full streamer flow completes (apply → claim)
- [ ] Pusher real-time notifications fire on negotiation updates
- [ ] Sentry captures a test error in the correct project
5. Known Gaps
- No automated API tests — all API coverage is manual or inferred from contract tests
- No frontend unit or integration tests (no Jest / Vitest / Playwright setup)
- Streamer wallet page and delivery review flows have documented gaps (see milestones open-gaps table)
- Conversion tracking is not yet live