24: Remove noisy test logs r=D4nte a=D4nte



Co-authored-by: Franck Royer <franck@royer.one>
This commit is contained in:
bors[bot] 2021-04-09 06:19:36 +00:00 committed by GitHub
commit 3333a9c6c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 16 deletions

View File

@ -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 });

View File

@ -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;
}
}

View File

@ -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 });

View File

@ -3,6 +3,7 @@ import { randomInt } from 'crypto';
import appRoot from 'app-root-path';
import axios from 'axios';
import debug from 'debug';
import Multiaddr from 'multiaddr';
import multiaddr from 'multiaddr';
import PeerId from 'peer-id';
@ -13,6 +14,8 @@ import { RelayDefaultTopic } from '../lib/waku_relay';
import { existsAsync, mkdirAsync, openAsync } from './async_fs';
import waitForLine from './log_file';
const dbg = debug('nim-waku');
const NIM_WAKU_DEFAULT_P2P_PORT = 60000;
const NIM_WAKU_DEFAULT_RPC_PORT = 8545;
const NIM_WAKU_DIR = appRoot + '/nim-waku';
@ -88,14 +91,14 @@ export class NimWaku {
],
});
this.pid = this.process.pid;
console.log(
dbg(
`nim-waku ${
this.process.pid
} started at ${new Date().toLocaleTimeString()}`
);
this.process.on('exit', (signal) => {
console.log(
dbg(
`nim-waku ${
this.process ? this.process.pid : this.pid
} process exited with ${signal} at ${new Date().toLocaleTimeString()}`
@ -114,7 +117,7 @@ export class NimWaku {
}
public stop() {
console.log(
dbg(
`nim-waku ${
this.process ? this.process.pid : this.pid
} getting SIGINT at ${new Date().toLocaleTimeString()}`