Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 1f432f7

Browse files
committed
chore: fix tests
1 parent 7f3edc4 commit 1f432f7

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

packages/interface-ipfs-core/src/dht/provide.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const CID = require('cids')
66
const all = require('it-all')
77
const { getDescribe, getIt, expect } = require('../utils/mocha')
88
const testTimeout = require('../utils/test-timeout')
9+
const last = require('it-last')
910

1011
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
1112
/**
@@ -29,8 +30,10 @@ module.exports = (common, options) => {
2930

3031
after(() => common.clean())
3132

32-
it('should respect timeout option when providing a value on the DHT', () => {
33-
return testTimeout(() => ipfs.dht.provide(new CID('Qmd7qZS4T7xXtsNFdRoK1trfMs5zU94EpokQ9WFtxdPxsZ'), {
33+
it('should respect timeout option when providing a value on the DHT', async () => {
34+
const res = await last(ipfs.add(Buffer.from('test')))
35+
36+
await testTimeout(() => ipfs.dht.provide(res.cid, {
3437
timeout: 1
3538
}))
3639
})

packages/ipfs/test/http-api/inject/files.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ describe('/files', () => {
245245
it('should cat a valid hash', async function () {
246246
const data = Buffer.from('TEST' + Date.now())
247247

248-
ipfs.cat.withArgs(`/ipfs/${cid}`, defaultOptions).returns([
248+
ipfs.cat.withArgs(`${cid}`, defaultOptions).returns([
249249
data
250250
])
251251

@@ -262,7 +262,7 @@ describe('/files', () => {
262262
it('should cat a valid hash with an offset', async function () {
263263
const data = Buffer.from('TEST' + Date.now())
264264

265-
ipfs.cat.withArgs(`/ipfs/${cid}`, {
265+
ipfs.cat.withArgs(`${cid}`, {
266266
...defaultOptions,
267267
offset: 10
268268
}).returns([
@@ -282,7 +282,7 @@ describe('/files', () => {
282282
it('should cat a valid hash with a length', async function () {
283283
const data = Buffer.from('TEST' + Date.now())
284284

285-
ipfs.cat.withArgs(`/ipfs/${cid}`, {
285+
ipfs.cat.withArgs(`${cid}`, {
286286
...defaultOptions,
287287
length: 10
288288
}).returns([
@@ -314,7 +314,7 @@ describe('/files', () => {
314314
})
315315

316316
it('accepts a timeout', async () => {
317-
ipfs.get.withArgs(`/ipfs/${cid}`, {
317+
ipfs.get.withArgs(`${cid}`, {
318318
...defaultOptions,
319319
timeout: 1000
320320
}).returns([{
@@ -342,7 +342,7 @@ describe('/files', () => {
342342
})
343343

344344
it('should list directory contents', async () => {
345-
ipfs.ls.withArgs(`/ipfs/${cid}`, defaultOptions).returns([{
345+
ipfs.ls.withArgs(`${cid}`, defaultOptions).returns([{
346346
name: 'link',
347347
cid,
348348
size: 10,
@@ -358,7 +358,7 @@ describe('/files', () => {
358358

359359
expect(res).to.have.property('statusCode', 200)
360360
expect(res).to.have.deep.nested.property('result.Objects[0]', {
361-
Hash: `/ipfs/${cid}`,
361+
Hash: `${cid}`,
362362
Links: [{
363363
Depth: 1,
364364
Hash: cid.toString(),
@@ -371,7 +371,7 @@ describe('/files', () => {
371371
})
372372

373373
it('should list directory contents recursively', async () => {
374-
ipfs.ls.withArgs(`/ipfs/${cid}`, {
374+
ipfs.ls.withArgs(`${cid}`, {
375375
...defaultOptions,
376376
recursive: true
377377
}).returns([{
@@ -390,7 +390,7 @@ describe('/files', () => {
390390

391391
expect(res).to.have.property('statusCode', 200)
392392
expect(res).to.have.deep.nested.property('result.Objects[0]', {
393-
Hash: `/ipfs/${cid}`,
393+
Hash: `${cid}`,
394394
Links: [{
395395
Depth: 1,
396396
Hash: cid.toString(),
@@ -404,7 +404,7 @@ describe('/files', () => {
404404

405405
// TODO: unskip after switch to v1 CIDs by default
406406
it.skip('should return base64 encoded CIDs', async () => {
407-
ipfs.ls.withArgs(`/ipfs/${cid}`, defaultOptions).returns([])
407+
ipfs.ls.withArgs(`${cid}`, defaultOptions).returns([])
408408

409409
const res = await http({
410410
method: 'POST',
@@ -419,7 +419,7 @@ describe('/files', () => {
419419
})
420420

421421
it('accepts a timeout', async () => {
422-
ipfs.ls.withArgs(`/ipfs/${cid}`, {
422+
ipfs.ls.withArgs(`${cid}`, {
423423
...defaultOptions,
424424
timeout: 1000
425425
}).returns([{
@@ -440,7 +440,7 @@ describe('/files', () => {
440440
})
441441

442442
it('accepts a timeout when streaming', async () => {
443-
ipfs.ls.withArgs(`/ipfs/${cid}`, {
443+
ipfs.ls.withArgs(`${cid}`, {
444444
...defaultOptions,
445445
timeout: 1000
446446
}).returns([{
@@ -477,7 +477,7 @@ describe('/files', () => {
477477
})
478478

479479
it('should list refs', async () => {
480-
ipfs.refs.withArgs([`/ipfs/${cid}`], {
480+
ipfs.refs.withArgs([`${cid}`], {
481481
...defaultOptions,
482482
format: '<linkname>'
483483
}).returns([{
@@ -494,7 +494,7 @@ describe('/files', () => {
494494
})
495495

496496
it('should list refs for multiple IPFS paths', async () => {
497-
ipfs.refs.withArgs([`/ipfs/${cid}`, `/ipfs/${cid2}`], defaultOptions).returns([{
497+
ipfs.refs.withArgs([`${cid}`, `/ipfs/${cid2}`], defaultOptions).returns([{
498498
ref: cid.toString()
499499
}])
500500

@@ -508,7 +508,7 @@ describe('/files', () => {
508508
})
509509

510510
it('accepts a timeout', async () => {
511-
ipfs.refs.withArgs([`/ipfs/${cid}`], {
511+
ipfs.refs.withArgs([`${cid}`], {
512512
...defaultOptions,
513513
timeout: 1000
514514
}).returns([{

packages/ipfs/test/http-api/inject/pin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ describe('/pin', () => {
273273
})
274274

275275
it('finds specific pinned objects', async () => {
276-
ipfs.pin.ls.withArgs([`/ipfs/${cid}`], defaultOptions).returns([{
276+
ipfs.pin.ls.withArgs([`${cid}`], defaultOptions).returns([{
277277
cid,
278278
type: 'recursive'
279279
}])

0 commit comments

Comments
 (0)