Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix dispatchEvent test #1897

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/tests/src/lib/service_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@

// waku nodes takes some time to bind port so to decrease chances of conflict
// we also randomize the first port that portfinder will try
const startPort = Math.floor(Math.random() * (65535 - 1025) + 1025);
// depending on getPorts count adjust the random function in such a way that max port is 65535
const startPort = Math.floor(Math.random() * (65530 - 1025) + 1025);

const ports: Ports = await new Promise((resolve, reject) => {
portfinder.getPorts(4, { port: startPort }, (err, ports) => {
Expand Down Expand Up @@ -352,7 +353,7 @@
async restCall<T>(
endpoint: string,
method: "GET" | "POST",
body: any = null,

Check warning on line 356 in packages/tests/src/lib/service_node.ts

View workflow job for this annotation

GitHub Actions / check

Unexpected any. Specify a different type

Check warning on line 356 in packages/tests/src/lib/service_node.ts

View workflow job for this annotation

GitHub Actions / proto

Unexpected any. Specify a different type
processResponse: (response: Response) => Promise<T>
): Promise<T> {
this.checkProcess();
Expand Down
7 changes: 4 additions & 3 deletions packages/tests/tests/connection-mananger/methods.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ describe("Public methods", function () {
).to.eq(0);
});

// Will be skipped until https://github.com/waku-org/js-waku/issues/1835 is fixed
it.skip("dispatchEvent via connectionManager", async function () {
it("dispatchEvent via connectionManager", async function () {
const peerIdBootstrap = await createSecp256k1PeerId();
await waku.libp2p.peerStore.save(peerIdBootstrap, {
tags: {
Expand All @@ -252,7 +251,9 @@ describe("Public methods", function () {
);
});
waku.connectionManager.dispatchEvent(
new CustomEvent<PeerId>("peer:connect", { detail: peerIdBootstrap })
new CustomEvent<PeerId>(EPeersByDiscoveryEvents.PEER_CONNECT_BOOTSTRAP, {
detail: peerIdBootstrap
})
);
expect(await peerConnectedBootstrap).to.eq(true);
});
Expand Down
3 changes: 2 additions & 1 deletion packages/tests/tests/peer-exchange/query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ describe("Peer Exchange Query", function () {
await tearDownNodes([nwaku1, nwaku2, nwaku3], waku);
});

it("connected peers and dial", async function () {
// slow and flaky in CI
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's open an issue to track this please

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've opened this one

it.skip("connected peers and dial", async function () {
expect(peerInfos[0].ENR).to.not.be.null;
expect(peerInfos[0].ENR?.peerInfo?.multiaddrs).to.not.be.null;

Expand Down
Loading