This package provides a containerized Waku light node simulation server for testing and development. The server runs a headless browser using Playwright and exposes a REST API similar to the nwaku REST API. A Dockerfile is provided to allow programmatic simulation and "deployment" of js-waku nodes in any Waku orchestration environment that uses Docker (e.g. 10ksim ).
# Build the application
npm run build
# Start the server (port 8080)
npm run start:server
# Build and run Docker container
npm run docker:build
docker run -p 8080:8080 waku-browser-tests:local
Configure the Waku node using environment variables:
WAKU_CLUSTER_ID: Cluster ID (default: 1)WAKU_SHARD: Specific shard number - enables static sharding mode (optional)Sharding Behavior:
numShardsInCluster: 8 across cluster 1WAKU_SHARD is set, uses only that specific shardWAKU_ENR_BOOTSTRAP: Enable ENR bootstrap mode with custom bootstrap peers (comma-separated)WAKU_LIGHTPUSH_NODE: Preferred lightpush node multiaddr (Docker only)When WAKU_ENR_BOOTSTRAP is set:
defaultBootstrap: false)# Example: ENR bootstrap mode
WAKU_ENR_BOOTSTRAP="enr:-QEnuEBEAyErHEfhiQxAVQoWowGTCuEF9fKZtXSd7H_PymHFhGJA3rGAYDVSHKCyJDGRLBGsloNbS8AZF33IVuefjOO6BIJpZIJ2NIJpcIQS39tkim11bHRpYWRkcnO4lgAvNihub2RlLTAxLmRvLWFtczMud2FrdXYyLnRlc3Quc3RhdHVzaW0ubmV0BgG73gMAODcxbm9kZS0wMS5hYy1jbi1ob25na29uZy1jLndha3V2Mi50ZXN0LnN0YXR1c2ltLm5ldAYBu94DACm9A62t7AQL4Ef5ZYZosRpQTzFVAB8jGjf1TER2wH-0zBOe1-MDBNLeA4lzZWNwMjU2azGhAzfsxbxyCkgCqq8WwYsVWH7YkpMLnU2Bw5xJSimxKav-g3VkcIIjKA" npm run start:server
The server exposes the following HTTP endpoints:
GET /: Health check - returns server statusGET /waku/v1/peer-info: Get node peer informationPOST /waku/v1/wait-for-peers: Wait for peers with specific protocolsPOST /lightpush/v3/message: Send message via lightpushGET /app/index.html: Web application entry pointGET /app/*: Static web application filescurl -X POST http://localhost:8080/lightpush/v3/message \
-H "Content-Type: application/json" \
-d '{
"pubsubTopic": "",
"message": {
"contentTopic": "/test/1/example/proto",
"payload": "SGVsbG8gV2FrdQ==",
"version": 1
}
}'
curl -X POST http://localhost:8080/lightpush/v3/message \
-H "Content-Type: application/json" \
-d '{
"pubsubTopic": "/waku/2/rs/1/4",
"message": {
"contentTopic": "/test/1/example/proto",
"payload": "SGVsbG8gV2FrdQ==",
"version": 1
}
}'
curl -X POST http://localhost:8080/waku/v1/wait-for-peers \
-H "Content-Type: application/json" \
-d '{
"timeoutMs": 30000,
"protocols": ["lightpush", "filter"]
}'
curl -X GET http://localhost:8080/waku/v1/peer-info
Run with CLI arguments:
# Custom cluster and shard
node dist/src/server.js --cluster-id=2 --shard=0
The package includes several test suites:
# Basic server functionality tests (default)
npm test
# Docker testing workflow
npm run docker:build
npm run test:integration
# All tests
npm run test:all
# Individual test suites:
npm run test:server # Server-only tests
npm run test:e2e # End-to-end tests
Test Types:
server.spec.ts - Tests basic server functionality and static file servingintegration.spec.ts - Tests Docker container integration with external servicese2e.spec.ts - Full end-to-end tests using nwaku nodesThe package includes Docker support for containerized testing:
# Build image
docker build -t waku-browser-tests:local .
# Run with ENR bootstrap
docker run -p 8080:8080 \
-e WAKU_ENR_BOOTSTRAP="enr:-QEnuE..." \
-e WAKU_CLUSTER_ID="1" \
waku-browser-tests:local
# Run with specific configuration
docker run -p 8080:8080 \
-e WAKU_CLUSTER_ID="2" \
-e WAKU_SHARD="0" \
waku-browser-tests:local
The server automatically:
All endpoints are CORS-enabled for cross-origin requests.