diff options
| author | Your Name <you@example.com> | 2026-05-20 02:10:01 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-20 02:10:01 +0530 |
| commit | 82f1fc0d5535eda3fc9eab799d81b3e220dbe4ef (patch) | |
| tree | 341dcecb0a87a6219bc51d424316dfadcf69bf65 /tests/integration | |
| parent | 2c12c4281c47aa87a1c7bb82abe09bf9dbc788c3 (diff) | |
feat: add tollgate_core component + market config wiring
- Add tollgate_core ESP-IDF component (skeleton: cashu, dns, firewall, session)
- Add tollgate_platform.c with SPIFFS config backend
- Wire market_enabled, market_scan_interval_s, client_auto_switch in config.c
- Add lwip_tollgate_hooks.h (updated from feature branch)
- Add E2E fix plan, tollgate_core design doc, WPA autodetect plan
- Add integration test network helpers
- Add CONSOLIDATION.md plan
Reverts the broken merge (be4788b) that gutted config.c/tollgate_main.c/tollgate_api.c
and replaces it with a clean addition on top of intact master.
Diffstat (limited to 'tests/integration')
| -rw-r--r-- | tests/integration/helpers/network.mjs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/integration/helpers/network.mjs b/tests/integration/helpers/network.mjs new file mode 100644 index 0000000..0d6013d --- /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 = 30) { | ||
| 11 | try { | ||
| 12 | return execSync( | ||
| 13 | `curl -s -o /dev/null -w "%{http_code}" --connect-timeout ${timeout} --max-time ${timeout + 10} "${url}"`, | ||
| 14 | { encoding: 'utf8', timeout: (timeout + 10) * 1000 } | ||
| 15 | ).trim(); | ||
| 16 | } catch { | ||
| 17 | return null; | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | export function curlBody(url, timeout = 30) { | ||
| 22 | try { | ||
| 23 | return execSync( | ||
| 24 | `curl -s --connect-timeout ${timeout} --max-time ${timeout + 10} "${url}"`, | ||
| 25 | { encoding: 'utf8', timeout: (timeout + 10) * 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 = 5) { | ||
| 45 | try { | ||
| 46 | const result = execSync( | ||
| 47 | `dig +short +timeout=${timeout} +tries=1 ${domain} 2>&1`, | ||
| 48 | { encoding: 'utf8', timeout: (timeout + 2) * 1000 } | ||
| 49 | ).trim(); | ||
| 50 | return result.length > 0 && !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 | `dig +short +timeout=5 ${domain} @{ip} 2>&1`, | ||
| 61 | { encoding: 'utf8', timeout: 10000 } | ||
| 62 | ).trim(); | ||
| 63 | return result === ip; | ||
| 64 | } catch { | ||
| 65 | return false; | ||
| 66 | } | ||
| 67 | } | ||