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

fix: failing node_optional check #2025

Merged
merged 4 commits into from
Jun 18, 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
4 changes: 0 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./lib/predefined_bootstrap_nodes": {
weboko marked this conversation as resolved.
Show resolved Hide resolved
"types": "./dist/lib/predefined_bootstrap_nodes.d.ts",
"import": "./dist/lib/predefined_bootstrap_nodes.js"
},
"./lib/message/version_0": {
"types": "./dist/lib/message/version_0.d.ts",
"import": "./dist/lib/message/version_0.js"
Expand Down
68 changes: 0 additions & 68 deletions packages/core/src/lib/predefined_bootstrap_nodes.ts

This file was deleted.

80 changes: 43 additions & 37 deletions packages/tests/tests/peer-exchange/pe.optional.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { bootstrap } from "@libp2p/bootstrap";
import {
Fleet,
getPredefinedBootstrapNodes
} from "@waku/core/lib/predefined_bootstrap_nodes";
import { wakuPeerExchangeDiscovery } from "@waku/discovery";
DnsNodeDiscovery,
enrTree,
wakuPeerExchangeDiscovery
} from "@waku/discovery";
import type { LightNode } from "@waku/interfaces";
import { createLightNode } from "@waku/sdk";
import {
Expand All @@ -17,50 +17,56 @@ import { afterEachCustom, tearDownNodes } from "../../src";
describe("Peer Exchange", () => {
describe("Auto Discovery", function () {
let waku: LightNode;
const predefinedNodes: string[] = [];

afterEachCustom(this, async () => {
await tearDownNodes([], waku);
});

const testCases: [Fleet, number][] = [
[Fleet.Test, 2], // on test fleet there are only 3 peers
[Fleet.Sandbox, 3]
];
it(`should discover peers other than used for bootstrapping`, async function () {
this.timeout(50_000);

testCases.map(([name, nodes]) => {
it(`should discover peers other than used for bootstrapping on ${name} fleet`, async function () {
this.timeout(50_000);
const predefinedNodes = getPredefinedBootstrapNodes(name, nodes);
const dns = await DnsNodeDiscovery.dnsOverHttp();
const dnsEnrs = await dns.getPeers(
[enrTree["SANDBOX"], enrTree["TEST"]],
{
lightPush: 1
}
);
const dnsPeerMultiaddrs = dnsEnrs
.flatMap(
(enr) => enr.peerInfo?.multiaddrs.map((ma) => ma.toString()) ?? []
)
.filter((ma) => ma.includes("wss"));

const singleShardInfo = { clusterId: 1, shard: 1 };
const shardInfo = singleShardInfosToShardInfo([singleShardInfo]);
const pubsubTopic = singleShardInfoToPubsubTopic(singleShardInfo);
waku = await createLightNode({
libp2p: {
peerDiscovery: [
bootstrap({ list: predefinedNodes }),
wakuPeerExchangeDiscovery([pubsubTopic])
]
},
shardInfo: shardInfo
});
const singleShardInfo = { clusterId: 1, shard: 1 };
const shardInfo = singleShardInfosToShardInfo([singleShardInfo]);
const pubsubTopic = singleShardInfoToPubsubTopic(singleShardInfo);
waku = await createLightNode({
libp2p: {
peerDiscovery: [
bootstrap({ list: dnsPeerMultiaddrs }),
wakuPeerExchangeDiscovery([pubsubTopic])
]
},
shardInfo: shardInfo
});

await waku.start();
await waku.start();

const foundPxPeer = await new Promise<boolean>((resolve) => {
waku.libp2p.addEventListener("peer:discovery", (evt) => {
const peerId = evt.detail.id.toString();
const isBootstrapNode = predefinedNodes.find((n) =>
n.includes(peerId)
);
if (!isBootstrapNode) {
resolve(true);
}
});
const foundPxPeer = await new Promise<boolean>((resolve) => {
waku.libp2p.addEventListener("peer:discovery", (evt) => {
const peerId = evt.detail.id.toString();
const isBootstrapNode = predefinedNodes.find((n) =>
n.includes(peerId)
);
if (!isBootstrapNode) {
resolve(true);
}
});

expect(foundPxPeer).to.be.true;
});

expect(foundPxPeer).to.be.true;
});
});
});
Loading