mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-25 02:25:42 +00:00
Replace delay by waiting on correct event
This commit is contained in:
parent
eb874a956b
commit
b7ce121955
@ -20,12 +20,13 @@ test('Publishes message', async (t) => {
|
|||||||
await node1.dial(node2.peerId);
|
await node1.dial(node2.peerId);
|
||||||
|
|
||||||
await wakuRelayNode1.subscribe();
|
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
|
// Setup the promise before publishing to ensure the event is not missed
|
||||||
const promise = waitForNextData(node1.pubsub);
|
const promise = waitForNextData(node1.pubsub);
|
||||||
|
|
||||||
await delay(500);
|
|
||||||
|
|
||||||
await wakuRelayNode2.publish(message);
|
await wakuRelayNode2.publish(message);
|
||||||
|
|
||||||
const node1Received = await promise;
|
const node1Received = await promise;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user