Skip to content

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 ​

LayerToolScope
Smart contractFoundry (forge test)HTLC deposit / allocation / withdrawal / refund logic
APIManual / curlREST endpoints, auth, DB side-effects
FrontendManual (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 -vvv

Coverage areas:

GroupTests
DepositsETH and ERC-20 (USDC), edge cases
AllocationsSingle/multi-slot, variable amounts, permission checks
WithdrawalsSingle-slot, multi-slot, batch
RefundsAllocation-level and deposit-level
IntegrationFull lifecycle (deposit → allocate → withdraw → refund)
FuzzRandom 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:6020

Key env vars (API) ​

VariablePurpose
DATABASE_URLPostgreSQL connection string
KICK_CLIENT_ID / SECRETKick OAuth for streamer login
X_CLIENT_ID / SECRETTwitter/X OAuth
PUSHER_*Real-time notification channels
RESEND_API_KEYTransactional email
S3_*KYC document storage (Hetzner)
ADMIN_SECRETAdmin-only endpoint access

Key env vars (Frontend) ​

VariablePurpose
VITE_NETWORK_SEPOLIANetwork config string (chainId, contract address, RPC URL, explorer)
VITE_DEFAULT_NETWORKANVIL for local, SEPOLIA for staging/prod
VITE_API_URLAPI base URL (empty = Vite proxy)

3. Manual Test Flows ​

Operator flow ​

  1. Sign in — log in with a test operator account
  2. Create campaign — set name, category, budget cap, dates
  3. Deposit funds — connect MetaMask (Sepolia or Anvil), deposit USDC into escrow; confirm the deposit ID is stored
  4. Invite or approve a streamer — send an operator-initiated offer or accept a streamer application
  5. Negotiate terms — step through at least one round of counter-offers; verify term state updates
  6. 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
  7. Refund — after timelock expires, reclaim an unclaimed allocation; verify available balance increases

Streamer flow ​

  1. Sign up / log in — OAuth via Kick or X
  2. Complete profile — add wallet address (required for payouts)
  3. Apply to campaign — submit application with message
  4. Accept operator invite — if invited, accept the offer to start negotiation
  5. Negotiate terms — counter-propose, then agree
  6. View deal — confirm allocation appears in wallet view with correct amounts
  7. Submit stream proof — submit session evidence for a slot
  8. Claim payout — withdraw earnings; verify wallet balance increases on-chain

Negotiation edge cases ​

ScenarioExpected behaviour
Operator-initiated offer → allocationAllocation modal opens without "Could not locate application record" error
Streamer-initiated offer → allocationSame — both paths must work
Agreed negotiation, streamer has no walletAllocation blocked with clear error
Connected wallet ≠ deposit senderAllocation blocked with wallet mismatch error
Insufficient unallocated balanceAllocation blocked with available-vs-requested breakdown

4. Staging / Production Checklist ​

Before deploying to production (Sepolia + Cloudflare Pages):

  • [ ] forge test passes 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.com in _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

Verifluence Documentation