diff options
Diffstat (limited to 'interop/INTEROP_PLAN.md')
| -rw-r--r-- | interop/INTEROP_PLAN.md | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/interop/INTEROP_PLAN.md b/interop/INTEROP_PLAN.md new file mode 100644 index 0000000..c754e48 --- /dev/null +++ b/interop/INTEROP_PLAN.md | |||
| @@ -0,0 +1,149 @@ | |||
| 1 | # TollGate Interop Test Plan — ESP32 ↔ OpenWRT | ||
| 2 | |||
| 3 | ## Overview | ||
| 4 | |||
| 5 | Cross-platform interoperability tests between ESP32-based TollGate firmware and OpenWRT-based TollGate (tollgate-module-basic-go). Tests verify that Cashu e-cash tokens work across both implementations, and that the OpenWRT Go daemon can auto-pay the ESP32 for upstream internet access. | ||
| 6 | |||
| 7 | ## Device Inventory | ||
| 8 | |||
| 9 | | Device | Access | AP SSID | API | Mint | Metric | Price | | ||
| 10 | |--------|--------|---------|-----|------|--------|-------| | ||
| 11 | | OpenWRT (alpha) | SSH `root@10.47.41.1` | `TollGate-EVXZ-2.4GHz` / `TollGate-EVXZ-5GHz` | `http://10.47.41.1:2121/` | `nofee.testnut.cashu.space` | bytes (21MB/step) | 1 sat/step | | ||
| 12 | | ESP32 Board A | WiFi `10.192.45.1`, Serial `/dev/ttyACM0` | `TollGate-C0E9CA` | `http://10.192.45.1:2121/` | `testnut.cashu.space` | time (21 sats/60s) | 21 sats/step | | ||
| 13 | | ESP32 Board B | Serial `/dev/ttyACM1` | TBD | TBD | TBD | TBD | TBD | | ||
| 14 | |||
| 15 | ## Network Topology | ||
| 16 | |||
| 17 | ``` | ||
| 18 | ┌──────────────────────────────────────────────────┐ | ||
| 19 | │ Internet │ | ||
| 20 | └───────┬──────────────────────┬───────────────────┘ | ||
| 21 | │ │ | ||
| 22 | EnterSSID-5GHz (upstream) EnterSSID-2.4GHz (upstream) | ||
| 23 | │ │ | ||
| 24 | ┌────────┴────────┐ ┌────────┴────────┐ | ||
| 25 | │ OpenWRT Router │ │ ESP32 Board A │ | ||
| 26 | │ (alpha) │ │ (TollGate-C0E9CA) | ||
| 27 | │ 10.47.41.1 │ │ 10.192.45.1 │ | ||
| 28 | └────────┬────────┘ └────────┬────────┘ | ||
| 29 | │ │ | ||
| 30 | TollGate-EVXZ-2.4GHz TollGate-C0E9CA | ||
| 31 | TollGate-EVXZ-5GHz (open AP) | ||
| 32 | │ │ | ||
| 33 | ┌────────┴────────┐ ┌────────┴────────┐ | ||
| 34 | │ Laptop (eth0) │ │ Laptop (wlan0) │ | ||
| 35 | │ 10.47.41.106 │ │ 10.192.45.2 │ | ||
| 36 | └─────────────────┘ └─────────────────┘ | ||
| 37 | ``` | ||
| 38 | |||
| 39 | ## Mint Alignment Strategy | ||
| 40 | |||
| 41 | Both mints are test mints that auto-pay lightning invoices. For cross-platform interop, both devices accept tokens from either mint. | ||
| 42 | |||
| 43 | | Mint | Auto-pay | Used by | | ||
| 44 | |------|----------|---------| | ||
| 45 | | `testnut.cashu.space` | Yes | ESP32 (native), added to OpenWRT | | ||
| 46 | | `nofee.testnut.cashu.space` | Yes | OpenWRT (native), added to ESP32 | | ||
| 47 | |||
| 48 | ### Configuration Changes | ||
| 49 | |||
| 50 | **OpenWRT** — add `testnut.cashu.space` to `accepted_mints` in `/etc/tollgate/config.json` via SSH + jq. | ||
| 51 | |||
| 52 | **ESP32** — add `nofee.testnut.cashu.space` to `mint_url` in `config.json` on SPIFFS. Requires rebuild + reflash. | ||
| 53 | |||
| 54 | ## Token Format Compatibility | ||
| 55 | |||
| 56 | | Platform | V3 (cashuA) | V4 (cashuB/CBOR) | | ||
| 57 | |----------|-------------|-------------------| | ||
| 58 | | ESP32 | **Accepted** (only format supported) | Not supported | | ||
| 59 | | OpenWRT | Accepted | Accepted | | ||
| 60 | |||
| 61 | Token generation: | ||
| 62 | - **For ESP32**: `cashu --env-mint testnut.cashu.space send --legacy 21` → V3 | ||
| 63 | - **For OpenWRT**: `mint-token` Go binary → V4 (preferred), or `cashu --legacy` → V3 | ||
| 64 | |||
| 65 | ## Test Scenarios | ||
| 66 | |||
| 67 | ### Scenario 1: Laptop → ESP32 (Already Works) | ||
| 68 | |||
| 69 | Laptop connects to ESP32 AP, mints V3 token, pays ESP32 TollGate API, verifies internet. | ||
| 70 | |||
| 71 | This is the existing `make test-payment` flow, wrapped into the interop Makefile for consistency. | ||
| 72 | |||
| 73 | ### Scenario 2: Laptop → OpenWRT | ||
| 74 | |||
| 75 | Laptop connects to OpenWRT AP (or uses existing ethernet connection), mints V4 token, pays OpenWRT TollGate API, verifies internet. | ||
| 76 | |||
| 77 | **Steps:** | ||
| 78 | 1. Verify laptop can reach OpenWRT at `10.47.41.1` | ||
| 79 | 2. Check API advertisement at `http://10.47.41.1:2121/` (kind=10021) | ||
| 80 | 3. Mint V4 token via `mint-token` binary | ||
| 81 | 4. POST token to `http://10.47.41.1:2121/` | ||
| 82 | 5. Verify kind=1022 session response | ||
| 83 | 6. Verify internet via ping | ||
| 84 | |||
| 85 | ### Scenario 3: OpenWRT → ESP32 (Reseller) | ||
| 86 | |||
| 87 | OpenWRT connects its STA to ESP32's TollGate AP. OpenWRT's Go daemon auto-detects the TollGate upstream and pays with its wallet. ESP32 grants session. | ||
| 88 | |||
| 89 | **Steps:** | ||
| 90 | 1. Verify both devices accessible | ||
| 91 | 2. Fund ESP32 wallet (for receiving payment) | ||
| 92 | 3. Fund OpenWRT wallet (for paying upstream) | ||
| 93 | 4. Save OpenWRT's current upstream SSID | ||
| 94 | 5. Connect OpenWRT STA to `TollGate-C0E9CA` (ESP32's AP) | ||
| 95 | 6. Wait for DHCP + upstream detection | ||
| 96 | 7. Watch for auto-payment logs on OpenWRT | ||
| 97 | 8. Verify session on ESP32 (via serial or API) | ||
| 98 | 9. Restore OpenWRT upstream | ||
| 99 | 10. Restore production configs | ||
| 100 | |||
| 101 | ### Scenario 4: ESP32 → OpenWRT (Future) | ||
| 102 | |||
| 103 | ESP32 connects its STA to OpenWRT's TollGate AP. Requires ESP32 firmware to have TollGate client detection + auto-payment logic — **not yet implemented**. | ||
| 104 | |||
| 105 | ### Scenario 5: ESP32 ↔ ESP32 | ||
| 106 | |||
| 107 | Board A connects to Board B's AP (or vice versa), cross-payment test. Requires Board B to be flashed with unique nsec + funded wallet. | ||
| 108 | |||
| 109 | **Steps:** | ||
| 110 | 1. Flash Board B with different nsec | ||
| 111 | 2. Configure and fund both boards | ||
| 112 | 3. Board A connects STA to Board B's AP | ||
| 113 | 4. Manual curl payment test (POST token) | ||
| 114 | 5. Verify session + internet | ||
| 115 | |||
| 116 | ## Makefile Target Reference | ||
| 117 | |||
| 118 | | Target | Scenario | Description | | ||
| 119 | |--------|----------|-------------| | ||
| 120 | | `interop-status` | — | Show TollGate status for all devices | | ||
| 121 | | `interop-setup-mints` | — | Add both mints to both devices | | ||
| 122 | | `interop-fund-esp32` | — | Fund ESP32 wallet with test tokens | | ||
| 123 | | `interop-fund-openwrt` | — | Fund OpenWRT wallet with test tokens | | ||
| 124 | | `interop-setup` | — | Full setup: mints + fund both | | ||
| 125 | | `interop-laptop-esp32` | 1 | Laptop pays ESP32 | | ||
| 126 | | `interop-laptop-openwrt` | 2 | Laptop pays OpenWRT | | ||
| 127 | | `interop-openwrt-esp32` | 3 | OpenWRT auto-pays ESP32 for upstream | | ||
| 128 | | `interop-esp32-esp32` | 5 | Cross-board payment | | ||
| 129 | | `interop-cleanup` | — | Restore original configs on all devices | | ||
| 130 | |||
| 131 | ## Prerequisites | ||
| 132 | |||
| 133 | - Laptop connected to OpenWRT via ethernet (`enx00e04c683d2d`, `10.47.41.106`) | ||
| 134 | - Laptop connected to ESP32 via WiFi (`wlp59s0`, `10.192.45.2`) | ||
| 135 | - `mint-token` binary built: `cd physical-router-test-automation/scripts/mint-token && go build -o /tmp/mint-token .` | ||
| 136 | - `cashu` CLI installed: `pip install cashu` | ||
| 137 | - SSH key auth to OpenWRT: `ssh-copy-id root@10.47.41.1` | ||
| 138 | - ESP32 Board A flashed and running with funded wallet | ||
| 139 | |||
| 140 | ## Key Technical Notes | ||
| 141 | |||
| 142 | - OpenWRT uses `tollgate upstream connect <ssid>` CLI to switch upstream | ||
| 143 | - OpenWRT's daemon auto-detects TollGate upstream via HTTP GET to `:2121/` (kind=10021) | ||
| 144 | - ESP32 only accepts V3 tokens (`cashuA` prefix); OpenWRT accepts both V3 and V4 | ||
| 145 | - The `mint-token` binary mints from `nofee.testnut.cashu.space` and produces V4 tokens | ||
| 146 | - The `cashu` CLI with `--legacy` flag produces V3 tokens | ||
| 147 | - ESP32 has no TollGate client logic — cannot auto-pay upstream TollGates (future work) | ||
| 148 | - OpenWRT's `tollgate wallet fund` accepts piped V4 tokens | ||
| 149 | - ESP32's `POST /wallet/receive` accepts V3 tokens (via nucula) | ||