diff options
| author | Your Name <you@example.com> | 2026-05-18 19:55:01 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-18 19:55:01 +0530 |
| commit | f8a5cffd3fe9d07de52e1688bda9b2975adbb74d (patch) | |
| tree | 8fb5cfff0a24bd4868a8dcb70103dc10e2c0d873 | |
| parent | c8c68dcc0dc4b897519105faec64994e820af0c2 (diff) | |
feat: add E2E test helpers and update checklist for physical board testing
| -rw-r--r-- | docs/TOLLGATE_CORE_DESIGN.md | 23 | ||||
| -rw-r--r-- | tests/integration/helpers/network.mjs | 67 |
2 files changed, 88 insertions, 2 deletions
diff --git a/docs/TOLLGATE_CORE_DESIGN.md b/docs/TOLLGATE_CORE_DESIGN.md index a1ec639..d5ed06f 100644 --- a/docs/TOLLGATE_CORE_DESIGN.md +++ b/docs/TOLLGATE_CORE_DESIGN.md | |||
| @@ -327,7 +327,7 @@ This refactoring **must not proceed** until these branches land on master: | |||
| 327 | - [x] Implement `tollgate_core_tick()` — session expiry check | 327 | - [x] Implement `tollgate_core_tick()` — session expiry check |
| 328 | - [x] Implement `tollgate_core_get_status_json()` — JSON status | 328 | - [x] Implement `tollgate_core_get_status_json()` — JSON status |
| 329 | - [x] Implement `tollgate_core_get_config_json()` — JSON config (via platform) | 329 | - [x] Implement `tollgate_core_get_config_json()` — JSON config (via platform) |
| 330 | - [ ] Build and verify standalone | 330 | - [x] Build and verify standalone |
| 331 | 331 | ||
| 332 | ### Phase 4: Standalone Platform Implementation | 332 | ### Phase 4: Standalone Platform Implementation |
| 333 | 333 | ||
| @@ -344,7 +344,26 @@ This refactoring **must not proceed** until these branches land on master: | |||
| 344 | - [x] Remove old `main/cashu.c`, `main/dns_server.c`, `main/firewall.c`, `main/session.c` from CMakeLists.txt | 344 | - [x] Remove old `main/cashu.c`, `main/dns_server.c`, `main/firewall.c`, `main/session.c` from CMakeLists.txt |
| 345 | - [x] Update `main/CMakeLists.txt` (remove old SRCS, add `tollgate_platform.c`, add `tollgate_core` to REQUIRES) | 345 | - [x] Update `main/CMakeLists.txt` (remove old SRCS, add `tollgate_platform.c`, add `tollgate_core` to REQUIRES) |
| 346 | - [x] Update `main/lwip_tollgate_hooks.h` to call `tollgate_core_ip4_canforward_filter` | 346 | - [x] Update `main/lwip_tollgate_hooks.h` to call `tollgate_core_ip4_canforward_filter` |
| 347 | - [ ] Full standalone build + test | 347 | - [x] Full standalone build + test (verified: `c8c68dc` — build passes, 61/61 unit tests pass) |
| 348 | |||
| 349 | ### Phase 4.5: Physical Board E2E Testing (Board A) | ||
| 350 | |||
| 351 | - [x] Create `tests/integration/helpers/network.mjs` (shared test utilities) | ||
| 352 | - [x] Add arch test Makefile targets with mutex protection to `physical-router-test-automation/esp32/Makefile` | ||
| 353 | - [x] Add top-level Makefile wrappers for arch tests | ||
| 354 | - [ ] Acquire Board A mutex lock | ||
| 355 | - [ ] Flash arch firmware to Board A | ||
| 356 | - [ ] Verify boot via serial (no panics, services started) | ||
| 357 | - [ ] Connect WiFi to Board A AP | ||
| 358 | - [ ] Run smoke test (`arch-test-smoke`) | ||
| 359 | - [ ] Run network test (`arch-test-network`) | ||
| 360 | - [ ] Run API test (`arch-test-api`) | ||
| 361 | - [ ] Run DNS + firewall test (`arch-test-dns-fw`) | ||
| 362 | - [ ] Run reset auth test (`arch-test-reset`) | ||
| 363 | - [ ] Run session expiry test (`arch-test-session`) | ||
| 364 | - [ ] Run phase 2 API test (`arch-test-phase2`) | ||
| 365 | - [ ] Commit and push test results | ||
| 366 | - [ ] Release Board A mutex lock | ||
| 348 | 367 | ||
| 349 | ### Phase 5: ESP-Miner Integration | 368 | ### Phase 5: ESP-Miner Integration |
| 350 | 369 | ||
diff --git a/tests/integration/helpers/network.mjs b/tests/integration/helpers/network.mjs new file mode 100644 index 0000000..87bc5c5 --- /dev/null +++ b/tests/integration/helpers/network.mjs | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | import { execSync } from 'child_process'; | ||
| 2 | |||
| 3 | const DEFAULT_IP = '10.192.45.1'; | ||
| 4 | const WIFI_IFACE = 'wlp59s0'; | ||
| 5 | |||
| 6 | export function getPortalIP() { | ||
| 7 | return process.env.TOLLGATE_IP || DEFAULT_IP; | ||
| 8 | } | ||
| 9 | |||
| 10 | export function curl(url, timeout = 5) { | ||
| 11 | try { | ||
| 12 | return execSync( | ||
| 13 | `curl -s -o /dev/null -w "%{http_code}" --connect-timeout ${timeout} --max-time ${timeout + 5} "${url}"`, | ||
| 14 | { encoding: 'utf8', timeout: (timeout + 5) * 1000 } | ||
| 15 | ).trim(); | ||
| 16 | } catch { | ||
| 17 | return null; | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | export function curlBody(url, timeout = 5) { | ||
| 22 | try { | ||
| 23 | return execSync( | ||
| 24 | `curl -s --connect-timeout ${timeout} --max-time ${timeout + 5} "${url}"`, | ||
| 25 | { encoding: 'utf8', timeout: (timeout + 5) * 1000 } | ||
| 26 | ); | ||
| 27 | } catch { | ||
| 28 | return null; | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | export function canPing(host = '8.8.8.8', count = 1) { | ||
| 33 | try { | ||
| 34 | const result = execSync( | ||
| 35 | `ping -c ${count} -W 3 -I ${WIFI_IFACE} ${host} 2>/dev/null`, | ||
| 36 | { encoding: 'utf8', timeout: 10000 } | ||
| 37 | ); | ||
| 38 | return result && !result.includes('100% packet loss'); | ||
| 39 | } catch { | ||
| 40 | return false; | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | export function canResolve(domain, timeout = 3) { | ||
| 45 | try { | ||
| 46 | const result = execSync( | ||
| 47 | `nslookup -timeout=${timeout} ${domain} 2>&1`, | ||
| 48 | { encoding: 'utf8', timeout: (timeout + 2) * 1000 } | ||
| 49 | ); | ||
| 50 | return result && result.includes('Address') && !result.includes('NXDOMAIN'); | ||
| 51 | } catch { | ||
| 52 | return false; | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | export function dnsResolvesToSelf(domain) { | ||
| 57 | const ip = getPortalIP(); | ||
| 58 | try { | ||
| 59 | const result = execSync( | ||
| 60 | `nslookup ${domain} ${ip} 2>&1`, | ||
| 61 | { encoding: 'utf8', timeout: 8000 } | ||
| 62 | ); | ||
| 63 | return result && result.includes(ip); | ||
| 64 | } catch { | ||
| 65 | return false; | ||
| 66 | } | ||
| 67 | } | ||