From 50eaa39fecbbfc750c6ef5492f0c43389b5d4e8e Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Mon, 10 May 2021 20:18:26 +1000 Subject: [PATCH] Add debug statement in tests Also enable debug logs in CI. --- .github/workflows/ci.yml | 2 ++ src/lib/waku_relay/index.spec.ts | 7 +++++++ src/test_utils/nim_waku.ts | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b81bc2519b..f33c0ecb95 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,6 +97,8 @@ jobs: [ $(git status --short --ignore-submodules|wc -l) -eq 0 ] - name: test + env: + DEBUG: "waku:nim-waku*,waku:test*" run: npm run test - name: Upload logs on failure diff --git a/src/lib/waku_relay/index.spec.ts b/src/lib/waku_relay/index.spec.ts index eb0303b2aa..cf3265dfb9 100644 --- a/src/lib/waku_relay/index.spec.ts +++ b/src/lib/waku_relay/index.spec.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import debug from 'debug'; import TCP from 'libp2p-tcp'; import { @@ -13,6 +14,8 @@ import { WakuMessage } from '../waku_message'; import { RelayCodec, RelayDefaultTopic } from './index'; +const log = debug('waku:test'); + describe('Waku Relay', () => { afterEach(function () { if (this.currentTest?.state === 'failed') { @@ -130,6 +133,8 @@ describe('Waku Relay', () => { beforeEach(async function () { this.timeout(30_000); + + log('Create waku node'); waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1, listenAddresses: ['/ip4/0.0.0.0/tcp/0'], @@ -138,8 +143,10 @@ describe('Waku Relay', () => { const multiAddrWithId = waku.getLocalMultiaddrWithID(); nimWaku = new NimWaku(makeLogFileName(this)); + log('Starting nim-waku'); await nimWaku.start({ staticnode: multiAddrWithId }); + log('Waiting for heartbeat'); await new Promise((resolve) => waku.libp2p.pubsub.once('gossipsub:heartbeat', resolve) ); diff --git a/src/test_utils/nim_waku.ts b/src/test_utils/nim_waku.ts index 3096463076..19b5725399 100644 --- a/src/test_utils/nim_waku.ts +++ b/src/test_utils/nim_waku.ts @@ -14,7 +14,7 @@ import * as proto from '../proto/waku/v2/message'; import { existsAsync, mkdirAsync, openAsync } from './async_fs'; import waitForLine from './log_file'; -const dbg = debug('nim-waku'); +const dbg = debug('waku:nim-waku'); const NIM_WAKU_DEFAULT_P2P_PORT = 60000; const NIM_WAKU_DEFAULT_RPC_PORT = 8545; @@ -114,7 +114,9 @@ export class NimWaku { ); }); + dbg("Waiting to see 'RPC Server started' in nim-waku logs"); await this.waitForLog('RPC Server started'); + dbg('nim-waku node has been started'); } public stop(): void {