Skip to content

Commit b8add9b

Browse files
committed
Extend tests
1 parent e1f5b64 commit b8add9b

13 files changed

Lines changed: 2009 additions & 393 deletions

File tree

.github/workflows/test.yaml

Lines changed: 118 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ jobs:
7676
wasm-sdk-browser:
7777
runs-on: ubuntu-latest
7878
timeout-minutes: 45
79+
env:
80+
WASM_PACK_VERSION: "0.13.1"
81+
WASM_BINDGEN_TEST_TIMEOUT: "300"
82+
WASM_BROWSER_TEST_LOG: "bindings/wasm-sdk/target/wasm-browser-tests-chrome.log"
83+
WASM_BINDGEN_TEST_RUNNER_VERSION: "0.2.117"
7984
steps:
8085
- uses: actions/checkout@v4
8186
with:
@@ -86,20 +91,123 @@ jobs:
8691
- name: Add wasm32 target
8792
run: rustup target add wasm32-unknown-unknown
8893
- name: Install wasm-pack
89-
run: cargo install wasm-pack --locked
94+
run: cargo install wasm-pack --version ${WASM_PACK_VERSION} --locked
95+
- name: Install Chrome
96+
uses: browser-actions/setup-chrome@v1
97+
with:
98+
chrome-version: stable
99+
- name: Browser tooling versions
100+
run: |
101+
wasm-pack --version
102+
if command -v google-chrome >/dev/null 2>&1; then
103+
google-chrome --version
104+
elif command -v chromium >/dev/null 2>&1; then
105+
chromium --version
106+
elif command -v chromium-browser >/dev/null 2>&1; then
107+
chromium-browser --version
108+
else
109+
echo "Chrome/Chromium binary not found in PATH"
110+
exit 1
111+
fi
112+
- name: wasm-sdk browser tests
113+
run: |
114+
WASM_TEST_BROWSER=chrome ./bindings/wasm-sdk/scripts/run-browser-tests.sh
115+
- name: Verify wasm-bindgen test runner version
116+
if: always()
117+
run: |
118+
RUNNER_PATH="$(find "${HOME}/.cache/.wasm-pack" -maxdepth 2 -type f -name "wasm-bindgen-test-runner" | head -n1 || true)"
119+
if [ -z "${RUNNER_PATH}" ]; then
120+
echo "wasm-bindgen-test-runner binary was not found in cache"
121+
exit 1
122+
fi
123+
RAW_VERSION="$(${RUNNER_PATH} --version)"
124+
echo "Runner path: ${RUNNER_PATH}"
125+
echo "Runner version: ${RAW_VERSION}"
126+
ACTUAL_VERSION="$(printf '%s\n' "${RAW_VERSION}" | awk '{print $2}')"
127+
if [ "${ACTUAL_VERSION}" != "${WASM_BINDGEN_TEST_RUNNER_VERSION}" ]; then
128+
echo "Unexpected wasm-bindgen-test-runner version: ${ACTUAL_VERSION} (expected ${WASM_BINDGEN_TEST_RUNNER_VERSION})"
129+
exit 1
130+
fi
131+
- name: Cached wasm runner versions
132+
if: always()
133+
run: |
134+
find "${HOME}/.cache/.wasm-pack" -maxdepth 2 -type f -name "wasm-bindgen-test-runner" -print -exec {} --version \; || true
135+
find "${HOME}/.cache/.wasm-pack" -maxdepth 3 -type f -name "chromedriver" -print -exec {} --version \; || true
136+
- name: Upload browser test artifacts (chrome)
137+
if: failure()
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: wasm-sdk-browser-chrome-logs
141+
path: |
142+
bindings/wasm-sdk/target/wasm-browser-tests-chrome.log
143+
bindings/wasm-sdk/target/wasm32-unknown-unknown/debug/deps/*.wasm
144+
if-no-files-found: warn
145+
146+
wasm-sdk-browser-diagnostic-firefox:
147+
runs-on: ubuntu-latest
148+
timeout-minutes: 45
149+
continue-on-error: true
150+
env:
151+
WASM_PACK_VERSION: "0.13.1"
152+
WASM_BINDGEN_TEST_TIMEOUT: "300"
153+
WASM_BROWSER_TEST_LOG: "bindings/wasm-sdk/target/wasm-browser-tests-firefox.log"
154+
WASM_BINDGEN_TEST_RUNNER_VERSION: "0.2.117"
155+
steps:
156+
- uses: actions/checkout@v4
157+
with:
158+
submodules: true
159+
- uses: actions-rust-lang/setup-rust-toolchain@v1
160+
with:
161+
rustflags: ""
162+
- name: Add wasm32 target
163+
run: rustup target add wasm32-unknown-unknown
164+
- name: Install wasm-pack
165+
run: cargo install wasm-pack --version ${WASM_PACK_VERSION} --locked
90166
- name: Install Firefox
91167
run: sudo apt-get update && sudo apt-get install -y firefox
92-
- name: wasm-sdk browser tests
93-
env:
94-
WASM_BINDGEN_TEST_TIMEOUT: "300"
168+
- name: Install geckodriver
95169
run: |
96-
cd bindings/wasm-sdk
97-
if command -v geckodriver >/dev/null 2>&1; then
98-
export GECKODRIVER="$(command -v geckodriver)"
99-
elif [ -x /snap/bin/geckodriver ]; then
100-
export GECKODRIVER="/snap/bin/geckodriver"
170+
GECKO_VERSION="v0.36.0"
171+
curl -fsSL -o /tmp/geckodriver.tar.gz "https://github.com/mozilla/geckodriver/releases/download/${GECKO_VERSION}/geckodriver-${GECKO_VERSION}-linux64.tar.gz"
172+
tar -xzf /tmp/geckodriver.tar.gz -C /tmp
173+
sudo install -m 0755 /tmp/geckodriver /usr/local/bin/geckodriver
174+
- name: Browser tooling versions
175+
run: |
176+
wasm-pack --version
177+
firefox --version
178+
geckodriver --version | head -n 1
179+
- name: wasm-sdk browser tests (diagnostic)
180+
run: |
181+
WASM_TEST_BROWSER=firefox ./bindings/wasm-sdk/scripts/run-browser-tests.sh
182+
- name: Verify wasm-bindgen test runner version (diagnostic)
183+
if: always()
184+
run: |
185+
RUNNER_PATH="$(find "${HOME}/.cache/.wasm-pack" -maxdepth 2 -type f -name "wasm-bindgen-test-runner" | head -n1 || true)"
186+
if [ -z "${RUNNER_PATH}" ]; then
187+
echo "wasm-bindgen-test-runner binary was not found in cache"
188+
exit 1
101189
fi
102-
wasm-pack test --headless --firefox
190+
RAW_VERSION="$(${RUNNER_PATH} --version)"
191+
echo "Runner path: ${RUNNER_PATH}"
192+
echo "Runner version: ${RAW_VERSION}"
193+
ACTUAL_VERSION="$(printf '%s\n' "${RAW_VERSION}" | awk '{print $2}')"
194+
if [ "${ACTUAL_VERSION}" != "${WASM_BINDGEN_TEST_RUNNER_VERSION}" ]; then
195+
echo "Unexpected wasm-bindgen-test-runner version: ${ACTUAL_VERSION} (expected ${WASM_BINDGEN_TEST_RUNNER_VERSION})"
196+
exit 1
197+
fi
198+
- name: Cached wasm runner versions
199+
if: always()
200+
run: |
201+
find "${HOME}/.cache/.wasm-pack" -maxdepth 2 -type f -name "wasm-bindgen-test-runner" -print -exec {} --version \; || true
202+
- name: Upload browser test artifacts (firefox diagnostic)
203+
if: failure()
204+
uses: actions/upload-artifact@v4
205+
with:
206+
name: wasm-sdk-browser-firefox-logs
207+
path: |
208+
bindings/wasm-sdk/target/wasm-browser-tests-firefox.log
209+
bindings/wasm-sdk/target/wasm32-unknown-unknown/debug/deps/*.wasm
210+
if-no-files-found: warn
103211

104212
lib-sdk-tests:
105213
runs-on: warp-ubuntu-latest-x64-16x

bindings/wasm-sdk/README.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,59 @@ cd bindings/wasm-sdk
2929
wasm-pack build --target web --out-dir pkg
3030
```
3131

32+
## Run Local Environment
33+
34+
Use this when you want to run browser interop flows against local regtest infra.
35+
36+
Prerequisites:
37+
38+
- Docker + Docker Compose
39+
- Rust toolchain (for `wasm-pack` build and optional gateway runs)
40+
- `wasm-pack` (`cargo install wasm-pack`)
41+
42+
Start local infra (from repo root):
43+
44+
```sh
45+
cd bindings/wasm-sdk
46+
docker compose -f compose.wasm.yaml up -d
47+
```
48+
49+
This brings up:
50+
51+
- RGB proxy: `127.0.0.1:3000`
52+
- WASM proxy gateway: `127.0.0.1:3001`
53+
- Esplora HTTP: `127.0.0.1:3002`
54+
- Electrum: `127.0.0.1:50001`
55+
- Bitcoind RPC: `127.0.0.1:18443`
56+
57+
Build WASM package for browser examples:
58+
59+
```sh
60+
cd bindings/wasm-sdk
61+
wasm-pack build --target web --dev
62+
```
63+
64+
Serve repository files (from repo root):
65+
66+
```sh
67+
python3 -m http.server 8080
68+
```
69+
70+
Open examples:
71+
72+
- `http://localhost:8080/bindings/wasm-sdk/examples/wasm-interop/`
73+
- `http://localhost:8080/bindings/wasm-sdk/examples/wasm-interop/virtual_channels_flow.html`
74+
- `http://localhost:8080/bindings/wasm-sdk/examples/wasm-interop/rgb_asset_transfer_flow.html`
75+
76+
Stop local infra:
77+
78+
```sh
79+
cd bindings/wasm-sdk
80+
docker compose -f compose.wasm.yaml down
81+
```
82+
83+
If ports are busy, either stop conflicting services or edit `compose.wasm.yaml` port mappings.
84+
3285
## Runtime model
3386

3487
- Public API: `wasm_native_ldk` runtime only.
@@ -49,7 +102,20 @@ WASM checks are wired into CI in `.github/workflows/test.yaml`:
49102

50103
- `wasm-sdk` (native host checks for crate)
51104
- `wasm-sdk-wasm32` (target compatibility check)
52-
- `wasm-sdk-browser` (headless browser wasm-bindgen test execution via `wasm-pack test`)
105+
- `wasm-sdk-browser` (blocking headless browser run in Chrome)
106+
- `wasm-sdk-browser-diagnostic-firefox` (non-blocking diagnostic run in Firefox)
107+
108+
Both browser jobs pin:
109+
- `wasm-pack` to `0.13.1`
110+
- `wasm-bindgen-test-runner` to `0.2.117` (verified in CI after test bootstrap)
111+
112+
Local browser test command (same wrapper used by CI):
113+
114+
```sh
115+
WASM_BINDGEN_TEST_TIMEOUT=300 WASM_TEST_BROWSER=chrome ./bindings/wasm-sdk/scripts/run-browser-tests.sh
116+
```
117+
118+
`WASM_TEST_BROWSER` supports `chrome` (default) and `firefox`.
53119

54120
## Additional docs
55121

bindings/wasm-sdk/examples/wasm-interop/README.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,22 @@ Alternatively, you can fill relay auth values directly in the
152152

153153
If UI values are present, they are used first and callback mode is skipped.
154154

155-
For RGB asset issuance + transfer flow, open:
155+
For RGB-over-Lightning flow, open:
156156

157157
```text
158158
http://localhost:8080/bindings/wasm-sdk/examples/wasm-interop/rgb_asset_transfer_flow.html
159159
```
160160

161-
Click `Run RGB Transfer Flow`.
161+
Click `Run RGB over Lightning Flow`.
162162
`rgb_asset_transfer_flow.html` is prefilled with local defaults for:
163163
indexer URL (`http://127.0.0.1:3002`), node proxy URL (`ws://127.0.0.1:3001`),
164-
and RGB transport endpoint (`http://127.0.0.1:3001/rgb/json-rpc`).
164+
RGB transport endpoint (`http://127.0.0.1:3001/rgb/json-rpc`),
165+
and peer addresses (`127.0.0.1:9745` / `127.0.0.1:9746`).
166+
167+
The flow is:
168+
`connectPeer` -> `openChannelValue` ->
169+
`issueAssetNia` -> `createLnInvoiceValue` ->
170+
`sendPaymentValue` with `asset_id` + `asset_amount`.
165171

166172
When sender wallet BTC is zero, the page now tries automatic local regtest funding
167173
through wasm gateway endpoint `POST /dev/regtest/fund`.
@@ -185,26 +191,16 @@ If auto-funding is disabled or unavailable, the page logs a manual fallback comm
185191
1. This example is browser-only (`--target web`).
186192
2. It focuses on deterministic interop surface checks, not full native RLN node runtime behavior.
187193
3. Peer-session start may fail in normal local runs if proxy/peer is not reachable; the example logs this as non-fatal.
188-
4. `rgb_asset_transfer_flow.html` signs PSBTs via wallet-native `signPsbtValue` by default.
189-
If you want to delegate signing to an external signer/wallet, define this callback:
190-
191-
```js
192-
window.signPsbt = async (unsignedPsbt) => {
193-
// return signed PSBT string from your external signer
194-
return unsignedPsbt;
195-
}
196-
```
197-
198-
In real usage, this callback is optional and can be used for hardware/external wallet integration.
199-
5. The RGB transfer page uses fixed constants in JS for:
194+
4. The RGB over Lightning page uses fixed constants in JS for:
200195
- `Indexer URL`: `http://127.0.0.1:3002`
201196
- `Node proxy URL` (for node handle construction): `ws://127.0.0.1:3001`
202197
- `RGB transport endpoint`: `http://127.0.0.1:3001/rgb/json-rpc`
203-
- sender/receiver RLN instances are initialized at runtime, each with generated keys and a generated wallet bootstrap
204-
- each SDK instance configures transport once via `setDefaultRgbProxyTransport(...)`; `blindReceive` then uses wallet defaults when `transport_endpoints` is omitted
205-
6. Additional runtime observability/control APIs are available on node/facade/node-handle surfaces:
198+
- `LN amount`: `3_000_000 msat` (minimum RGB-LN compatible amount)
199+
- canonical RGB `asset_id` values (`rgb:...`) are accepted in LN APIs
200+
- sender/receiver RLN instances are initialized at runtime and each SDK instance configures transport via `setDefaultRgbProxyTransport(...)`
201+
5. Additional runtime observability/control APIs are available on node/facade/node-handle surfaces:
206202
- `ldkRuntimeComponentsValue/Json` (runtime component readiness + lifecycle counters)
207203
- `chainSyncStart*` / `chainSyncStatus*` / `chainSyncStop*` / `chainSyncTick*` / `chainSyncEnqueueRebroadcastTx`
208204
- `listRgbLnTransfersValue/Json` (RGB-over-LN transfer ledger derived from LN payment state)
209-
7. `manual_js_wasm_interop.js` and `manual_js_virtual_channels_sdk_flow.js` now demonstrate these APIs directly
205+
6. `manual_js_wasm_interop.js` and `manual_js_virtual_channels_sdk_flow.js` now demonstrate these APIs directly
210206
(components status, chain sync start/status/stop, RGB-LN transfer listing).

0 commit comments

Comments
 (0)