Write and run WAO SDK integration tests for HyperBEAM Erlang devices. Launches a real HyperBEAM node and tests devices via HTTP.
Resolve HyperBEAM path
Read .env.hyperbeam and extract the CWD value:
grep '^CWD=' .env.hyperbeam 2>/dev/null | cut -d= -f2-
If .env.hyperbeam doesn't exist or has no CWD, STOP immediately and tell the user:
No HyperBEAM configured. Device integration tests require a HyperBEAM installation.
Set it up by adding a
CWDentry to.env.hyperbeam:bashecho "CWD=/path/to/your/HyperBEAM" >> .env.hyperbeam
Then verify the directory exists:
test -d "$HB_DIR/src" && echo "HyperBEAM: OK" || echo "HyperBEAM: MISSING"
If MISSING, stop and tell the user the path in .env.hyperbeam is invalid.
Do NOT mark the task as done. Set the task status to "pending" and stop.
Steps
- •
Read
tasks.jsonand find the task matching$ARGUMENTS(task id). Update its status to"in_progress". - •
Kill stale HyperBEAM processes:
bashpkill -f beam.smp 2>/dev/null || true
- •
Read
docs/wao-sdk.mdfor HB class patterns (spawn, schedule, compute). - •
Write integration tests in
test/{name}-device.test.js:The
HyperBEAMclass reads.env.hyperbeamautomatically viadotenv, so it will find the correctCWD. No need to pass it manually.jsimport { describe, it, before, after } from "node:test" import assert from "node:assert" import { HB, HyperBEAM, acc } from "wao/test" describe("{name} device integration", () => { let hbeam, hb before(async () => { hbeam = await new HyperBEAM({ reset: true }).ready() hb = hbeam.hb }) after(async () => { if (hbeam) await hbeam.kill() }) it("should spawn process with device", async () => { const { id } = await hb.spawn({ "execution-device": "dev_{name}@1.0", }) assert.ok(id) }) it("should handle action via device", async () => { const { id } = await hb.spawn({ "execution-device": "dev_{name}@1.0", }) const result = await hb.schedule({ process: id, action: "MyAction", tags: { /* ... */ }, }) assert.ok(result) }) // Test all device operations: // - Spawn with device // - Each exported action // - Error handling (invalid action, bad input) // - State persistence across messages // - Device stacks (if applicable) }) - •
Run the tests:
bashyarn test test/{name}-device.test.js - •
If any tests fail:
- •Read the error output
- •Check if HyperBEAM started correctly
- •Fix the test or device code
- •Kill stale processes and re-run
- •Repeat until 100% pass
- •
Always ensure HyperBEAM is killed after tests (check
after()hook). - •
Update the task status to
"done"intasks.json.