mirror of https://github.com/waku-org/js-waku.git
Test cleanup
This commit is contained in:
parent
eb9f1c154b
commit
79a9520348
|
@ -11,12 +11,7 @@ describe('Waku', function () {
|
||||||
this.timeout(10_000);
|
this.timeout(10_000);
|
||||||
const waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 });
|
const waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 });
|
||||||
|
|
||||||
const peerId = waku.libp2p.peerId.toB58String();
|
const multiAddrWithId = waku.getLocalMultiaddrWithID();
|
||||||
|
|
||||||
const localMultiaddr = waku.libp2p.multiaddrs.find((addr) =>
|
|
||||||
addr.toString().match(/127\.0\.0\.1/)
|
|
||||||
);
|
|
||||||
const multiAddrWithId = localMultiaddr + '/p2p/' + peerId;
|
|
||||||
|
|
||||||
const nimWaku = new NimWaku(makeLogFileName(this));
|
const nimWaku = new NimWaku(makeLogFileName(this));
|
||||||
await nimWaku.start({ staticnode: multiAddrWithId });
|
await nimWaku.start({ staticnode: multiAddrWithId });
|
||||||
|
|
|
@ -67,4 +67,20 @@ export default class Waku {
|
||||||
async stop() {
|
async stop() {
|
||||||
await this.libp2p.stop();
|
await this.libp2p.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the local multiaddr with peer id on which libp2p is listening.
|
||||||
|
* @throws if libp2p is not listening on localhost
|
||||||
|
*/
|
||||||
|
getLocalMultiaddrWithID(): string {
|
||||||
|
const localMultiaddr = this.libp2p.multiaddrs.find((addr) =>
|
||||||
|
addr.toString().match(/127\.0\.0\.1/)
|
||||||
|
);
|
||||||
|
if (!localMultiaddr || localMultiaddr.toString() === '') {
|
||||||
|
throw 'Not listening on localhost';
|
||||||
|
}
|
||||||
|
const multiAddrWithId =
|
||||||
|
localMultiaddr + '/p2p/' + this.libp2p.peerId.toB58String();
|
||||||
|
return multiAddrWithId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,15 +99,10 @@ describe('Waku Relay', () => {
|
||||||
let nimWaku: NimWaku;
|
let nimWaku: NimWaku;
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
this.timeout(10_000);
|
this.timeout(12_000);
|
||||||
waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 });
|
waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 });
|
||||||
|
|
||||||
const peerId = waku.libp2p.peerId.toB58String();
|
const multiAddrWithId = waku.getLocalMultiaddrWithID();
|
||||||
const localMultiaddr = waku.libp2p.multiaddrs.find((addr) =>
|
|
||||||
addr.toString().match(/127\.0\.0\.1/)
|
|
||||||
);
|
|
||||||
const multiAddrWithId = localMultiaddr + '/p2p/' + peerId;
|
|
||||||
|
|
||||||
nimWaku = new NimWaku(makeLogFileName(this));
|
nimWaku = new NimWaku(makeLogFileName(this));
|
||||||
await nimWaku.start({ staticnode: multiAddrWithId });
|
await nimWaku.start({ staticnode: multiAddrWithId });
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ export class NimWaku {
|
||||||
}
|
}
|
||||||
|
|
||||||
public stop() {
|
public stop() {
|
||||||
debug(
|
dbg(
|
||||||
`nim-waku ${
|
`nim-waku ${
|
||||||
this.process ? this.process.pid : this.pid
|
this.process ? this.process.pid : this.pid
|
||||||
} getting SIGINT at ${new Date().toLocaleTimeString()}`
|
} getting SIGINT at ${new Date().toLocaleTimeString()}`
|
||||||
|
|
Loading…
Reference in New Issue