mirror of https://github.com/status-im/js-waku.git
Merge #31
31: Remove warnings r=D4nte a=D4nte Co-authored-by: Franck Royer <franck@royer.one>
This commit is contained in:
commit
41fa29feac
|
@ -12,7 +12,7 @@ import { RelayCodec, RelayDefaultTopic } from './index';
|
|||
|
||||
describe('Waku Relay', () => {
|
||||
afterEach(function () {
|
||||
if (this.currentTest!.state === 'failed') {
|
||||
if (this.currentTest?.state === 'failed') {
|
||||
console.log(`Test failed, log file name is ${makeLogFileName(this)}`);
|
||||
}
|
||||
});
|
||||
|
@ -41,15 +41,13 @@ describe('Waku Relay', () => {
|
|||
|
||||
await Promise.all([
|
||||
new Promise((resolve) =>
|
||||
waku1.libp2p.pubsub.once(
|
||||
'pubsub:subscription-change',
|
||||
(...args: any[]) => resolve(args)
|
||||
waku1.libp2p.pubsub.once('pubsub:subscription-change', () =>
|
||||
resolve(null)
|
||||
)
|
||||
),
|
||||
new Promise((resolve) =>
|
||||
waku2.libp2p.pubsub.once(
|
||||
'pubsub:subscription-change',
|
||||
(...args: any[]) => resolve(args)
|
||||
waku2.libp2p.pubsub.once('pubsub:subscription-change', () =>
|
||||
resolve(null)
|
||||
)
|
||||
),
|
||||
]);
|
||||
|
@ -173,7 +171,7 @@ describe('Waku Relay', () => {
|
|||
this.timeout(10_000);
|
||||
waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 });
|
||||
|
||||
nimWaku = new NimWaku(this.test!.ctx!.currentTest!.title);
|
||||
nimWaku = new NimWaku(this.test?.ctx?.currentTest?.title + '');
|
||||
await nimWaku.start();
|
||||
|
||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||
|
@ -252,7 +250,7 @@ describe('Waku Relay', () => {
|
|||
Waku.create({ staticNoiseKey: NOISE_KEY_2 }),
|
||||
]);
|
||||
|
||||
nimWaku = new NimWaku(this.test!.ctx!.currentTest!.title);
|
||||
nimWaku = new NimWaku(this.test?.ctx?.currentTest?.title + '');
|
||||
await nimWaku.start();
|
||||
|
||||
const nimWakuMultiaddr = await nimWaku.getMultiaddrWithId();
|
||||
|
@ -315,10 +313,9 @@ describe('Waku Relay', () => {
|
|||
});
|
||||
});
|
||||
|
||||
function waitForNextData(pubsub: Pubsub): Promise<WakuMessage> {
|
||||
return new Promise((resolve) => {
|
||||
async function waitForNextData(pubsub: Pubsub): Promise<WakuMessage> {
|
||||
const msg = (await new Promise((resolve) => {
|
||||
pubsub.once(RelayDefaultTopic, resolve);
|
||||
}).then((msg: any) => {
|
||||
return WakuMessage.decode(msg.data);
|
||||
});
|
||||
})) as Pubsub.InMessage;
|
||||
return WakuMessage.decode(msg.data);
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ export class WakuRelayPubsub extends Gossipsub {
|
|||
);
|
||||
this.mesh.set(topic, peers);
|
||||
}
|
||||
this.mesh.get(topic)!.forEach((id) => {
|
||||
this.mesh.get(topic)?.forEach((id) => {
|
||||
this.log('JOIN: Add mesh link to %s in %s', id, topic);
|
||||
this._sendGraft(id, topic);
|
||||
});
|
||||
|
@ -156,7 +156,7 @@ export class WakuRelayPubsub extends Gossipsub {
|
|||
this.lastpub.set(topic, this._now());
|
||||
}
|
||||
|
||||
meshPeers!.forEach((peer) => {
|
||||
meshPeers?.forEach((peer) => {
|
||||
toSend.add(peer);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@ export class RelayHeartbeat extends Heartbeat {
|
|||
|
||||
const timeout = setTimeout(() => {
|
||||
heartbeat();
|
||||
this._heartbeatTimer!.runPeriodically(
|
||||
this._heartbeatTimer?.runPeriodically(
|
||||
heartbeat,
|
||||
constants.RelayHeartbeatInterval
|
||||
);
|
||||
|
@ -36,7 +36,7 @@ export class RelayHeartbeat extends Heartbeat {
|
|||
},
|
||||
cancel: () => {
|
||||
clearTimeout(timeout);
|
||||
clearInterval(this._heartbeatTimer!._intervalId as NodeJS.Timeout);
|
||||
clearInterval(this._heartbeatTimer?._intervalId as NodeJS.Timeout);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ export class RelayHeartbeat extends Heartbeat {
|
|||
const topicPeers = this.gossipsub.topics.get(topic);
|
||||
fanoutPeers.forEach((id) => {
|
||||
if (
|
||||
!topicPeers!.has(id) ||
|
||||
!topicPeers?.has(id) ||
|
||||
getScore(id) <
|
||||
this.gossipsub._options.scoreThresholds.publishThreshold
|
||||
) {
|
||||
|
|
|
@ -41,9 +41,9 @@ function clean(str: string): string {
|
|||
}
|
||||
|
||||
export function makeLogFileName(ctx: Context): string {
|
||||
const unitTest = ctx!.currentTest ? ctx!.currentTest : ctx.test;
|
||||
const unitTest = ctx?.currentTest ? ctx!.currentTest : ctx.test;
|
||||
let name = clean(unitTest!.title);
|
||||
let suite = unitTest!.parent;
|
||||
let suite = unitTest?.parent;
|
||||
|
||||
while (suite && suite.title) {
|
||||
name = clean(suite.title) + '_' + name;
|
||||
|
|
|
@ -213,7 +213,10 @@ export class NimWaku {
|
|||
return `http://localhost:${port}/`;
|
||||
}
|
||||
|
||||
private async rpcCall(method: string, params: any[]) {
|
||||
private async rpcCall(
|
||||
method: string,
|
||||
params: Array<string | number | unknown>
|
||||
) {
|
||||
const res = await axios.post(
|
||||
this.rpcUrl,
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue