diff --git a/package.json b/package.json index 824f5a9ed5..65e59f9df1 100644 --- a/package.json +++ b/package.json @@ -73,4 +73,4 @@ "workspaces": [ "packages/*" ] -} +} \ No newline at end of file diff --git a/packages/interface-ipfs-core/src/add-all.js b/packages/interface-ipfs-core/src/add-all.js index b56c5d1445..0e5efd94ea 100644 --- a/packages/interface-ipfs-core/src/add-all.js +++ b/packages/interface-ipfs-core/src/add-all.js @@ -76,8 +76,7 @@ export function testAddAll (factory, options) { it('should add a File as array of tuples', async function () { if (!supportsFileReader) { - // @ts-expect-error this is mocha - return this.skip('skip in node') + return this.skip() } const tuple = { @@ -102,8 +101,7 @@ export function testAddAll (factory, options) { it('should add array of objects with readable stream content', async function () { if (!isNode) { - // @ts-expect-error this is mocha - this.skip('Only node supports readable streams') + this.skip() } const expectedCid = 'QmVv4Wz46JaZJeH5PMV4LGbRiiMKEmszPYY3g6fjGnVXBS' @@ -336,7 +334,6 @@ export function testAddAll (factory, options) { }) it('should add a directory with only-hash=true', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const content = String(Math.random() + Date.now()) @@ -358,21 +355,18 @@ export function testAddAll (factory, options) { }) it('should add with mode as string', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const mode = '0777' await testMode(mode, parseInt(mode, 8)) }) it('should add with mode as number', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const mode = parseInt('0777', 8) await testMode(mode, mode) }) it('should add with mtime as Date', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const mtime = new Date(5000) await testMtime(mtime, { @@ -382,7 +376,6 @@ export function testAddAll (factory, options) { }) it('should add with mtime as { nsecs, secs }', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const mtime = { secs: 5, @@ -392,7 +385,6 @@ export function testAddAll (factory, options) { }) it('should add with mtime as timespec', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) await testMtime({ Seconds: 5, @@ -404,7 +396,6 @@ export function testAddAll (factory, options) { }) it('should add with mtime as hrtime', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const mtime = process.hrtime() await testMtime(mtime, { @@ -414,7 +405,6 @@ export function testAddAll (factory, options) { }) it('should add a directory from the file system', async function () { - // @ts-expect-error this is mocha if (!isNode) this.skip() const filesPath = resolve('test/fixtures/test-folder', 'interface-ipfs-core') @@ -423,7 +413,6 @@ export function testAddAll (factory, options) { }) it('should add a directory from the file system with an odd name', async function () { - // @ts-expect-error this is mocha if (!isNode) this.skip() const filesPath = resolve('test/fixtures/weird name folder [v0]', 'interface-ipfs-core') @@ -433,7 +422,6 @@ export function testAddAll (factory, options) { }) it('should ignore a directory from the file system', async function () { - // @ts-expect-error this is mocha if (!isNode) this.skip() const filesPath = resolve('test/fixtures/test-folder', 'interface-ipfs-core') @@ -443,7 +431,6 @@ export function testAddAll (factory, options) { }) it('should add a file from the file system', async function () { - // @ts-expect-error this is mocha if (!isNode) this.skip() const filePath = resolve('test/fixtures/test-folder', 'interface-ipfs-core') @@ -454,7 +441,6 @@ export function testAddAll (factory, options) { }) it('should add a hidden file in a directory from the file system', async function () { - // @ts-expect-error this is mocha if (!isNode) this.skip() const filesPath = resolve('test/fixtures', 'interface-ipfs-core') @@ -465,10 +451,8 @@ export function testAddAll (factory, options) { }) it('should add a file with only-hash=true', async function () { - // @ts-expect-error this is mocha if (!isNode) this.skip() - // @ts-expect-error this is mocha this.slow(10 * 1000) const out = await all(ipfs.addAll([{ diff --git a/packages/interface-ipfs-core/src/add.js b/packages/interface-ipfs-core/src/add.js index 38cd90175b..1d0f05dec2 100644 --- a/packages/interface-ipfs-core/src/add.js +++ b/packages/interface-ipfs-core/src/add.js @@ -73,8 +73,7 @@ export function testAdd (factory, options) { it('should add a File', async function () { if (!supportsFileReader) { - // @ts-expect-error this is mocha - return this.skip('skip in node') + return this.skip() } const fileAdded = await ipfs.add(new File(['should add a File'], 'filename.txt', { type: 'text/plain' })) @@ -83,8 +82,7 @@ export function testAdd (factory, options) { it('should add a File as tuple', async function () { if (!supportsFileReader) { - // @ts-expect-error this is mocha - return this.skip('skip in node') + return this.skip() } const tuple = { @@ -212,7 +210,6 @@ export function testAdd (factory, options) { it('should add readable stream', async function () { if (!isNode) { - // @ts-expect-error this is mocha this.skip() } const expectedCid = 'QmVv4Wz46JaZJeH5PMV4LGbRiiMKEmszPYY3g6fjGnVXBS' @@ -264,7 +261,6 @@ export function testAdd (factory, options) { }) it('should add with only-hash=true', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const content = String(Math.random() + Date.now()) @@ -292,21 +288,18 @@ export function testAdd (factory, options) { }) it('should add with mode as string', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const mode = '0777' await testMode(mode, parseInt(mode, 8)) }) it('should add with mode as number', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const mode = parseInt('0777', 8) await testMode(mode, mode) }) it('should add with mtime as Date', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const mtime = new Date(5000) await testMtime(mtime, { @@ -316,7 +309,6 @@ export function testAdd (factory, options) { }) it('should add with mtime as { nsecs, secs }', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const mtime = { secs: 5, @@ -326,7 +318,6 @@ export function testAdd (factory, options) { }) it('should add with mtime as timespec', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) await testMtime({ Seconds: 5, @@ -338,7 +329,6 @@ export function testAdd (factory, options) { }) it('should add with mtime as hrtime', async function () { - // @ts-expect-error this is mocha this.slow(10 * 1000) const mtime = process.hrtime() await testMtime(mtime, { diff --git a/packages/interface-ipfs-core/src/dag/export.js b/packages/interface-ipfs-core/src/dag/export.js index abd9ddd2dc..8a1b4cc0ab 100644 --- a/packages/interface-ipfs-core/src/dag/export.js +++ b/packages/interface-ipfs-core/src/dag/export.js @@ -72,7 +72,6 @@ export function testExport (factory, options) { }) it('export of shuffled devnet export identical to canonical original', async function () { - // @ts-expect-error this is mocha this.timeout(360000) const input = loadFixture('test/fixtures/car/lotus_devnet_genesis.car', 'interface-ipfs-core') @@ -83,7 +82,6 @@ export function testExport (factory, options) { }) it('export of shuffled testnet export identical to canonical original', async function () { - // @ts-expect-error this is mocha this.timeout(360000) const input = loadFixture('test/fixtures/car/lotus_testnet_export_128.car', 'interface-ipfs-core') diff --git a/packages/interface-ipfs-core/src/files/touch.js b/packages/interface-ipfs-core/src/files/touch.js index 614a7bb17e..a4edfef830 100644 --- a/packages/interface-ipfs-core/src/files/touch.js +++ b/packages/interface-ipfs-core/src/files/touch.js @@ -53,7 +53,6 @@ export function testTouch (factory, options) { after(() => factory.clean()) it('should have default mtime', async function () { - // @ts-expect-error this is mocha this.slow(5 * 1000) const testPath = `/test-${nanoid()}` @@ -74,7 +73,6 @@ export function testTouch (factory, options) { }) it('should update file mtime', async function () { - // @ts-expect-error this is mocha this.slow(5 * 1000) const testPath = `/test-${nanoid()}` const mtime = new Date() @@ -92,7 +90,6 @@ export function testTouch (factory, options) { }) it('should update directory mtime', async function () { - // @ts-expect-error this is mocha this.slow(5 * 1000) const testPath = `/test-${nanoid()}` const mtime = new Date() diff --git a/packages/interface-ipfs-core/src/files/write.js b/packages/interface-ipfs-core/src/files/write.js index 4dedb4080b..4c4f148b75 100644 --- a/packages/interface-ipfs-core/src/files/write.js +++ b/packages/interface-ipfs-core/src/files/write.js @@ -188,7 +188,6 @@ export function testWrite (factory, options) { it('writes a small file using a Node stream (Node only)', async function () { if (!isNode) { - // @ts-expect-error this is mocha this.skip() } const filePath = `/small-file-${Math.random()}.txt` @@ -205,7 +204,6 @@ export function testWrite (factory, options) { it('writes a small file using an HTML5 Blob (Browser only)', async function () { if (!global.Blob || !global.FileReader) { - // @ts-expect-error this is mocha return this.skip() } diff --git a/packages/interface-ipfs-core/src/key/gen.js b/packages/interface-ipfs-core/src/key/gen.js index f09d9346d6..72511fe496 100644 --- a/packages/interface-ipfs-core/src/key/gen.js +++ b/packages/interface-ipfs-core/src/key/gen.js @@ -44,7 +44,6 @@ export function testGen (factory, options) { keyTypes.forEach((kt) => { it(`should generate a new ${kt.opts.type || 'default'} key`, async function () { - // @ts-expect-error this is mocha this.timeout(20 * 1000) const name = nanoid() const key = await ipfs.key.gen(name, kt.opts) @@ -61,8 +60,7 @@ export function testGen (factory, options) { } catch (/** @type {any} */ err) { if (err.code === 'ERR_NOT_IMPLEMENTED') { // key export is not exposed over the HTTP API - // @ts-expect-error this is mocha - this.skip('Cannot verify key type') + this.skip() } throw err diff --git a/packages/interface-ipfs-core/src/key/list.js b/packages/interface-ipfs-core/src/key/list.js index 15de84f4fe..9b85ac9742 100644 --- a/packages/interface-ipfs-core/src/key/list.js +++ b/packages/interface-ipfs-core/src/key/list.js @@ -27,7 +27,6 @@ export function testList (factory, options) { after(() => factory.clean()) it('should list all the keys', async function () { - // @ts-expect-error this is mocha this.timeout(60 * 1000) const keys = await Promise.all([1, 2, 3].map(() => ipfs.key.gen(nanoid(), { type: 'rsa', size: 2048 }))) diff --git a/packages/interface-ipfs-core/src/key/rename.js b/packages/interface-ipfs-core/src/key/rename.js index b8f4c1bc4a..6acfb6a35f 100644 --- a/packages/interface-ipfs-core/src/key/rename.js +++ b/packages/interface-ipfs-core/src/key/rename.js @@ -27,7 +27,6 @@ export function testRename (factory, options) { after(() => factory.clean()) it('should rename a key', async function () { - // @ts-expect-error this is mocha this.timeout(30 * 1000) const oldName = nanoid() diff --git a/packages/interface-ipfs-core/src/key/rm.js b/packages/interface-ipfs-core/src/key/rm.js index 5cde9bf106..f24771f1ec 100644 --- a/packages/interface-ipfs-core/src/key/rm.js +++ b/packages/interface-ipfs-core/src/key/rm.js @@ -27,7 +27,6 @@ export function testRm (factory, options) { after(() => factory.clean()) it('should rm a key', async function () { - // @ts-expect-error this is mocha this.timeout(30 * 1000) const key = await ipfs.key.gen(nanoid(), { type: 'rsa', size: 2048 }) diff --git a/packages/interface-ipfs-core/src/miscellaneous/dns.js b/packages/interface-ipfs-core/src/miscellaneous/dns.js index 3ca5b7d54f..8d7837d250 100644 --- a/packages/interface-ipfs-core/src/miscellaneous/dns.js +++ b/packages/interface-ipfs-core/src/miscellaneous/dns.js @@ -38,13 +38,11 @@ export function testDns (factory, options) { expect(res).to.match(/\/ipns\/.+$/) } catch (/** @type {any} */ err) { if (err.message.includes('could not resolve name')) { - // @ts-expect-error this is mocha return this.skip() } // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } @@ -62,13 +60,11 @@ export function testDns (factory, options) { expect(res).to.match(/\/ipfs\/.+$/) } catch (/** @type {any} */ err) { if (err.message.includes('could not resolve name')) { - // @ts-expect-error this is mocha return this.skip() } // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } @@ -86,13 +82,11 @@ export function testDns (factory, options) { expect(res).to.match(/\/ipfs\/.+$/) } catch (/** @type {any} */ err) { if (err.message.includes('could not resolve name')) { - // @ts-expect-error this is mocha return this.skip() } // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } diff --git a/packages/interface-ipfs-core/src/miscellaneous/id.js b/packages/interface-ipfs-core/src/miscellaneous/id.js index cd67e48ddf..59107c232c 100644 --- a/packages/interface-ipfs-core/src/miscellaneous/id.js +++ b/packages/interface-ipfs-core/src/miscellaneous/id.js @@ -59,7 +59,6 @@ export function testId (factory, options) { it('should return swarm ports opened after startup', async function () { if (isWebWorker) { // TODO: webworkers are not currently dialable - // @ts-expect-error this is mocha return this.skip() } @@ -69,7 +68,6 @@ export function testId (factory, options) { it('should get the id of another node in the swarm', async function () { if (isWebWorker) { // TODO: https://github.com/libp2p/js-libp2p-websockets/issues/129 - // @ts-expect-error this is mocha return this.skip() } diff --git a/packages/interface-ipfs-core/src/miscellaneous/resolve.js b/packages/interface-ipfs-core/src/miscellaneous/resolve.js index 49e004c4fa..3a2648e79a 100644 --- a/packages/interface-ipfs-core/src/miscellaneous/resolve.js +++ b/packages/interface-ipfs-core/src/miscellaneous/resolve.js @@ -94,7 +94,6 @@ export function testResolve (factory, options) { // Test resolve turns /ipns/domain.com into /ipfs/QmHash it('should resolve an IPNS DNS link', async function () { - // @ts-expect-error this is mocha this.retries(3) const domain = 'ipfs.io' @@ -105,7 +104,6 @@ export function testResolve (factory, options) { } catch (/** @type {any} */ err) { // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } @@ -114,7 +112,6 @@ export function testResolve (factory, options) { }) it('should resolve IPNS link recursively by default', async function () { - // @ts-expect-error this is mocha this.timeout(20 * 1000) // webworkers are not dialable because webrtc is not available const node = (await factory.spawn({ @@ -140,7 +137,6 @@ export function testResolve (factory, options) { }) it('should resolve IPNS link non-recursively if recursive==false', async function () { - // @ts-expect-error this is mocha this.timeout(20 * 1000) // webworkers are not dialable because webrtc is not available const node = (await factory.spawn({ diff --git a/packages/interface-ipfs-core/src/name-pubsub/cancel.js b/packages/interface-ipfs-core/src/name-pubsub/cancel.js index 39971ec5d8..a655840ad0 100644 --- a/packages/interface-ipfs-core/src/name-pubsub/cancel.js +++ b/packages/interface-ipfs-core/src/name-pubsub/cancel.js @@ -32,7 +32,6 @@ export function testCancel (factory, options) { after(() => factory.clean()) it('should return false when the name that is intended to cancel is not subscribed', async function () { - // @ts-expect-error this is mocha this.timeout(60 * 1000) const res = await ipfs.name.pubsub.cancel(nodeId) @@ -42,7 +41,6 @@ export function testCancel (factory, options) { }) it('should cancel a subscription correctly returning true', async function () { - // @ts-expect-error this is mocha this.timeout(300 * 1000) const peerId = await createEd25519PeerId() diff --git a/packages/interface-ipfs-core/src/name-pubsub/pubsub.js b/packages/interface-ipfs-core/src/name-pubsub/pubsub.js index 7849334951..688be1cf0b 100644 --- a/packages/interface-ipfs-core/src/name-pubsub/pubsub.js +++ b/packages/interface-ipfs-core/src/name-pubsub/pubsub.js @@ -82,7 +82,6 @@ export function testPubsub (factory, options) { after(() => factory.clean()) it('should publish and then resolve correctly', async function () { - // @ts-expect-error this is mocha this.timeout(80 * 1000) const routingKey = ipns.peerIdToRoutingKey(idA.id) @@ -98,7 +97,6 @@ export function testPubsub (factory, options) { }) it('should self resolve, publish and then resolve correctly', async function () { - // @ts-expect-error this is mocha this.timeout(6000) const emptyDirCid = '/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn' const { path } = await nodeA.add(uint8ArrayFromString('pubsub records')) @@ -120,7 +118,6 @@ export function testPubsub (factory, options) { }) it('should handle event on publish correctly', async function () { - // @ts-expect-error this is mocha this.timeout(80 * 1000) const testAccountName = 'test-account' diff --git a/packages/interface-ipfs-core/src/name-pubsub/state.js b/packages/interface-ipfs-core/src/name-pubsub/state.js index 17ab98f449..fd966f6da4 100644 --- a/packages/interface-ipfs-core/src/name-pubsub/state.js +++ b/packages/interface-ipfs-core/src/name-pubsub/state.js @@ -26,7 +26,6 @@ export function testState (factory, options) { after(() => factory.clean()) it('should get the current state of pubsub', async function () { - // @ts-expect-error this is mocha this.timeout(50 * 1000) const res = await ipfs.name.pubsub.state() diff --git a/packages/interface-ipfs-core/src/name-pubsub/subs.js b/packages/interface-ipfs-core/src/name-pubsub/subs.js index 3f2d264204..558f3a7b86 100644 --- a/packages/interface-ipfs-core/src/name-pubsub/subs.js +++ b/packages/interface-ipfs-core/src/name-pubsub/subs.js @@ -27,7 +27,6 @@ export function testSubs (factory, options) { after(() => factory.clean()) it('should get an empty array as a result of subscriptions before any resolve', async function () { - // @ts-expect-error this is mocha this.timeout(60 * 1000) const res = await ipfs.name.pubsub.subs() @@ -36,7 +35,6 @@ export function testSubs (factory, options) { }) it('should get the list of subscriptions updated after a resolve', async function () { - // @ts-expect-error this is mocha this.timeout(300 * 1000) const id = 'QmNP1ASen5ZREtiJTtVD3jhMKhoPb1zppET1tgpjHx2NGA' diff --git a/packages/interface-ipfs-core/src/name/publish.js b/packages/interface-ipfs-core/src/name/publish.js index e44b806387..0cc06a70bb 100644 --- a/packages/interface-ipfs-core/src/name/publish.js +++ b/packages/interface-ipfs-core/src/name/publish.js @@ -46,7 +46,6 @@ export function testPublish (factory, options) { after(() => factory.clean()) it('should publish an IPNS record with the default params', async function () { - // @ts-expect-error this is mocha this.timeout(50 * 1000) const value = fixture.cid @@ -71,7 +70,6 @@ export function testPublish (factory, options) { }) it('should publish correctly when the file was not added but resolve is disabled', async function () { - // @ts-expect-error this is mocha this.timeout(50 * 1000) const value = 'QmPFVLPmp9zv5Z5KUqLhe2EivAGccQW2r7M7jhVJGLZoZU' @@ -97,7 +95,6 @@ export function testPublish (factory, options) { }) it('should publish with a key received as param, instead of using the key of the node', async function () { - // @ts-expect-error this is mocha this.timeout(90 * 1000) const value = fixture.cid diff --git a/packages/interface-ipfs-core/src/name/resolve.js b/packages/interface-ipfs-core/src/name/resolve.js index 69deee2ff9..4b5aa290c0 100644 --- a/packages/interface-ipfs-core/src/name/resolve.js +++ b/packages/interface-ipfs-core/src/name/resolve.js @@ -44,7 +44,6 @@ export function testResolve (factory, options) { after(() => factory.clean()) it('should resolve a record default options', async function () { - // @ts-expect-error this is mocha this.timeout(20 * 1000) const { path } = await ipfs.add(uint8ArrayFromString('should resolve a record default options')) @@ -58,7 +57,6 @@ export function testResolve (factory, options) { }) it('should resolve a record from peerid as cidv1 in base32', async function () { - // @ts-expect-error this is mocha this.timeout(20 * 1000) const { cid } = await ipfs.add(uint8ArrayFromString('should resolve a record from cidv1b32')) const { id: peerId } = await ipfs.id() @@ -80,7 +78,6 @@ export function testResolve (factory, options) { }) it('should resolve a record recursive === true', async function () { - // @ts-expect-error this is mocha this.timeout(20 * 1000) const { path } = await ipfs.add(uint8ArrayFromString('should resolve a record recursive === true')) @@ -94,7 +91,6 @@ export function testResolve (factory, options) { }) it('should resolve a record default options with remainder', async function () { - // @ts-expect-error this is mocha this.timeout(20 * 1000) const { path } = await ipfs.add(uint8ArrayFromString('should resolve a record default options with remainder')) @@ -115,7 +111,6 @@ export function testResolve (factory, options) { }) it('should resolve a record recursive === true with remainder', async function () { - // @ts-expect-error this is mocha this.timeout(20 * 1000) const { path } = await ipfs.add(uint8ArrayFromString('should resolve a record recursive = true with remainder')) @@ -169,7 +164,6 @@ export function testResolve (factory, options) { } catch (/** @type {any} */ err) { // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } @@ -186,7 +180,6 @@ export function testResolve (factory, options) { } catch (/** @type {any} */ err) { // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } @@ -203,7 +196,6 @@ export function testResolve (factory, options) { } catch (/** @type {any} */ err) { // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } @@ -220,7 +212,6 @@ export function testResolve (factory, options) { } catch (/** @type {any} */ err) { // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } @@ -237,7 +228,6 @@ export function testResolve (factory, options) { } catch (/** @type {any} */ err) { // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } @@ -254,7 +244,6 @@ export function testResolve (factory, options) { } catch (/** @type {any} */ err) { // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } @@ -279,7 +268,6 @@ export function testResolve (factory, options) { } catch (/** @type {any} */ err) { // happens when running tests offline if (err.message.includes(`ECONNREFUSED ${domain}`)) { - // @ts-expect-error this is mocha return this.skip() } diff --git a/packages/interface-ipfs-core/src/pin/add.js b/packages/interface-ipfs-core/src/pin/add.js index 3823cbac0d..62ab0c4a85 100644 --- a/packages/interface-ipfs-core/src/pin/add.js +++ b/packages/interface-ipfs-core/src/pin/add.js @@ -102,9 +102,7 @@ export function testAdd (factory, options) { }) it('should fail to pin a hash not in datastore', async function () { - // @ts-expect-error this is mocha this.slow(3 * 1000) - // @ts-expect-error this is mocha this.timeout(5 * 1000) const falseHash = `${`${fixtures.directory.cid}`.slice(0, -2)}ss` @@ -113,9 +111,7 @@ export function testAdd (factory, options) { }) it('needs all children in datastore to pin recursively', async function () { - // @ts-expect-error this is mocha this.slow(3 * 1000) - // @ts-expect-error this is mocha this.timeout(5 * 1000) await all(ipfs.block.rm(fixtures.directory.files[0].cid)) diff --git a/packages/interface-ipfs-core/src/pubsub/subscribe.js b/packages/interface-ipfs-core/src/pubsub/subscribe.js index bad06e4015..87ecd48f7b 100644 --- a/packages/interface-ipfs-core/src/pubsub/subscribe.js +++ b/packages/interface-ipfs-core/src/pubsub/subscribe.js @@ -194,7 +194,6 @@ export function testSubscribe (factory, options) { it('should receive messages from a different node with floodsub', async function () { if (!isNode) { - // @ts-expect-error this is mocha return this.skip() } diff --git a/packages/interface-ipfs-core/src/refs.js b/packages/interface-ipfs-core/src/refs.js index 8bea1e73e3..739447410a 100644 --- a/packages/interface-ipfs-core/src/refs.js +++ b/packages/interface-ipfs-core/src/refs.js @@ -50,7 +50,6 @@ export function testRefs (factory, options) { const { path, params, expected, expectError, expectTimeout } = options // eslint-disable-next-line no-loop-func it(name, async function () { - // @ts-expect-error this is mocha this.timeout(20 * 1000) // Call out to IPFS @@ -81,7 +80,6 @@ export function testRefs (factory, options) { }) it('should get refs with cbor links', async function () { - // @ts-expect-error this is mocha this.timeout(20 * 1000) // Call out to IPFS diff --git a/packages/interface-ipfs-core/src/utils/mocha.js b/packages/interface-ipfs-core/src/utils/mocha.js index bd5e93941e..cf90f1f74e 100644 --- a/packages/interface-ipfs-core/src/utils/mocha.js +++ b/packages/interface-ipfs-core/src/utils/mocha.js @@ -93,15 +93,20 @@ export function getDescribe (config) { * @param {object} [config] * @param {boolean | Skip | (string | Skip)[]} [config.skip] * @param {boolean} [config.only] + * @returns {Mocha.TestFunction} */ export function getIt (config) { if (!config) return it /** - * @param {string} name - * @param {*} impl + * @param {string | Mocha.Func} name + * @param {Mocha.Func | Mocha.AsyncFunc} [impl] */ const _it = (name, impl) => { + if (typeof name !== 'string') { + throw new Error('Pass test name as first argument to it') + } + if (Array.isArray(config.skip)) { const skip = config.skip .map((s) => isSkip(s) ? s : { name: s, reason: '🤷' }) @@ -124,9 +129,10 @@ export function getIt (config) { } } - it(name, impl) + return it(name, impl) } + _it.retries = it.retries _it.skip = it.skip _it.only = it.only // eslint-disable-line no-only-tests/no-only-tests diff --git a/packages/ipfs-core-utils/src/pins/normalise-input.js b/packages/ipfs-core-utils/src/pins/normalise-input.js index feef80f43c..3675f53ca6 100644 --- a/packages/ipfs-core-utils/src/pins/normalise-input.js +++ b/packages/ipfs-core-utils/src/pins/normalise-input.js @@ -17,6 +17,30 @@ import { CID } from 'multiformats/cid' * @property {any} [metadata] */ +/** + * @param {any} thing + * @returns {thing is IterableIterator & Iterator} + */ +function isIterable (thing) { + return Symbol.iterator in thing +} + +/** + * @param {any} thing + * @returns {thing is AsyncIterableIterator & AsyncIterator} + */ +function isAsyncIterable (thing) { + return Symbol.asyncIterator in thing +} + +/** + * @param {any} thing + * @returns {thing is CID} + */ +function isCID (thing) { + return CID.asCID(thing) != null +} + /** * Transform one of: * @@ -71,14 +95,16 @@ export async function * normaliseInput (input) { } // Iterable - if (Symbol.iterator in input) { - // @ts-expect-error + if (isIterable(input)) { const iterator = input[Symbol.iterator]() const first = iterator.next() - if (first.done) return iterator - // Iterable - if (CID.asCID(first.value) || first.value instanceof String || typeof first.value === 'string') { + if (first.done) { + return iterator + } + + // Iterable + if (isCID(first.value)) { yield toPin({ cid: first.value }) for (const cid of iterator) { yield toPin({ cid }) @@ -86,7 +112,16 @@ export async function * normaliseInput (input) { return } - // Iterable<{ cid: CID recursive, metadata }> + // Iterable + if (first.value instanceof String || typeof first.value === 'string') { + yield toPin({ path: first.value }) + for (const path of iterator) { + yield toPin({ path }) + } + return + } + + // Iterable if (first.value.cid != null || first.value.path != null) { yield toPin(first.value) for (const obj of iterator) { @@ -99,14 +134,13 @@ export async function * normaliseInput (input) { } // AsyncIterable - if (Symbol.asyncIterator in input) { - // @ts-expect-error + if (isAsyncIterable(input)) { const iterator = input[Symbol.asyncIterator]() const first = await iterator.next() if (first.done) return iterator - // AsyncIterable - if (CID.asCID(first.value) || first.value instanceof String || typeof first.value === 'string') { + // AsyncIterable + if (isCID(first.value)) { yield toPin({ cid: first.value }) for await (const cid of iterator) { yield toPin({ cid }) @@ -114,6 +148,15 @@ export async function * normaliseInput (input) { return } + // AsyncIterable + if (first.value instanceof String || typeof first.value === 'string') { + yield toPin({ path: first.value }) + for await (const path of iterator) { + yield toPin({ path }) + } + return + } + // AsyncIterable<{ cid: CID|String recursive, metadata }> if (first.value.cid != null || first.value.path != null) { yield toPin(first.value) diff --git a/packages/ipfs-http-client/src/key/gen.js b/packages/ipfs-http-client/src/key/gen.js index 50a5e634fc..766a2d26b6 100644 --- a/packages/ipfs-http-client/src/key/gen.js +++ b/packages/ipfs-http-client/src/key/gen.js @@ -11,14 +11,16 @@ export const createGen = configure(api => { /** * @type {KeyAPI["gen"]} */ - async function gen (name, options = { type: 'Ed25519' }) { + async function gen (name, options) { + const opts = options ?? { type: 'Ed25519' } + const res = await api.post('key/gen', { - signal: options.signal, + signal: opts.signal, searchParams: toUrlSearchParams({ arg: name, - ...options + ...opts }), - headers: options.headers + headers: opts.headers }) const data = await res.json() diff --git a/packages/ipfs-message-port-protocol/src/cid.js b/packages/ipfs-message-port-protocol/src/cid.js index 99d64468dc..a4522896ba 100644 --- a/packages/ipfs-message-port-protocol/src/cid.js +++ b/packages/ipfs-message-port-protocol/src/cid.js @@ -36,15 +36,14 @@ export const decodeCID = encodedCID => { // @ts-expect-error we are converting this into an object compatible with the CID class const cid = (encodedCID) - // @ts-expect-error non-enumerable field that doesn't always get transferred - if (!cid._baseCache) { - Object.defineProperty(cid, '_baseCache', { - value: new Map() + if (!cid.asCID) { + Object.defineProperty(cid, 'asCID', { + get: () => cid }) } - if (!cid.asCID) { - Object.defineProperty(cid, 'asCID', { + if (!cid['/']) { + Object.defineProperty(cid, '/', { get: () => cid }) } @@ -53,10 +52,6 @@ export const decodeCID = encodedCID => { Object.setPrototypeOf(cid.multihash.bytes, Uint8Array.prototype) Object.setPrototypeOf(cid.bytes, Uint8Array.prototype) Object.setPrototypeOf(cid, CID.prototype) - // TODO: Figure out a way to avoid `Symbol.for` here as it can get out of - // sync with cids implementation. - // See: https://github.com/moxystudio/js-class-is/issues/25 - Object.defineProperty(cid, Symbol.for('@ipld/js-cid/CID'), { value: true }) return cid } diff --git a/packages/ipfs/package.json b/packages/ipfs/package.json index d80160a62a..12b812e452 100644 --- a/packages/ipfs/package.json +++ b/packages/ipfs/package.json @@ -89,7 +89,6 @@ "@types/update-notifier": "^6.0.1", "aegir": "^37.0.11", "cross-env": "^7.0.0", - "electron-webrtc": "^0.3.0", "go-ipfs": "^0.12.0", "interface-ipfs-core": "^0.157.0", "ipfs-client": "^0.9.2", @@ -102,7 +101,10 @@ "kubo-rpc-client": "^1.0.1", "merge-options": "^3.0.4", "mock-ipfs-pinning-service": "^0.4.2", - "url": "^0.11.0", + "url": "^0.11.0" + }, + "optionalDependencies": { + "electron-webrtc": "^0.3.0", "wrtc": "^0.4.6" }, "browser": {