diff options
| author | Your Name <you@example.com> | 2026-05-17 17:18:43 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-17 17:18:43 +0530 |
| commit | 8071741815f0b0938701e80a63e80b0ec94b2778 (patch) | |
| tree | 2a1511480e0b58f4efb144aa9d10c9fba5eed034 /Makefile | |
| parent | 0c2c67b463d6a90aaa0bb69bf3c91dba1d9ec3ec (diff) | |
refactor: reorganize test suite, add integration tests for NAT filter
- Move integration tests (api, network, phase2, smoke) to tests/integration/
- Move Playwright specs (captive-portal, interop-happy-path) to tests/e2e/
- Move playwright.config.mjs to tests/e2e/
- Fix hardcoded IP fallbacks: 192.168.4.1 → 10.192.45.1
- Add test-reset-auth.mjs: reset→pay→allow→revoke→block cycle
- Add test-session-expiry.mjs: pay→wait 65s→verify blocked (slow test)
- Add test-dns-firewall.mjs: DNS hijack/forward + per-client NAT filter
- Update Makefile with test-unit, test-integration, test-e2e, test-all targets
- Update package.json scripts for new paths
- Fix Playwright video: retain-on-failure instead of always-on
- Update AGENTS.md: per-client NAT filter description
- Update CHECKLIST.md: mark completed items, add Board B identity
- Board B nsec: 9af47906... → SSID TollGate-b96d80, AP IP 10.185.47.1
- 186 unit tests passing
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 91 |
1 files changed, 58 insertions, 33 deletions
| @@ -17,12 +17,15 @@ NODE ?= node | |||
| 17 | NPM ?= npm | 17 | NPM ?= npm |
| 18 | PYTHON ?= python3 | 18 | PYTHON ?= python3 |
| 19 | 19 | ||
| 20 | TOLLGATE_IP ?= 10.192.45.1 | ||
| 21 | |||
| 20 | .PHONY: help setup detect-ports detect-chip detect-all | 22 | .PHONY: help setup detect-ports detect-chip detect-all |
| 21 | .PHONY: flash flash-a flash-b monitor monitor-a monitor-b | 23 | .PHONY: flash flash-a flash-b monitor monitor-a monitor-b |
| 22 | .PHONY: test smoke test-api test-portal test-network test-full | 24 | .PHONY: test test-unit test-integration test-e2e test-all |
| 23 | .PHONY: tokens test-payment wallet-setup wallet-info wallet-balance mint-token send-token | 25 | .PHONY: test-smoke test-api test-network test-portal test-payment |
| 24 | .PHONY: clean erase-nvs reset serial-log | 26 | .PHONY: test-reset-auth test-session-expiry test-dns-firewall |
| 25 | .PHONY: bootstrap-config | 27 | .PHONY: tokens wallet-setup wallet-info wallet-balance mint-token send-token |
| 28 | .PHONY: clean erase-nvs reset serial-log bootstrap-config | ||
| 26 | 29 | ||
| 27 | help: | 30 | help: |
| 28 | @echo "TollGate ESP32 — Makefile" | 31 | @echo "TollGate ESP32 — Makefile" |
| @@ -38,25 +41,24 @@ help: | |||
| 38 | @echo " flash-b Flash to PORT_B" | 41 | @echo " flash-b Flash to PORT_B" |
| 39 | @echo " monitor Serial monitor on PORT" | 42 | @echo " monitor Serial monitor on PORT" |
| 40 | @echo "" | 43 | @echo "" |
| 41 | @echo "Test (Phase 1):" | 44 | @echo "Testing:" |
| 42 | @echo " test Run all Phase 1 tests" | 45 | @echo " test-unit Host C unit tests (no hardware)" |
| 43 | @echo " smoke Quick 30s smoke test" | 46 | @echo " test-integration Node.js integration tests (live board)" |
| 44 | @echo " test-api curl API endpoint tests" | 47 | @echo " test-e2e Playwright browser E2E tests" |
| 45 | @echo " test-portal Playwright captive portal tests" | 48 | @echo " test-all Run all three test layers" |
| 46 | @echo " test-network DNS/NAT connectivity tests" | 49 | @echo " test-smoke Quick 30s smoke test" |
| 47 | @echo " test-full All 14 Phase 1 tests" | 50 | @echo " test-reset-auth Reset auth + per-client NAT filter test" |
| 51 | @echo " test-dns-firewall DNS hijack + NAT filter test" | ||
| 52 | @echo " test-session-expiry Session lifecycle with 65s expiry wait" | ||
| 48 | @echo "" | 53 | @echo "" |
| 49 | @echo "Test (Phase 2):" | 54 | @echo "Wallet:" |
| 50 | @echo " wallet-setup Initialize nutshell wallet for test mint" | 55 | @echo " wallet-setup Initialize nutshell wallet for test mint" |
| 51 | @echo " wallet-info Show mint info" | 56 | @echo " wallet-info Show mint info" |
| 52 | @echo " wallet-balance Show wallet balance" | 57 | @echo " wallet-balance Show wallet balance" |
| 53 | @echo " mint-token Invoice + send test token (AMOUNT=21)" | 58 | @echo " mint-token Invoice + send test token (AMOUNT=21)" |
| 54 | @echo " send-token Send cashuA token (AMOUNT=21)" | 59 | @echo " send-token Send cashuA token (AMOUNT=21)" |
| 55 | @echo " tokens Alias for send-token" | ||
| 56 | @echo " test-payment Payment flow tests" | ||
| 57 | @echo "" | 60 | @echo "" |
| 58 | @echo "Utilities:" | 61 | @echo "Utilities:" |
| 59 | @echo " setup One-time: install esptool, deps" | ||
| 60 | @echo " clean Clean build" | 62 | @echo " clean Clean build" |
| 61 | @echo " erase-nvs Erase NVS partition on PORT" | 63 | @echo " erase-nvs Erase NVS partition on PORT" |
| 62 | @echo " reset Hardware reset on PORT" | 64 | @echo " reset Hardware reset on PORT" |
| @@ -144,33 +146,60 @@ monitor-b: PORT=$(PORT_B) | |||
| 144 | monitor-b: monitor | 146 | monitor-b: monitor |
| 145 | 147 | ||
| 146 | # ────────────────────────────────────────────── | 148 | # ────────────────────────────────────────────── |
| 147 | # Test Infrastructure | 149 | # Testing |
| 148 | # ────────────────────────────────────────────── | 150 | # ────────────────────────────────────────────── |
| 149 | 151 | ||
| 150 | test: test-api test-network | 152 | test-unit: |
| 151 | @echo "=== All tests passed ===" | 153 | @echo "=== Running host unit tests ===" |
| 154 | $(MAKE) -C tests/unit test | ||
| 155 | |||
| 156 | test-integration: test-api test-network test-reset-auth test-dns-firewall | ||
| 157 | @echo "=== Integration tests passed ===" | ||
| 158 | |||
| 159 | test-e2e: | ||
| 160 | @echo "=== Running Playwright E2E tests ===" | ||
| 161 | cd tests/e2e && npx playwright test | ||
| 162 | |||
| 163 | test-all: test-unit test-integration test-e2e | ||
| 164 | @echo "=== All test layers passed ===" | ||
| 165 | |||
| 166 | test: test-unit test-integration | ||
| 167 | @echo "=== Tests passed ===" | ||
| 152 | 168 | ||
| 153 | smoke: | 169 | test-smoke: |
| 154 | @echo "=== Running smoke test (30s) ===" | 170 | @echo "=== Running smoke test (30s) ===" |
| 155 | $(NODE) tests/smoke.mjs $(PORT) | 171 | TOLLGATE_IP=$(TOLLGATE_IP) $(NODE) tests/integration/smoke.mjs |
| 156 | 172 | ||
| 157 | test-api: | 173 | test-api: |
| 158 | @echo "=== Running API tests ===" | 174 | @echo "=== Running API tests ===" |
| 159 | $(NODE) tests/api.mjs | 175 | TOLLGATE_IP=$(TOLLGATE_IP) $(NODE) tests/integration/api.mjs |
| 176 | |||
| 177 | test-network: | ||
| 178 | @echo "=== Running network tests ===" | ||
| 179 | TOLLGATE_IP=$(TOLLGATE_IP) $(NODE) tests/integration/network.mjs | ||
| 160 | 180 | ||
| 161 | test-portal: | 181 | test-portal: |
| 162 | @echo "=== Running Playwright portal tests ===" | 182 | @echo "=== Running Playwright portal tests ===" |
| 163 | npx playwright test tests/captive-portal.spec.mjs | 183 | cd tests/e2e && npx playwright test captive-portal.spec.mjs |
| 164 | 184 | ||
| 165 | test-network: | 185 | test-payment: |
| 166 | @echo "=== Running network tests ===" | 186 | @echo "=== Running payment tests ===" |
| 167 | $(NODE) tests/network.mjs | 187 | TOLLGATE_IP=$(TOLLGATE_IP) $(NODE) tests/integration/phase2.mjs |
| 188 | |||
| 189 | test-reset-auth: | ||
| 190 | @echo "=== Running reset auth test ===" | ||
| 191 | TOLLGATE_IP=$(TOLLGATE_IP) $(NODE) tests/integration/test-reset-auth.mjs | ||
| 168 | 192 | ||
| 169 | test-full: test-api test-portal test-network | 193 | test-session-expiry: |
| 170 | @echo "=== Full test suite passed ===" | 194 | @echo "=== Running session expiry test (65s wait, ~80s total) ===" |
| 195 | TOLLGATE_IP=$(TOLLGATE_IP) $(NODE) tests/integration/test-session-expiry.mjs | ||
| 196 | |||
| 197 | test-dns-firewall: | ||
| 198 | @echo "=== Running DNS + firewall test ===" | ||
| 199 | TOLLGATE_IP=$(TOLLGATE_IP) $(NODE) tests/integration/test-dns-firewall.mjs | ||
| 171 | 200 | ||
| 172 | # ────────────────────────────────────────────── | 201 | # ────────────────────────────────────────────── |
| 173 | # Phase 2: Payment Testing (Nutshell wallet) | 202 | # Wallet |
| 174 | # ────────────────────────────────────────────── | 203 | # ────────────────────────────────────────────── |
| 175 | 204 | ||
| 176 | wallet-setup: | 205 | wallet-setup: |
| @@ -187,8 +216,8 @@ wallet-balance: | |||
| 187 | cashu --env-mint $(TEST_MINT) balance | 216 | cashu --env-mint $(TEST_MINT) balance |
| 188 | 217 | ||
| 189 | mint-token: | 218 | mint-token: |
| 190 | @echo "=== Minting test token (AMOUNT=$(or $(AMOUNT),21)) ===" | ||
| 191 | @AMOUNT=$${AMOUNT:-21}; \ | 219 | @AMOUNT=$${AMOUNT:-21}; \ |
| 220 | echo "=== Minting test token ($$AMOUNT sats) ==="; \ | ||
| 192 | cashu --env-mint $(TEST_MINT) invoice $$AMOUNT && \ | 221 | cashu --env-mint $(TEST_MINT) invoice $$AMOUNT && \ |
| 193 | echo "--- Token (cashuA legacy) ---" && \ | 222 | echo "--- Token (cashuA legacy) ---" && \ |
| 194 | cashu --env-mint $(TEST_MINT) send --legacy $$AMOUNT | 223 | cashu --env-mint $(TEST_MINT) send --legacy $$AMOUNT |
| @@ -200,10 +229,6 @@ send-token: | |||
| 200 | 229 | ||
| 201 | tokens: send-token | 230 | tokens: send-token |
| 202 | 231 | ||
| 203 | test-payment: | ||
| 204 | @echo "=== Running payment tests ===" | ||
| 205 | $(NODE) tests/phase2.mjs | ||
| 206 | |||
| 207 | # ────────────────────────────────────────────── | 232 | # ────────────────────────────────────────────── |
| 208 | # Utilities | 233 | # Utilities |
| 209 | # ────────────────────────────────────────────── | 234 | # ────────────────────────────────────────────── |