Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@
"p-map-series": "^2.1.0",
"p-timeout": "^3.2.0",
"p-times": "^2.1.0",
"p-whilst": "^2.1.0",
"peer-id": "~0.13.5",
"peer-info": "~0.15.0",
"peer-id": "~0.12.2",
"peer-info": "~0.15.1",
"pull-stream": "^3.6.11",
"pull-to-promise": "^1.0.1",
"pump": "^3.0.0",
Expand Down
13 changes: 9 additions & 4 deletions src/bitswap/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ module.exports = (createCommon, options) => {
const it = getIt(options)
const common = createCommon()

describe('.bitswap.stat', function () {
this.timeout(60 * 1000)
describe('.bitswap.stat', () => {
let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand All @@ -24,7 +27,9 @@ module.exports = (createCommon, options) => {
expectIsBitswap(null, res)
})

it('should not get bitswap stats when offline', async () => {
it('should not get bitswap stats when offline', async function () {
this.timeout(60 * 1000)

const node = await createCommon().setup()
await node.stop()

Expand Down
20 changes: 9 additions & 11 deletions src/bitswap/utils.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
'use strict'

const pWhilst = require('p-whilst')
const delay = require('delay')

function waitForWantlistKey (ipfs, key, opts = {}) {
async function waitForWantlistKey (ipfs, key, opts = {}) {
opts.timeout = opts.timeout || 10000
const end = Date.now() + opts.timeout

let list = { Keys: [] }
while (Date.now() < end) {
const list = await ipfs.bitswap.wantlist(opts.peerId)

const start = Date.now()
const findKey = () => !list.Keys.some(k => k['/'] === key)

const iteratee = async () => {
if (Date.now() - start > opts.timeout) {
throw new Error(`Timed out waiting for ${key} in wantlist`)
if (list && list.Keys && list.Keys.some(k => k['/'] === key)) {
return
}

list = await ipfs.bitswap.wantlist(opts.peerId)
await delay(500)
}

return pWhilst(findKey, iteratee)
throw new Error(`Timed out waiting for ${key} in wantlist`)
}

module.exports.waitForWantlistKey = waitForWantlistKey
34 changes: 24 additions & 10 deletions src/bitswap/wantlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,51 @@ module.exports = (createCommon, options) => {
const it = getIt(options)
const common = createCommon()

describe('.bitswap.wantlist', function () {
this.timeout(60 * 1000)
describe('.bitswap.wantlist', () => {
let ipfsA
let ipfsB
const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR'

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfsA = await common.setup()
ipfsB = await common.setup()

// Add key to the wantlist for ipfsB
ipfsB.block.get(key, () => {})
ipfsB.block.get(key).catch(() => {})

await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])
})

after(() => common.teardown())
after(function () {
this.timeout(30 * 1000)

return common.teardown()
})

it('should get the wantlist', () => {
it('should get the wantlist', function () {
this.timeout(60 * 1000)
return waitForWantlistKey(ipfsB, key)
})

it('should get the wantlist by peer ID for a diffreent node', () => {
return waitForWantlistKey(ipfsA, key, { peerId: ipfsB.peerId.id })
it('should get the wantlist by peer ID for a different node', function () {
this.timeout(60 * 1000)
return waitForWantlistKey(ipfsA, key, {
peerId: ipfsB.peerId.id,
timeout: 60 * 1000
})
})

it('should not get the wantlist when offline', async () => {
it('should not get the wantlist when offline', async function () {
this.timeout(60 * 1000)

const node = await createCommon().setup()
await node.stop()

return expect(node.bitswap.stat()).to.eventually.be.rejected()
return expect(node.bitswap.wantlist()).to.eventually.be.rejected()
})
})
}
9 changes: 6 additions & 3 deletions src/block/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ module.exports = (createCommon, options) => {
const it = getIt(options)
const common = createCommon()

describe('.block.get', function () {
this.timeout(60 * 1000)
describe('.block.get', () => {
const data = Buffer.from('blorb')
let ipfs, hash

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
const block = await ipfs.block.put(data)
hash = block.cid.multihash
Expand Down
9 changes: 6 additions & 3 deletions src/block/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ module.exports = (createCommon, options) => {
const it = getIt(options)
const common = createCommon()

describe('.block.put', function () {
this.timeout(60 * 1000)
describe('.block.put', () => {
let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand Down
9 changes: 6 additions & 3 deletions src/block/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ module.exports = (createCommon, options) => {
const it = getIt(options)
const common = createCommon()

describe('.block.rm', function () {
this.timeout(60 * 1000)
describe('.block.rm', () => {
let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand Down
9 changes: 6 additions & 3 deletions src/block/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ module.exports = (createCommon, options) => {
const it = getIt(options)
const common = createCommon()

describe('.block.stat', function () {
this.timeout(60 * 1000)
describe('.block.stat', () => {
const data = Buffer.from('blorb')
let ipfs, hash

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
const block = await ipfs.block.put(data)
hash = block.cid.multihash
Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ module.exports = (createCommon, options) => {

let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ module.exports = (createCommon, options) => {

let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ module.exports = (createCommon, options) => {

let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand Down
8 changes: 6 additions & 2 deletions src/config/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ module.exports = (createCommon, options) => {
const common = createCommon()

describe('.config.get', function () {
this.timeout(60 * 1000)
this.timeout(30 * 1000)
let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand Down
6 changes: 5 additions & 1 deletion src/config/profiles/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ module.exports = (createCommon, options) => {
this.timeout(30 * 1000)
let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand Down
8 changes: 6 additions & 2 deletions src/config/profiles/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ module.exports = (createCommon, options) => {
const common = createCommon()

describe('.config.profiles.list', function () {
this.timeout(60 * 1000)
this.timeout(30 * 1000)
let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand Down
8 changes: 6 additions & 2 deletions src/config/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ module.exports = (createCommon, options) => {
const common = createCommon()

describe('.config.replace', function () {
this.timeout(60 * 1000)
this.timeout(30 * 1000)
let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand Down
8 changes: 6 additions & 2 deletions src/config/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ module.exports = (createCommon, options) => {
const common = createCommon()

describe('.config.set', function () {
this.timeout(60 * 1000)
this.timeout(30 * 1000)
let ipfs

before(async () => {
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

Expand Down
11 changes: 8 additions & 3 deletions src/dag/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ module.exports = (createCommon, options) => {
const it = getIt(options)
const common = createCommon()

describe('.dag.get', function () {
this.timeout(60 * 1000)
describe('.dag.get', () => {
let ipfs

before(async () => { ipfs = await common.setup() })
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

after(() => common.teardown())

Expand Down
11 changes: 8 additions & 3 deletions src/dag/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ module.exports = (createCommon, options) => {
const it = getIt(options)
const common = createCommon()

describe('.dag.put', function () {
this.timeout(60 * 1000)
describe('.dag.put', () => {
let ipfs

before(async () => { ipfs = await common.setup() })
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

after(() => common.teardown())

Expand Down
11 changes: 8 additions & 3 deletions src/dag/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ module.exports = (createCommon, options) => {
const it = getIt(options)
const common = createCommon()

describe('.dag.tree', function () {
this.timeout(60 * 1000)
describe('.dag.tree', () => {
let ipfs

before(async () => { ipfs = await common.setup() })
before(async function () {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

ipfs = await common.setup()
})

after(() => common.teardown())

Expand Down
Loading