From c8abcd0fafff82747d3e0b4029bcfd1a49d4ca77 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Tue, 14 May 2024 19:53:20 +0200 Subject: [PATCH 1/4] Fix broken start() --- lib/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 3181770..e49448f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -91,7 +91,9 @@ function initNet(peer, config) { async function start() { await stats.loaded() glue(infos, connections) - queueMicrotask(() => scheduler.start.bind(scheduler)) + queueMicrotask(() => scheduler.start.bind(scheduler)((err) => { + if (err) console.error("pzp-net scheduler start failed:", err) + })) } function stop() { From 977e6c2fb331a839e56d0059bedfb2f469e7c4df Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Wed, 15 May 2024 18:01:31 +0200 Subject: [PATCH 2/4] Comment fix --- lib/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index e49448f..0dd09f1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -91,9 +91,9 @@ function initNet(peer, config) { async function start() { await stats.loaded() glue(infos, connections) - queueMicrotask(() => scheduler.start.bind(scheduler)((err) => { - if (err) console.error("pzp-net scheduler start failed:", err) - })) + //queueMicrotask(() => scheduler.start.bind(scheduler)((err) => { + // if (err) console.error("pzp-net scheduler start failed:", err) + //})) } function stop() { From 319dd8f4ab14346f2a3f3341c430b48feeee6b8c Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Wed, 15 May 2024 18:12:21 +0200 Subject: [PATCH 3/4] Try adding timeouts to tests --- lib/index.js | 6 +++--- test/glue.test.js | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 0dd09f1..e49448f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -91,9 +91,9 @@ function initNet(peer, config) { async function start() { await stats.loaded() glue(infos, connections) - //queueMicrotask(() => scheduler.start.bind(scheduler)((err) => { - // if (err) console.error("pzp-net scheduler start failed:", err) - //})) + queueMicrotask(() => scheduler.start.bind(scheduler)((err) => { + if (err) console.error("pzp-net scheduler start failed:", err) + })) } function stop() { diff --git a/test/glue.test.js b/test/glue.test.js index d8f3a15..ba7cea6 100644 --- a/test/glue.test.js +++ b/test/glue.test.js @@ -62,6 +62,9 @@ test('Glueing together stats with connections', async (t) => { while (FS.existsSync(statsJSONPath) === false) { await p(setTimeout)(1) } + + await p(setTimeout)(1000) + const fileContents = FS.readFileSync(statsJSONPath, 'utf8') const json = JSON.parse(fileContents) assert.deepEqual(Object.keys(json), [TEST_ADDR]) @@ -101,12 +104,17 @@ test('Glueing together stats with connections', async (t) => { while (FS.existsSync(statsJSONPath) === false) { await p(setTimeout)(1) } + + await p(setTimeout)(1000) + const fileContents = FS.readFileSync(statsJSONPath, 'utf8') assert.equal(fileContents.length > 10, true, 'stats.json is not empty') peer.net.forget(address) await p(setTimeout)(200) + await p(setTimeout)(1000) + const entriesAfterForget = await p(peer.net.peers())(null) assert.equal(entriesAfterForget.length, 0, 'there is no entry in peers()') From 760e899876c2a5317b97e1b7e23e4e6239ce9e23 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Wed, 15 May 2024 18:22:02 +0200 Subject: [PATCH 4/4] Increase test timeout --- test/glue.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/glue.test.js b/test/glue.test.js index ba7cea6..47f64cc 100644 --- a/test/glue.test.js +++ b/test/glue.test.js @@ -63,7 +63,7 @@ test('Glueing together stats with connections', async (t) => { await p(setTimeout)(1) } - await p(setTimeout)(1000) + await p(setTimeout)(2000) const fileContents = FS.readFileSync(statsJSONPath, 'utf8') const json = JSON.parse(fileContents)