waku-org / js-waku

JavaScript implementation of Waku v2
https://js.waku.org
Apache License 2.0
162 stars 41 forks source link

fix(tests): flaky timeout to wait for peer-exchange #2010

Open danisharora099 opened 1 month ago

danisharora099 commented 1 month ago

This is a change request

Problem

For our compliance test: https://github.com/waku-org/js-waku/blob/6f188ef37978c93432774a5b3cac02e0b40fd184/packages/tests/tests/peer-exchange/compliance.spec.ts#L51-L54, we seem to wait 1000ms/1s, to ensure peer-exchange is mounted on the js-waku node.

This is quite hacky, and seems to introduce some race conditions as brought up by @gabrielmer.

Proposed Solutions

Use a more predictable logic that waits for peer-exchange to be mounted. Eg: peerExchange.isMounted/peerExchange.on("mounted")