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: ensure that websocket multiaddrs are returned from ENR #1275

Merged
merged 2 commits into from
Mar 28, 2023
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
9 changes: 8 additions & 1 deletion packages/enr/src/enr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ describe("ENR", function () {
const ip6 = "::1";
const tcp = 8080;
const udp = 8080;
const wsMultiaddr = multiaddr(
"/dns4/node-01.do-ams3.wakuv2.prod.statusim.net/tcp/8000/wss"
);
let peerId: PeerId;
let enr: ENR;

Expand All @@ -323,6 +326,7 @@ describe("ENR", function () {
enr.udp = udp;
enr.tcp6 = tcp;
enr.udp6 = udp;
enr.multiaddrs = [wsMultiaddr];
});

it("should properly create location multiaddrs - udp4", () => {
Expand Down Expand Up @@ -391,7 +395,7 @@ describe("ENR", function () {
const peerInfo = enr.peerInfo!;
console.log(peerInfo);
expect(peerInfo.id.toString()).to.equal(peerId.toString());
expect(peerInfo.multiaddrs.length).to.equal(4);
expect(peerInfo.multiaddrs.length).to.equal(5);
expect(peerInfo.multiaddrs.map((ma) => ma.toString())).to.contain(
multiaddr(`/ip4/${ip4}/tcp/${tcp}`).toString()
);
Expand All @@ -404,6 +408,9 @@ describe("ENR", function () {
expect(peerInfo.multiaddrs.map((ma) => ma.toString())).to.contain(
multiaddr(`/ip6/${ip6}/udp/${udp}`).toString()
);
expect(peerInfo.multiaddrs.map((ma) => ma.toString())).to.contain(
wsMultiaddr.toString()
);
});
});

Expand Down
3 changes: 1 addition & 2 deletions packages/enr/src/enr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ export class ENR extends RawEnr implements IEnr {
}

const _multiaddrs = this.multiaddrs ?? [];
multiaddrs.concat(_multiaddrs);

return multiaddrs;
return multiaddrs.concat(_multiaddrs);
}

get peerInfo(): PeerInfo | undefined {
Expand Down