fix: ensure that websocket multiaddrs are returned from ENR (#1275)

Closes: #1271

Co-authored-by: Danish Arora <35004822+danisharora099@users.noreply.github.com>
This commit is contained in:
fryorcraken.eth 2023-03-29 04:14:03 +11:00 committed by GitHub
parent c68f29adc3
commit 94940411b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -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;
@ -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", () => {
@ -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()
);
@ -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()
);
});
});

View File

@ -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 {