Compare commits

...

6 Commits

Author SHA1 Message Date
Jacob Karlsson a9a2d6746c 1.0.1 2024-05-15 18:29:19 +02:00
Powersource 2c9aa7384c Merge pull request 'Fix broken start()' (#2) from fix-start into master
Reviewed-on: https://codeberg.org/pzp/pzp-net/pulls/2
2024-05-15 16:24:22 +00:00
Jacob Karlsson 760e899876 Increase test timeout 2024-05-15 18:22:02 +02:00
Jacob Karlsson 319dd8f4ab Try adding timeouts to tests 2024-05-15 18:12:21 +02:00
Jacob Karlsson 977e6c2fb3 Comment fix 2024-05-15 18:01:31 +02:00
Jacob Karlsson c8abcd0faf Fix broken start() 2024-05-14 19:53:20 +02:00
3 changed files with 12 additions and 2 deletions

View File

@ -91,7 +91,9 @@ function initNet(peer, config) {
async function start() { async function start() {
await stats.loaded() await stats.loaded()
glue(infos, connections) 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() { function stop() {

View File

@ -1,6 +1,6 @@
{ {
"name": "pzp-net", "name": "pzp-net",
"version": "1.0.0", "version": "1.0.1",
"description": "PZP plugin to manage connections with hubs and peers", "description": "PZP plugin to manage connections with hubs and peers",
"author": "Andre Staltz <contact@staltz.com>", "author": "Andre Staltz <contact@staltz.com>",
"license": "MIT", "license": "MIT",

View File

@ -62,6 +62,9 @@ test('Glueing together stats with connections', async (t) => {
while (FS.existsSync(statsJSONPath) === false) { while (FS.existsSync(statsJSONPath) === false) {
await p(setTimeout)(1) await p(setTimeout)(1)
} }
await p(setTimeout)(2000)
const fileContents = FS.readFileSync(statsJSONPath, 'utf8') const fileContents = FS.readFileSync(statsJSONPath, 'utf8')
const json = JSON.parse(fileContents) const json = JSON.parse(fileContents)
assert.deepEqual(Object.keys(json), [TEST_ADDR]) assert.deepEqual(Object.keys(json), [TEST_ADDR])
@ -101,12 +104,17 @@ test('Glueing together stats with connections', async (t) => {
while (FS.existsSync(statsJSONPath) === false) { while (FS.existsSync(statsJSONPath) === false) {
await p(setTimeout)(1) await p(setTimeout)(1)
} }
await p(setTimeout)(1000)
const fileContents = FS.readFileSync(statsJSONPath, 'utf8') const fileContents = FS.readFileSync(statsJSONPath, 'utf8')
assert.equal(fileContents.length > 10, true, 'stats.json is not empty') assert.equal(fileContents.length > 10, true, 'stats.json is not empty')
peer.net.forget(address) peer.net.forget(address)
await p(setTimeout)(200) await p(setTimeout)(200)
await p(setTimeout)(1000)
const entriesAfterForget = await p(peer.net.peers())(null) const entriesAfterForget = await p(peer.net.peers())(null)
assert.equal(entriesAfterForget.length, 0, 'there is no entry in peers()') assert.equal(entriesAfterForget.length, 0, 'there is no entry in peers()')