Skip to content

Commit f8e02ab

Browse files
fix(tests): append p2p with the multiaddrs from ENR (#1817)
* append `p2p` with the multiaddrs from ENR * fix(tests): add p2p checks for ENR multiaddrs * fix(tests): type getter * chore(ci): remove debug flag from nwaku_master and go-waku tests
1 parent 749d84d commit f8e02ab

File tree

9 files changed

+17
-13
lines changed

9 files changed

+17
-13
lines changed

.github/workflows/ci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ jobs:
8787
with:
8888
nim_wakunode_image: harbor.status.im/wakuorg/nwaku:latest
8989
test_type: nwaku-master
90-
debug: waku*
9190

9291
maybe-release:
9392
name: release

packages/enr/src/enr.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,19 @@ describe("ENR", function () {
396396
expect(peerInfo.id.toString()).to.equal(peerId.toString());
397397
expect(peerInfo.multiaddrs.length).to.equal(5);
398398
expect(peerInfo.multiaddrs.map((ma) => ma.toString())).to.contain(
399-
multiaddr(`/ip4/${ip4}/tcp/${tcp}`).toString()
399+
multiaddr(`/ip4/${ip4}/tcp/${tcp}/p2p/${peerId}`).toString()
400400
);
401401
expect(peerInfo.multiaddrs.map((ma) => ma.toString())).to.contain(
402-
multiaddr(`/ip6/${ip6}/tcp/${tcp}`).toString()
402+
multiaddr(`/ip6/${ip6}/tcp/${tcp}/p2p/${peerId}`).toString()
403403
);
404404
expect(peerInfo.multiaddrs.map((ma) => ma.toString())).to.contain(
405-
multiaddr(`/ip4/${ip4}/udp/${udp}`).toString()
405+
multiaddr(`/ip4/${ip4}/udp/${udp}/p2p/${peerId}`).toString()
406406
);
407407
expect(peerInfo.multiaddrs.map((ma) => ma.toString())).to.contain(
408-
multiaddr(`/ip6/${ip6}/udp/${udp}`).toString()
408+
multiaddr(`/ip6/${ip6}/udp/${udp}/p2p/${peerId}`).toString()
409409
);
410410
expect(peerInfo.multiaddrs.map((ma) => ma.toString())).to.contain(
411-
wsMultiaddr.toString()
411+
`${wsMultiaddr.toString()}/p2p/${peerId}`
412412
);
413413
});
414414
});

packages/enr/src/enr.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ export class ENR extends RawEnr implements IEnr {
107107

108108
const _multiaddrs = this.multiaddrs ?? [];
109109

110-
return multiaddrs.concat(_multiaddrs);
110+
return multiaddrs.concat(_multiaddrs).map((ma) => {
111+
if (this.peerId) {
112+
return ma.encapsulate(`/p2p/${this.peerId.toString()}`);
113+
}
114+
return ma;
115+
});
111116
}
112117

113118
get peerInfo(): PeerInfo | undefined {

packages/tests/src/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class ServiceNodesFleet {
8484
get type(): "go-waku" | "nwaku" {
8585
const nodeType = new Set(
8686
this.nodes.map((node) => {
87-
return node.type();
87+
return node.type;
8888
})
8989
);
9090
if (nodeType.size > 1) {

packages/tests/src/lib/service_node.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class ServiceNode {
7979
this.logPath = `${LOG_DIR}/wakunode_${logName}.log`;
8080
}
8181

82-
type(): "go-waku" | "nwaku" {
82+
get type(): "go-waku" | "nwaku" {
8383
return isGoWaku ? "go-waku" : "nwaku";
8484
}
8585

packages/tests/tests/filter/single_node/push.node.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ describe("Waku Filter V2: FilterPush", function () {
167167
]);
168168

169169
// For go-waku the message is received (it is possible to send a message with no payload)
170-
if (nwaku.type() == "go-waku") {
170+
if (nwaku.type == "go-waku") {
171171
expect(await messageCollector.waitForMessages(1)).to.eq(true);
172172
} else {
173173
expect(await messageCollector.waitForMessages(1)).to.eq(false);

packages/tests/tests/light-push/single_node/index.node.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe("Waku Light Push: Single Node", function () {
155155
messagePayload
156156
);
157157

158-
if (nwaku.type() == "go-waku") {
158+
if (nwaku.type == "go-waku") {
159159
expect(pushResponse.recipients.length).to.eq(1);
160160
expect(await messageCollector.waitForMessages(1)).to.eq(true);
161161
messageCollector.verifyReceivedMessage(0, {

packages/tests/tests/store/cursor.node.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe("Waku Store, cursor", function () {
162162
expect(messagesAfterCursor.length).to.eql(0);
163163
} catch (error) {
164164
if (
165-
nwaku.type() === "go-waku" &&
165+
nwaku.type === "go-waku" &&
166166
typeof error === "string" &&
167167
error.includes("History response contains an Error: INVALID_CURSOR")
168168
) {

packages/tests/tests/store/page_size.node.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe("Waku Store, page size", function () {
5454
if (pageSize === 0) {
5555
effectivePageSize = 20;
5656
} else if (pageSize > 100) {
57-
if (nwaku.type() == "go-waku") {
57+
if (nwaku.type == "go-waku") {
5858
effectivePageSize = 20;
5959
} else {
6060
effectivePageSize = 100;

0 commit comments

Comments
 (0)