Skip to content

fix(tests): add relay-only peer nwaku so mesh forms before tests publish#2782

Closed
Ivansete-status wants to merge 1 commit into
masterfrom
fix-ci-add-peer-nwaku-for-mesh
Closed

fix(tests): add relay-only peer nwaku so mesh forms before tests publish#2782
Ivansete-status wants to merge 1 commit into
masterfrom
fix-ci-add-peer-nwaku-for-mesh

Conversation

@Ivansete-status

Copy link
Copy Markdown
Contributor

Summary

Tests built on runNodes (Store, Filter single-node, etc.) spawn one nwaku container + one js-waku LightNode. Light nodes never join the gossipsub mesh, so the nwaku has zero mesh peers on the test topic. Since nwaku PR #3669 (Jan 2026) the REST endpoint POST /relay/v1/auto/messages returns HTTP 400 / NoPeersToPublish in that state instead of silently succeeding, so ServiceNode.sendMessage() returns false and every test that seeds the store via REST publish fails.

That regression broke ~50 / 56 of the failing assertions on the nwaku js-waku-node CI job; the job has been red on every nwaku master run since (see nwaku run 26212476786 for the most recent example).

This PR fixes the harness rather than reverting the (correct) nwaku change.

What changed

  • runNodes now starts a second relay-only ServiceNode chained to the primary via --staticnode, subscribed to the same shards/topics. Once the gossipsub mesh GRAFTs, REST publishes on the primary have a real mesh peer and succeed.
  • The peer's lifecycle is bound to the primary via a new private companion field + setCompanion() setter; existing tearDownNodes(nwaku, ...) calls cascade and stop both nodes — no test changes needed.
  • Add ServiceNode.waitForMeshPeers(pubsubTopics, {timeoutMs}) polling /admin/v1/peers/mesh, called before runNodes returns so the first publish doesn't race the gossipsub heartbeat.

Out of scope

  • ServiceNodesFleet tests (already multi-node) — untouched.
  • The Filter "Multiple Service Nodes" duplication failures (tests 51-54 in the same nwaku run) and the Peer Exchange compliance timeouts (tests 55-56) are separate bugs — not addressed here.

Test plan

  • Local lint + typecheck pass: npm run check --workspace=@waku/tests
  • npm run build:esm passes across all workspaces ✅
  • test:node job green against quay.io/wakuorg/nwaku-pr:<latest> — needs CI

🤖 Generated with Claude Code

Tests built on `runNodes` (Store, Filter single-node, etc.) start a single
nwaku container and a js-waku LightNode. LightNodes never join the
gossipsub mesh, so the nwaku ends up with zero mesh peers on the test
topic. After nwaku PR #3669 (Jan 2026) the REST endpoint
`POST /relay/v1/auto/messages` now returns HTTP 400 with
`NoPeersToPublish` instead of silently succeeding in that state, which
causes `ServiceNode.sendMessage()` to return `false` and fails every
test that seeds the store via REST publish. That broke ~50/56 of the
failing assertions in the nwaku `js-waku-node` CI job and the job has
been red on every master run since.

Fix the test harness rather than reverting the (correct) nwaku change:

- `runNodes` now starts a second relay-only `ServiceNode` chained to the
  primary via `--staticnode`, subscribed to the same shards/topics. Once
  the gossipsub mesh GRAFTs, REST publishes on the primary have a real
  mesh peer and succeed.
- The peer's lifecycle is bound to the primary through a new private
  `companion` field + `setCompanion()` getter; existing `tearDownNodes`
  calls keep working unchanged.
- Add `ServiceNode.waitForMeshPeers(pubsubTopics, {timeoutMs})` polling
  `/admin/v1/peers/mesh`, called before `runNodes` returns so the first
  publish doesn't race the heartbeat.

Doesn't touch `ServiceNodesFleet` (already multi-node); doesn't address
the Filter Multiple-Service-Nodes duplication or Peer Exchange compliance
timeouts surfaced in the same run — those are separate bugs.
@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 96.4 KB (0%) 2 s (0%) 1.1 s (+13.28% 🔺) 3 s
Waku Simple Light Node 147.68 KB (0%) 3 s (0%) 825 ms (-37.75% 🔽) 3.8 s
ECIES encryption 22.62 KB (0%) 453 ms (0%) 359 ms (+94.12% 🔺) 811 ms
Symmetric encryption 22 KB (0%) 440 ms (0%) 441 ms (+20.85% 🔺) 881 ms
DNS discovery 52.17 KB (0%) 1.1 s (0%) 966 ms (+12.77% 🔺) 2.1 s
Peer Exchange discovery 52.91 KB (0%) 1.1 s (0%) 754 ms (+101.04% 🔺) 1.9 s
Peer Cache Discovery 46.64 KB (0%) 933 ms (0%) 425 ms (-42.91% 🔽) 1.4 s
Privacy preserving protocols 77.31 KB (0%) 1.6 s (0%) 921 ms (-22.58% 🔽) 2.5 s
Waku Filter 79.82 KB (0%) 1.6 s (0%) 995 ms (+11.01% 🔺) 2.6 s
Waku LightPush 77.97 KB (0%) 1.6 s (0%) 1.3 s (+68.33% 🔺) 2.8 s
History retrieval protocols 83.74 KB (0%) 1.7 s (0%) 796 ms (+0.05% 🔺) 2.5 s
Deterministic Message Hashing 28.98 KB (0%) 580 ms (0%) 515 ms (+2.71% 🔺) 1.1 s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant