Create promises before dialing

This commit is contained in:
Franck Royer 2021-10-05 15:29:39 +11:00
parent ea49955412
commit 04690b553a
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 12 additions and 10 deletions

View File

@ -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");
});