|
4 | 4 | const { getDescribe, getIt, expect } = require('../utils/mocha') |
5 | 5 | const { waitForWantlistKey } = require('./utils') |
6 | 6 |
|
7 | | -module.exports = (createCommon, options) => { |
| 7 | +/** @typedef { import("ipfsd-ctl/src/factory") } Factory */ |
| 8 | +/** |
| 9 | + * @param {Factory} common |
| 10 | + * @param {Object} options |
| 11 | + */ |
| 12 | +module.exports = (common, options) => { |
8 | 13 | const describe = getDescribe(options) |
9 | 14 | const it = getIt(options) |
10 | | - const common = createCommon() |
11 | 15 |
|
12 | | - describe('.bitswap.wantlist', () => { |
| 16 | + describe('.bitswap.wantlist', function () { |
| 17 | + this.timeout(60 * 1000) |
13 | 18 | let ipfsA |
14 | 19 | let ipfsB |
15 | 20 | const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR' |
16 | 21 |
|
17 | | - before(async function () { |
18 | | - // CI takes longer to instantiate the daemon, so we need to increase the |
19 | | - // timeout for the before step |
20 | | - this.timeout(60 * 1000) |
21 | | - |
22 | | - ipfsA = await common.setup() |
23 | | - ipfsB = await common.setup() |
24 | | - |
| 22 | + before(async () => { |
| 23 | + ipfsA = (await common.spawn()).api |
| 24 | + ipfsB = (await common.spawn({ type: 'go' })).api |
25 | 25 | // Add key to the wantlist for ipfsB |
26 | 26 | ipfsB.block.get(key).catch(() => {}) |
27 | | - |
28 | 27 | await ipfsA.swarm.connect(ipfsB.peerId.addresses[0]) |
29 | 28 | }) |
30 | 29 |
|
31 | | - after(function () { |
32 | | - this.timeout(30 * 1000) |
33 | | - |
34 | | - return common.teardown() |
35 | | - }) |
| 30 | + after(() => common.clean()) |
36 | 31 |
|
37 | 32 | it('should get the wantlist', function () { |
38 | | - this.timeout(60 * 1000) |
39 | 33 | return waitForWantlistKey(ipfsB, key) |
40 | 34 | }) |
41 | 35 |
|
42 | 36 | it('should get the wantlist by peer ID for a different node', function () { |
43 | | - this.timeout(60 * 1000) |
44 | 37 | return waitForWantlistKey(ipfsA, key, { |
45 | 38 | peerId: ipfsB.peerId.id, |
46 | 39 | timeout: 60 * 1000 |
47 | 40 | }) |
48 | 41 | }) |
49 | 42 |
|
50 | | - it('should not get the wantlist when offline', async function () { |
51 | | - this.timeout(60 * 1000) |
52 | | - |
53 | | - const node = await createCommon().setup() |
| 43 | + it('should not get the wantlist when offline', async () => { |
| 44 | + const node = await common.spawn() |
54 | 45 | await node.stop() |
55 | 46 |
|
56 | | - return expect(node.bitswap.wantlist()).to.eventually.be.rejected() |
| 47 | + return expect(node.api.bitswap.stat()).to.eventually.be.rejected() |
57 | 48 | }) |
58 | 49 | }) |
59 | 50 | } |
0 commit comments