From 04690b553a27fd788ae5f12ad5922ad81491939b Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Tue, 5 Oct 2021 15:29:39 +1100 Subject: [PATCH] Create promises before dialing --- .../status-communities/src/messenger.spec.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/status-communities/src/messenger.spec.ts b/packages/status-communities/src/messenger.spec.ts index 4df4eb5..ad7799a 100644 --- a/packages/status-communities/src/messenger.spec.ts +++ b/packages/status-communities/src/messenger.spec.ts @@ -32,15 +32,7 @@ describe("Messenger", () => { }), ]); - dbg("Connect messengers"); - // Connect both messengers together for test purposes - messengerAlice.waku.addPeerToAddressBook( - messengerBob.waku.libp2p.peerId, - messengerBob.waku.libp2p.multiaddrs - ); - - dbg("Wait for pubsub connection"); - await Promise.all([ + const pubsubPromises = [ new Promise((resolve) => messengerAlice.waku.libp2p.pubsub.once( "pubsub:subscription-change", @@ -52,7 +44,17 @@ describe("Messenger", () => { resolve(null) ) ), - ]); + ]; + + dbg("Connect messengers"); + // Connect both messengers together for test purposes + messengerAlice.waku.addPeerToAddressBook( + messengerBob.waku.libp2p.peerId, + messengerBob.waku.libp2p.multiaddrs + ); + + dbg("Wait for pubsub connection"); + await Promise.all(pubsubPromises); dbg("Messengers ready"); });