Replace delay by waiting on correct event

This commit is contained in:
Franck Royer 2021-03-15 11:35:30 +11:00
parent eb874a956b
commit b7ce121955
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4

View File

@ -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;