From b7ce121955f65c91365d9d0486d30bdb2499ab07 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Mon, 15 Mar 2021 11:35:30 +1100 Subject: [PATCH] Replace delay by waiting on correct event --- src/lib/node.spec.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/node.spec.ts b/src/lib/node.spec.ts index 65bc992a81..5256cf1742 100644 --- a/src/lib/node.spec.ts +++ b/src/lib/node.spec.ts @@ -20,12 +20,13 @@ test('Publishes message', async (t) => { await node1.dial(node2.peerId); await wakuRelayNode1.subscribe(); + await new Promise((resolve) => + node2.pubsub.once('pubsub:subscription-change', (...args) => resolve(args)) + ); // Setup the promise before publishing to ensure the event is not missed const promise = waitForNextData(node1.pubsub); - await delay(500); - await wakuRelayNode2.publish(message); const node1Received = await promise;