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);
|
||||
const waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 });
|
||||
|
||||
const peerId = waku.libp2p.peerId.toB58String();
|
||||
|
||||
const localMultiaddr = waku.libp2p.multiaddrs.find((addr) =>
|
||||
addr.toString().match(/127\.0\.0\.1/)
|
||||
);
|
||||
const multiAddrWithId = localMultiaddr + '/p2p/' + peerId;
|
||||
const multiAddrWithId = waku.getLocalMultiaddrWithID();
|
||||
|
||||
const nimWaku = new NimWaku(makeLogFileName(this));
|
||||
await nimWaku.start({ staticnode: multiAddrWithId });
|
||||
|
|
|
@ -67,4 +67,20 @@ export default class Waku {
|
|||
async 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;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(10_000);
|
||||
this.timeout(12_000);
|
||||
waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 });
|
||||
|
||||
const peerId = waku.libp2p.peerId.toB58String();
|
||||
const localMultiaddr = waku.libp2p.multiaddrs.find((addr) =>
|
||||
addr.toString().match(/127\.0\.0\.1/)
|
||||
);
|
||||
const multiAddrWithId = localMultiaddr + '/p2p/' + peerId;
|
||||
|
||||
const multiAddrWithId = waku.getLocalMultiaddrWithID();
|
||||
nimWaku = new NimWaku(makeLogFileName(this));
|
||||
await nimWaku.start({ staticnode: multiAddrWithId });
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ export class NimWaku {
|
|||
}
|
||||
|
||||
public stop() {
|
||||
debug(
|
||||
dbg(
|
||||
`nim-waku ${
|
||||
this.process ? this.process.pid : this.pid
|
||||
} getting SIGINT at ${new Date().toLocaleTimeString()}`
|
||||
|
|
Loading…
Reference in New Issue