Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit f5287d8

Browse files
committed
chore: update to the latest ctl api
1 parent c165e07 commit f5287d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+499
-893
lines changed

src/bitswap/stat.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
const { getDescribe, getIt, expect } = require('../utils/mocha')
55
const { expectIsBitswap } = require('../stats/utils')
66

7-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
7+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
88
/**
9-
* @param {TestsInterface} common
9+
* @param {Factory} common
1010
* @param {Object} options
1111
*/
1212
module.exports = (common, options) => {
@@ -18,18 +18,18 @@ module.exports = (common, options) => {
1818
let ipfs
1919

2020
before(async () => {
21-
ipfs = await common.setup()
21+
ipfs = (await common.spawn()).api
2222
})
2323

24-
after(() => common.teardown())
24+
after(() => common.clean())
2525

2626
it('should get bitswap stats', async () => {
2727
const res = await ipfs.bitswap.stat()
2828
expectIsBitswap(null, res)
2929
})
3030

31-
it('should not get bitswap stats when offline', async function () {
32-
const node = await common.node()
31+
it('should not get bitswap stats when offline', async () => {
32+
const node = await common.spawn()
3333
await node.stop()
3434

3535
return expect(node.api.bitswap.stat()).to.eventually.be.rejected()

src/bitswap/wantlist.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
const { getDescribe, getIt, expect } = require('../utils/mocha')
55
const { waitForWantlistKey } = require('./utils')
66

7-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
7+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
88
/**
9-
* @param {TestsInterface} common
9+
* @param {Factory} common
1010
* @param {Object} options
1111
*/
1212
module.exports = (common, options) => {
@@ -19,22 +19,14 @@ module.exports = (common, options) => {
1919
let ipfsB
2020
const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR'
2121

22-
before(async function () {
23-
// CI takes longer to instantiate the daemon, so we need to increase the
24-
// timeout for the before step
25-
this.timeout(60 * 1000)
26-
27-
ipfsA = await common.setup()
28-
ipfsB = await common.setup({ type: 'go' })
22+
before(async () => {
23+
ipfsA = (await common.spawn()).api
24+
ipfsB = (await common.spawn({ type: 'go' })).api
2925
// Add key to the wantlist for ipfsB
3026
ipfsB.block.get(key).catch(() => {})
3127
})
3228

33-
after(function () {
34-
this.timeout(30 * 1000)
35-
36-
return common.teardown()
37-
})
29+
after(() => common.clean())
3830

3931
it('should get the wantlist', function () {
4032
return waitForWantlistKey(ipfsB, key)
@@ -48,7 +40,7 @@ module.exports = (common, options) => {
4840
})
4941

5042
it('should not get the wantlist when offline', async () => {
51-
const node = await common.node()
43+
const node = await common.spawn()
5244
await node.stop()
5345

5446
return expect(node.api.bitswap.stat()).to.eventually.be.rejected()

src/block/get.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const multihash = require('multihashes')
55
const CID = require('cids')
66
const { getDescribe, getIt, expect } = require('../utils/mocha')
77

8-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
8+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
99
/**
10-
* @param {TestsInterface} common
10+
* @param {Factory} common
1111
* @param {Object} options
1212
*/
1313
module.exports = (common, options) => {
@@ -18,17 +18,13 @@ module.exports = (common, options) => {
1818
const data = Buffer.from('blorb')
1919
let ipfs, hash
2020

21-
before(async function () {
22-
// CI takes longer to instantiate the daemon, so we need to increase the
23-
// timeout for the before step
24-
this.timeout(60 * 1000)
25-
26-
ipfs = await common.setup()
21+
before(async () => {
22+
ipfs = (await common.spawn()).api
2723
const block = await ipfs.block.put(data)
2824
hash = block.cid.multihash
2925
})
3026

31-
after(() => common.teardown())
27+
after(() => common.clean())
3228

3329
it('should get by CID object', async () => {
3430
const cid = new CID(hash)

src/block/put.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const multihash = require('multihashes')
66
const CID = require('cids')
77
const { getDescribe, getIt, expect } = require('../utils/mocha')
88

9-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
9+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
1010
/**
11-
* @param {TestsInterface} common
11+
* @param {Factory} common
1212
* @param {Object} options
1313
*/
1414
module.exports = (common, options) => {
@@ -18,15 +18,11 @@ module.exports = (common, options) => {
1818
describe('.block.put', () => {
1919
let ipfs
2020

21-
before(async function () {
22-
// CI takes longer to instantiate the daemon, so we need to increase the
23-
// timeout for the before step
24-
this.timeout(60 * 1000)
25-
26-
ipfs = await common.setup()
21+
before(async () => {
22+
ipfs = (await common.spawn()).api
2723
})
2824

29-
after(() => common.teardown())
25+
after(() => common.clean())
3026

3127
it('should put a buffer, using defaults', async () => {
3228
const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'

src/block/rm.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
const { getDescribe, getIt, expect } = require('../utils/mocha')
55
const hat = require('hat')
66

7-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
7+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
88
/**
9-
* @param {TestsInterface} common
9+
* @param {Factory} common
1010
* @param {Object} options
1111
*/
1212
module.exports = (common, options) => {
@@ -16,9 +16,9 @@ module.exports = (common, options) => {
1616
describe('.block.rm', () => {
1717
let ipfs
1818

19-
before(async () => { ipfs = await common.setup() })
19+
before(async () => { ipfs = (await common.spawn()).api })
2020

21-
after(() => common.teardown())
21+
after(() => common.clean())
2222

2323
it('should remove by CID object', async () => {
2424
const cid = await ipfs.dag.put(Buffer.from(hat()), {

src/block/stat.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
const CID = require('cids')
55
const { getDescribe, getIt, expect } = require('../utils/mocha')
66

7-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
7+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
88
/**
9-
* @param {TestsInterface} common
9+
* @param {Factory} common
1010
* @param {Object} options
1111
*/
1212
module.exports = (common, options) => {
@@ -17,17 +17,13 @@ module.exports = (common, options) => {
1717
const data = Buffer.from('blorb')
1818
let ipfs, hash
1919

20-
before(async function () {
21-
// CI takes longer to instantiate the daemon, so we need to increase the
22-
// timeout for the before step
23-
this.timeout(60 * 1000)
24-
25-
ipfs = await common.setup()
20+
before(async () => {
21+
ipfs = (await common.spawn()).api
2622
const block = await ipfs.block.put(data)
2723
hash = block.cid.multihash
2824
})
2925

30-
after(() => common.teardown())
26+
after(() => common.clean())
3127

3228
it('should stat by CID', async () => {
3329
const cid = new CID(hash)

src/bootstrap/add.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const { getDescribe, getIt, expect } = require('../utils/mocha')
66
const invalidArg = 'this/Is/So/Invalid/'
77
const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z'
88

9-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
9+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
1010
/**
11-
* @param {TestsInterface} common
11+
* @param {Factory} common
1212
* @param {Object} options
1313
*/
1414
module.exports = (common, options) => {
@@ -20,15 +20,11 @@ module.exports = (common, options) => {
2020

2121
let ipfs
2222

23-
before(async function () {
24-
// CI takes longer to instantiate the daemon, so we need to increase the
25-
// timeout for the before step
26-
this.timeout(60 * 1000)
27-
28-
ipfs = await common.setup()
23+
before(async () => {
24+
ipfs = (await common.spawn()).api
2925
})
3026

31-
after(() => common.teardown())
27+
after(() => common.clean())
3228

3329
it('should return an error when called with an invalid arg', () => {
3430
return expect(ipfs.bootstrap.add(invalidArg)).to.eventually.be.rejected

src/bootstrap/list.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
const { getDescribe, getIt, expect } = require('../utils/mocha')
55

6-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
6+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
77
/**
8-
* @param {TestsInterface} common
8+
* @param {Factory} common
99
* @param {Object} options
1010
*/
1111
module.exports = (common, options) => {
@@ -17,9 +17,9 @@ module.exports = (common, options) => {
1717

1818
let ipfs
1919

20-
before(async () => { ipfs = await common.setup() })
20+
before(async () => { ipfs = (await common.spawn()).api })
2121

22-
after(() => common.teardown())
22+
after(() => common.clean())
2323

2424
it('should return a list of peers', async () => {
2525
const res = await ipfs.bootstrap.list()

src/bootstrap/rm.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
const { getDescribe, getIt, expect } = require('../utils/mocha')
55

6-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
6+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
77
/**
8-
* @param {TestsInterface} common
8+
* @param {Factory} common
99
* @param {Object} options
1010
*/
1111
module.exports = (common, options) => {
@@ -20,9 +20,9 @@ module.exports = (common, options) => {
2020

2121
let ipfs
2222

23-
before(async () => { ipfs = await common.setup() })
23+
before(async () => { ipfs = (await common.spawn()).api })
2424

25-
after(() => common.teardown())
25+
after(() => common.clean())
2626

2727
it('should return an error when called with an invalid arg', () => {
2828
return expect(ipfs.bootstrap.rm(invalidArg)).to.eventually.be.rejected

src/config/get.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
const { getDescribe, getIt, expect } = require('../utils/mocha')
55
const isPlainObject = require('is-plain-object')
66

7-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
7+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
88
/**
9-
* @param {TestsInterface} common
9+
* @param {Factory} common
1010
* @param {Object} options
1111
*/
1212
module.exports = (common, options) => {
@@ -17,9 +17,9 @@ module.exports = (common, options) => {
1717
this.timeout(30 * 1000)
1818
let ipfs
1919

20-
before(async () => { ipfs = await common.setup() })
20+
before(async () => { ipfs = (await common.spawn()).api })
2121

22-
after(() => common.teardown())
22+
after(() => common.clean())
2323

2424
it('should retrieve the whole config', async () => {
2525
const config = await ipfs.config.get()

src/config/profiles/apply.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
'use strict'
33

44
const { getDescribe, getIt, expect } = require('../../utils/mocha')
5-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
5+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
66
/**
7-
* @param {TestsInterface} common
7+
* @param {Factory} common
88
* @param {Object} options
99
*/
1010
module.exports = (common, options) => {
@@ -15,15 +15,11 @@ module.exports = (common, options) => {
1515
this.timeout(30 * 1000)
1616
let ipfs
1717

18-
before(async function () {
19-
// CI takes longer to instantiate the daemon, so we need to increase the
20-
// timeout for the before step
21-
this.timeout(60 * 1000)
22-
23-
ipfs = await common.setup()
18+
before(async () => {
19+
ipfs = (await common.spawn()).api
2420
})
2521

26-
after(() => common.teardown())
22+
after(() => common.clean())
2723

2824
it('should apply a config profile', async () => {
2925
const diff = await ipfs.config.profiles.apply('lowpower')

src/config/profiles/list.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
'use strict'
33

44
const { getDescribe, getIt, expect } = require('../../utils/mocha')
5-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
5+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
66
/**
7-
* @param {TestsInterface} common
7+
* @param {Factory} common
88
* @param {Object} options
99
*/
1010
module.exports = (common, options) => {
@@ -15,15 +15,11 @@ module.exports = (common, options) => {
1515
this.timeout(30 * 1000)
1616
let ipfs
1717

18-
before(async function () {
19-
// CI takes longer to instantiate the daemon, so we need to increase the
20-
// timeout for the before step
21-
this.timeout(60 * 1000)
22-
23-
ipfs = await common.setup()
18+
before(async () => {
19+
ipfs = (await common.spawn()).api
2420
})
2521

26-
after(() => common.teardown())
22+
after(() => common.clean())
2723

2824
it('should list config profiles', async () => {
2925
const profiles = await ipfs.config.profiles.list()

src/config/replace.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
'use strict'
33

44
const { getDescribe, getIt, expect } = require('../utils/mocha')
5-
/** @typedef { import("ipfsd-ctl").TestsInterface } TestsInterface */
5+
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
66
/**
7-
* @param {TestsInterface} common
7+
* @param {Factory} common
88
* @param {Object} options
99
*/
1010
module.exports = (common, options) => {
@@ -15,15 +15,11 @@ module.exports = (common, options) => {
1515
this.timeout(30 * 1000)
1616
let ipfs
1717

18-
before(async function () {
19-
// CI takes longer to instantiate the daemon, so we need to increase the
20-
// timeout for the before step
21-
this.timeout(60 * 1000)
22-
23-
ipfs = await common.setup()
18+
before(async () => {
19+
ipfs = (await common.spawn()).api
2420
})
2521

26-
after(() => common.teardown())
22+
after(() => common.clean())
2723

2824
const config = {
2925
Fruit: 'Bananas'

0 commit comments

Comments
 (0)