diff --git a/iroh-js/__test__/blob.spec.mjs b/iroh-js/__test__/blob.spec.mjs index aa9ec552..69067dc8 100644 --- a/iroh-js/__test__/blob.spec.mjs +++ b/iroh-js/__test__/blob.spec.mjs @@ -38,7 +38,7 @@ test('add blob from path', async (t) => { t.truthy(allDone.tag) t.truthy(allDone.hash) - await node.node.shutdown(false) + await node.node.shutdown() }) test('hash basics', (t) => { @@ -104,7 +104,7 @@ test('collections', async (t) => { t.is(collectionList[0].hash, res.hash) t.is(collectionList[0].totalBlobsCount, BigInt(numFiles + 1)) - await node.node.shutdown(false) + await node.node.shutdown() }) test('share', async (t) => { @@ -119,7 +119,7 @@ test('share', async (t) => { t.is(ticket.hash, res.hash) t.deepEqual(ticket.nodeAddr, nodeAddr) - await node.node.shutdown(false) + await node.node.shutdown() }) test('provide events', async (t) => { @@ -174,6 +174,6 @@ test('provide events', async (t) => { t.is(events.length, 4) - await node1.node.shutdown(false) - await node2.node.shutdown(false) + await node1.node.shutdown() + await node2.node.shutdown() }) diff --git a/iroh-js/__test__/node.spec.mjs b/iroh-js/__test__/node.spec.mjs index a070217a..fa2f6baa 100644 --- a/iroh-js/__test__/node.spec.mjs +++ b/iroh-js/__test__/node.spec.mjs @@ -2,9 +2,9 @@ import test from 'ava' import { Iroh } from '../index.js' - test('create memory node', async (t) => { const node = await Iroh.memory() + await node.node.shutdown() t.pass() }) @@ -12,6 +12,7 @@ test('create memory node, with options', async (t) => { const node = await Iroh.memory({ gcIntervalMillis: 10000 }) + await node.node.shutdown() t.pass() }) @@ -20,6 +21,7 @@ test('node status', async (t) => { const status = await iroh.node.status() t.is(status.version, '0.28.1') + await iroh.node.shutdown() }) test('rpc client memory node', async (t) => { @@ -33,6 +35,8 @@ test('rpc client memory node', async (t) => { const clientId = await client.net.nodeId() t.is(nodeId, clientId) + + await node.node.shutdown() }) @@ -43,33 +47,31 @@ test('custom protocol', async (t) => { const protocols = { [alpn]: (err, ep, client) => ({ accept: async (err, connecting) => { - console.log('accept') + // console.log('accept') t.falsy(err) const nodeId = await client.net.nodeId() - console.log(`accepting on node ${nodeId}`) + // console.log(`accepting on node ${nodeId}`) const alpn = await connecting.alpn() - console.log(`incoming on ${alpn.toString()}`) + // console.log(`incoming on ${alpn.toString()}`) const conn = await connecting.connect() const remote = await conn.getRemoteNodeId() - console.log(`connected id ${remote.toString()}`) + // console.log(`connected id ${remote.toString()}`) const bi = await conn.acceptBi() const bytes = await bi.recv.readToEnd(64) - console.log(`got: ${bytes.toString()}`) + // console.log(`got: ${bytes.toString()}`) t.is(bytes.toString(), 'yo') await bi.send.writeAll(Buffer.from('hello')) await bi.send.finish() await conn.closed() }, shutdown: (err) => { - if (err != null) { - if (!err.message.contains("closed by peer")) { - throw err - } + if (err != null && !err.message.contains('closed by peer')) { + throw err } - console.log('shutting down') + // console.log('shutting down') } }) } @@ -82,11 +84,11 @@ test('custom protocol', async (t) => { const node2 = await Iroh.memory({ protocols }) const endpoint = node2.node.endpoint() - console.log(`connecting to ${nodeAddr.nodeId}`) + // console.log(`connecting to ${nodeAddr.nodeId}`) const conn = await endpoint.connect(nodeAddr, alpn) const remote = await conn.getRemoteNodeId() - console.log(`connected to ${remote.toString()}`) + // console.log(`connected to ${remote.toString()}`) const bi = await conn.openBi() @@ -96,12 +98,13 @@ test('custom protocol', async (t) => { let out = Buffer.alloc(5) await bi.recv.readExact(out) - console.log(`read: ${out.toString()}`) + // console.log(`read: ${out.toString()}`) t.is(out.toString(), 'hello') await node2.node.shutdown() await node1.node.shutdown() - console.log('end') + // console.log('end') + t.pass() }) diff --git a/iroh-js/index.d.ts b/iroh-js/index.d.ts index 5d60dcdb..fc569060 100644 --- a/iroh-js/index.d.ts +++ b/iroh-js/index.d.ts @@ -431,7 +431,7 @@ export declare class Node { /** Get status information about a node */ status(): Promise /** Shutdown this iroh node. */ - shutdown(force: boolean): Promise + shutdown(): Promise /** Returns `Some(addr)` if an RPC endpoint is running, `None` otherwise. */ myRpcAddr(): string | null endpoint(): Endpoint | null