upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/PLAN.md
diff options
context:
space:
mode:
Diffstat (limited to 'PLAN.md')
-rw-r--r--PLAN.md63
1 files changed, 62 insertions, 1 deletions
diff --git a/PLAN.md b/PLAN.md
index 0fcecac..8ea827d 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -382,7 +382,68 @@ Total payload: 9 bytes (fits easily in beacon, typical budget ~200 bytes)
382 382
383**Goal:** ESP32 can pay OpenWRT TollGate using Cashu tokens. Full interoperability with existing OpenWRT-based TollGate infrastructure. 383**Goal:** ESP32 can pay OpenWRT TollGate using Cashu tokens. Full interoperability with existing OpenWRT-based TollGate infrastructure.
384 384
385## Total: 38 Tests across 4 phases 385## Total: 38 + 20 Tests across 4 phases
386
387## Testing Infrastructure
388
389### Three-Layer Test Architecture
390
391| Layer | Location | What | Runs on | Requires |
392|-------|----------|------|---------|----------|
393| **Unit** | `tests/unit/` | Host-compiled C tests for pure-logic functions | Dev machine (gcc) | `libmbedtls-dev`, `libcjson-dev` |
394| **Integration** | `tests/integration/` | Node.js curl/ping against live board | Dev machine + Board A | Board flashed + connected |
395| **E2E** | `tests/e2e/` | Playwright browser tests | Dev machine + Board A | Board + browser |
396
397### Unit Tests (`tests/unit/`)
398
399Host-compiled C tests that verify pure-logic functions with known input/output vectors. No hardware needed. ESP-IDF types provided by stubs in `tests/unit/stubs/`. Source files are **never modified** for testing.
400
401**System deps:** `sudo apt install libmbedtls-dev libcjson-dev`
402
403| Test file | Module | What's tested |
404|-----------|--------|---------------|
405| `test_geohash.c` | `geohash.c` | `geohash_encode()` against reference vectors (Munich, NYC, origin, boundaries) |
406| `test_identity.c` | `identity.c` | `tollgate_derive()` HMAC-SHA512 determinism, MAC locally-administered bit, multicast bit cleared, SSID/IP derivation |
407| `test_nostr_event.c` | `nostr_event.c` | NIP-01 event ID (SHA-256 of canonical JSON), Schnorr signature generation + verification, JSON serialization |
408| `test_cashu.c` | `cashu.c` | `cashu_decode_token()`, `cashu_calculate_allotment_ms()`, `cashu_is_mint_accepted()` |
409| `test_session.c` | `session.c` | Session lifecycle: create/find/extend/expire/revoke, spent-secret dedup |
410
411**Run:** `make test-unit`
412
413### Integration Tests (`tests/integration/`)
414
415Node.js scripts that test against a live ESP32 board via HTTP, ping, nmcli. Require `TOLLGATE_IP` env var.
416
417| Test file | Phase | What's tested |
418|-----------|-------|---------------|
419| `phase1_api.mjs` | 1 | Portal HTML, captive URIs, whoami, usage, grant/reset, DNS hijack/forward |
420| `phase1_network.mjs` | 1 | AP scan, DHCP, DNS, NAT, ping before/after auth |
421| `phase2.mjs` | 2 | API advertisement, payment flow, invalid/spent/wrong-mint tokens, session expiry/renewal |
422| `phase3.mjs` | 3 | Wallet endpoints, identity-derived SSID/IP, wifistr on relay, send/receive roundtrip |
423| `smoke.mjs` | all | Quick 30s smoke: AP visible, portal, grant, internet, reset |
424
425**Run:** `TOLLGATE_IP=10.192.45.1 make test-integration`
426
427### E2E Tests (`tests/e2e/`)
428
429Playwright browser tests for the captive portal UI and payment flow.
430
431| Test file | What's tested |
432|-----------|---------------|
433| `captive-portal.spec.mjs` | Portal branding, price, mint URL, template substitution, captive URIs, catch-all, API structure |
434| `payment.spec.mjs` | Paste token → click Pay → success/error, empty submit, full payment flow |
435
436**Run:** `TOLLGATE_IP=10.192.45.1 make test-e2e`
437
438### Test Coverage Rules
439
440- Every new `.c/.h` file MUST have unit tests in `tests/unit/`
441- Every new HTTP endpoint MUST have integration tests in `tests/integration/`
442- Every new browser-visible feature MUST have Playwright tests in `tests/e2e/`
443- All tests must pass before commit
444- Commit + push every time a test passes that previously didn't pass
445- Never hardcode IP addresses — always use `process.env.TOLLGATE_IP`
446- See `AGENTS.md` for full rules
386 447
387## Key Technical Notes 448## Key Technical Notes
388 449