From 7873deb07b785f35ac02b9f5d80b591c34b31833 Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Thu, 28 Nov 2019 14:58:00 +0000 Subject: [PATCH 01/15] chore: add tests timeouts as they were previously --- src/bitswap/stat.js | 13 +++++++++---- src/bitswap/wantlist.js | 19 ++++++++++++++----- src/block/get.js | 9 ++++++--- src/block/put.js | 9 ++++++--- src/block/rm.js | 9 ++++++--- src/block/stat.js | 9 ++++++--- src/bootstrap/add.js | 6 +++++- src/bootstrap/list.js | 6 +++++- src/bootstrap/rm.js | 6 +++++- src/config/get.js | 8 ++++++-- src/config/profiles/apply.js | 6 +++++- src/config/profiles/list.js | 8 ++++++-- src/config/replace.js | 8 ++++++-- src/config/set.js | 8 ++++++-- src/dag/get.js | 11 ++++++++--- src/dag/put.js | 11 ++++++++--- src/dag/tree.js | 11 ++++++++--- src/dht/find-peer.js | 12 ++++++++++-- src/dht/find-provs.js | 15 +++++++++++---- src/dht/get.js | 16 +++++++++++++--- src/dht/provide.js | 12 ++++++++++-- src/dht/put.js | 10 ++++++++-- src/dht/query.js | 12 ++++++++++-- src/files-mfs/cp.js | 10 ++++++++-- src/files-mfs/flush.js | 10 ++++++++-- src/files-mfs/ls-pull-stream.js | 10 ++++++++-- src/files-mfs/ls-readable-stream.js | 10 ++++++++-- src/files-mfs/ls.js | 10 ++++++++-- src/files-mfs/mkdir.js | 10 ++++++++-- src/files-mfs/mv.js | 10 ++++++++-- src/files-mfs/read-pull-stream.js | 10 ++++++++-- src/files-mfs/read-readable-stream.js | 10 ++++++++-- src/files-mfs/read.js | 10 ++++++++-- src/files-mfs/rm.js | 10 ++++++++-- src/files-mfs/stat.js | 10 ++++++++-- src/files-mfs/write.js | 8 +++++++- src/files-regular/add-from-fs.js | 10 ++++++++-- src/files-regular/add-from-stream.js | 10 ++++++++-- src/files-regular/add-from-url.js | 10 ++++++++-- src/files-regular/add-pull-stream.js | 10 ++++++++-- src/files-regular/add-readable-stream.js | 10 ++++++++-- src/files-regular/add.js | 8 +++++++- src/files-regular/cat-pull-stream.js | 10 ++++++++-- src/files-regular/cat-readable-stream.js | 8 ++++++-- src/files-regular/cat.js | 10 ++++++++-- src/files-regular/get-pull-stream.js | 10 ++++++++-- src/files-regular/get-readable-stream.js | 8 ++++++-- src/files-regular/get.js | 8 ++++++-- src/files-regular/ls-pull-stream.js | 8 ++++++-- src/files-regular/ls-readable-stream.js | 8 ++++++-- src/files-regular/ls.js | 8 ++++++-- src/files-regular/refs-local-tests.js | 8 ++++++-- src/files-regular/refs-tests.js | 8 ++++++-- src/key/export.js | 9 ++++++--- src/key/gen.js | 9 ++++++--- src/key/import.js | 9 ++++++--- src/key/list.js | 11 ++++++++--- src/key/rename.js | 11 ++++++++--- src/key/rm.js | 11 ++++++++--- src/miscellaneous/dns.js | 6 +++++- src/miscellaneous/resolve.js | 2 ++ src/miscellaneous/stop.js | 6 ++---- src/miscellaneous/version.js | 9 ++++++--- src/name-pubsub/cancel.js | 8 ++++++-- src/name-pubsub/state.js | 9 ++++++--- src/name-pubsub/subs.js | 8 ++++++-- src/name/publish.js | 8 ++++++-- src/name/resolve.js | 2 +- src/object/data.js | 6 +++++- src/object/get.js | 6 +++++- src/object/links.js | 6 +++++- src/object/new.js | 6 +++++- src/object/patch/add-link.js | 6 +++++- src/object/patch/append-data.js | 6 +++++- src/object/patch/rm-link.js | 6 +++++- src/object/patch/set-data.js | 6 +++++- src/object/put.js | 6 +++++- src/object/stat.js | 6 +++++- src/pin/add.js | 8 ++++++-- src/pin/ls.js | 8 ++++++-- src/pin/rm.js | 8 ++++++-- src/ping/ping.js | 6 +++++- src/pubsub/ls.js | 6 +++++- src/pubsub/peers.js | 6 +++++- src/pubsub/publish.js | 6 +++++- src/pubsub/subscribe.js | 6 +++++- src/pubsub/unsubscribe.js | 6 +++++- src/repo/gc.js | 9 ++++++--- src/repo/stat.js | 9 ++++++--- src/repo/version.js | 9 ++++++--- src/stats/bitswap.js | 6 +++++- src/stats/bw-pull-stream.js | 9 ++++++--- src/stats/bw-readable-stream.js | 9 ++++++--- src/stats/bw.js | 9 ++++++--- src/stats/repo.js | 9 ++++++--- 95 files changed, 626 insertions(+), 195 deletions(-) diff --git a/src/bitswap/stat.js b/src/bitswap/stat.js index 30b5570f4..de99bc4a2 100644 --- a/src/bitswap/stat.js +++ b/src/bitswap/stat.js @@ -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() }) @@ -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() diff --git a/src/bitswap/wantlist.js b/src/bitswap/wantlist.js index 34480a900..573bdf3d5 100644 --- a/src/bitswap/wantlist.js +++ b/src/bitswap/wantlist.js @@ -10,13 +10,16 @@ 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() @@ -26,7 +29,11 @@ module.exports = (createCommon, options) => { 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', () => { return waitForWantlistKey(ipfsB, key) @@ -36,7 +43,9 @@ module.exports = (createCommon, options) => { return waitForWantlistKey(ipfsA, key, { peerId: ipfsB.peerId.id }) }) - 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() diff --git a/src/block/get.js b/src/block/get.js index 38e2a659a..e07e68d5d 100644 --- a/src/block/get.js +++ b/src/block/get.js @@ -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 diff --git a/src/block/put.js b/src/block/put.js index 1df2edc99..ec8d3ffb1 100644 --- a/src/block/put.js +++ b/src/block/put.js @@ -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() }) diff --git a/src/block/rm.js b/src/block/rm.js index 8f99fa23a..e5fe1fe0e 100644 --- a/src/block/rm.js +++ b/src/block/rm.js @@ -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() }) diff --git a/src/block/stat.js b/src/block/stat.js index 0d1a5976e..baa7a66ff 100644 --- a/src/block/stat.js +++ b/src/block/stat.js @@ -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 diff --git a/src/bootstrap/add.js b/src/bootstrap/add.js index eb8034663..c4a8440d6 100644 --- a/src/bootstrap/add.js +++ b/src/bootstrap/add.js @@ -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() }) diff --git a/src/bootstrap/list.js b/src/bootstrap/list.js index ffb75c23d..033920571 100644 --- a/src/bootstrap/list.js +++ b/src/bootstrap/list.js @@ -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() }) diff --git a/src/bootstrap/rm.js b/src/bootstrap/rm.js index 172cf014d..f8e200402 100644 --- a/src/bootstrap/rm.js +++ b/src/bootstrap/rm.js @@ -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() }) diff --git a/src/config/get.js b/src/config/get.js index 199257e36..9470c1b67 100644 --- a/src/config/get.js +++ b/src/config/get.js @@ -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() }) diff --git a/src/config/profiles/apply.js b/src/config/profiles/apply.js index 7cd96f785..ca0b91262 100644 --- a/src/config/profiles/apply.js +++ b/src/config/profiles/apply.js @@ -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() }) diff --git a/src/config/profiles/list.js b/src/config/profiles/list.js index 69482b21b..ffe572388 100644 --- a/src/config/profiles/list.js +++ b/src/config/profiles/list.js @@ -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() }) diff --git a/src/config/replace.js b/src/config/replace.js index bab2133cc..67496a7d7 100644 --- a/src/config/replace.js +++ b/src/config/replace.js @@ -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() }) diff --git a/src/config/set.js b/src/config/set.js index c808c4ec2..1e29d9234 100644 --- a/src/config/set.js +++ b/src/config/set.js @@ -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() }) diff --git a/src/dag/get.js b/src/dag/get.js index ad68e2794..dc8ee9ee9 100644 --- a/src/dag/get.js +++ b/src/dag/get.js @@ -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()) diff --git a/src/dag/put.js b/src/dag/put.js index 9ef382c98..eb52106cb 100644 --- a/src/dag/put.js +++ b/src/dag/put.js @@ -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()) diff --git a/src/dag/tree.js b/src/dag/tree.js index a60746f7e..fe9826209 100644 --- a/src/dag/tree.js +++ b/src/dag/tree.js @@ -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()) diff --git a/src/dht/find-peer.js b/src/dht/find-peer.js index 898ddf4b7..5c6c3b4e4 100644 --- a/src/dht/find-peer.js +++ b/src/dht/find-peer.js @@ -14,13 +14,21 @@ module.exports = (createCommon, options) => { let nodeA let nodeB - 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) + nodeA = await common.setup() nodeB = await common.setup() await nodeB.swarm.connect(nodeA.peerId.addresses[0]) }) - after(() => common.teardown()) + after(function () { + this.timeout(50 * 1000) + + return common.teardown() + }) it('should find other peers', async () => { const res = await nodeA.dht.findPeer(nodeB.peerId.id) diff --git a/src/dht/find-provs.js b/src/dht/find-provs.js index 4897f4f16..9e3016666 100644 --- a/src/dht/find-provs.js +++ b/src/dht/find-provs.js @@ -18,15 +18,16 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.dht.findProvs', function () { - this.timeout(80 * 1000) - + describe('.dht.findProvs', () => { let nodeA let nodeB let nodeC 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) + nodeA = await common.setup() nodeB = await common.setup() nodeC = await common.setup() @@ -36,7 +37,11 @@ module.exports = (createCommon, options) => { ]) }) - after(() => common.teardown()) + after(function () { + this.timeout(50 * 1000) + + return common.teardown() + }) let providedCid before('add providers for the same cid', async function () { @@ -56,6 +61,8 @@ module.exports = (createCommon, options) => { }) it('should be able to find providers', async function () { + this.timeout(20 * 1000) + const provs = await nodeA.dht.findProvs(providedCid) const providerIds = provs.map((p) => p.id.toB58String()) diff --git a/src/dht/get.js b/src/dht/get.js index a71e54d22..0fe6df9e4 100644 --- a/src/dht/get.js +++ b/src/dht/get.js @@ -15,20 +15,30 @@ module.exports = (createCommon, options) => { let nodeA let nodeB - 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) + nodeA = await common.setup() nodeB = await common.setup() await nodeA.swarm.connect(nodeB.peerId.addresses[0]) }) - after(() => common.teardown()) + after(function () { + this.timeout(50 * 1000) + + return common.teardown() + }) it('should error when getting a non-existent key from the DHT', () => { return expect(nodeA.dht.get('non-existing', { timeout: 100 })).to.eventually.be.rejected .and.be.an.instanceOf(Error) }) - it('should get a value after it was put on another node', async () => { + it('should get a value after it was put on another node', async function () { + this.timeout(80 * 1000) + const key = Buffer.from(hat()) const value = Buffer.from(hat()) diff --git a/src/dht/provide.js b/src/dht/provide.js index 456dcbc7d..c4c6fafd6 100644 --- a/src/dht/provide.js +++ b/src/dht/provide.js @@ -14,13 +14,21 @@ 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() const nodeB = await common.setup() await ipfs.swarm.connect(nodeB.peerId.addresses[0]) }) - after(() => common.teardown()) + after(function () { + this.timeout(50 * 1000) + + return common.teardown() + }) it('should provide local CID', async () => { const res = await ipfs.add(Buffer.from('test')) diff --git a/src/dht/put.js b/src/dht/put.js index 826c9fcce..04a795c5a 100644 --- a/src/dht/put.js +++ b/src/dht/put.js @@ -14,7 +14,11 @@ module.exports = (createCommon, options) => { let nodeA let nodeB - 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) + nodeA = await common.setup() nodeB = await common.setup() await nodeA.swarm.connect(nodeB.peerId.addresses[0]) @@ -22,7 +26,9 @@ module.exports = (createCommon, options) => { after(() => common.teardown()) - it('should put a value to the DHT', async () => { + it('should put a value to the DHT', async function () { + this.timeout(80 * 1000) + const key = Buffer.from('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn') const data = Buffer.from('data') diff --git a/src/dht/query.js b/src/dht/query.js index 2e155911f..015147d48 100644 --- a/src/dht/query.js +++ b/src/dht/query.js @@ -15,13 +15,21 @@ module.exports = (createCommon, options) => { let nodeA let nodeB - 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) + nodeA = await common.setup() nodeB = await common.setup() await nodeB.swarm.connect(nodeA.peerId.addresses[0]) }) - after(() => common.teardown()) + after(function () { + this.timeout(50 * 1000) + + return common.teardown() + }) it('should return the other node in the query', async function () { const timeout = 150 * 1000 diff --git a/src/files-mfs/cp.js b/src/files-mfs/cp.js index 966a8c302..400fe88ab 100644 --- a/src/files-mfs/cp.js +++ b/src/files-mfs/cp.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.cp', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-mfs/flush.js b/src/files-mfs/flush.js index eb3b66df3..fb53808ce 100644 --- a/src/files-mfs/flush.js +++ b/src/files-mfs/flush.js @@ -10,11 +10,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.flush', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-mfs/ls-pull-stream.js b/src/files-mfs/ls-pull-stream.js index 6210eaed6..72f6563f7 100644 --- a/src/files-mfs/ls-pull-stream.js +++ b/src/files-mfs/ls-pull-stream.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.lsPullStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-mfs/ls-readable-stream.js b/src/files-mfs/ls-readable-stream.js index e3a11a827..c32cfd709 100644 --- a/src/files-mfs/ls-readable-stream.js +++ b/src/files-mfs/ls-readable-stream.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.lsReadableStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-mfs/ls.js b/src/files-mfs/ls.js index 600db8d5a..0cf36c661 100644 --- a/src/files-mfs/ls.js +++ b/src/files-mfs/ls.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.ls', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-mfs/mkdir.js b/src/files-mfs/mkdir.js index 9cc0dd5da..4c2baf6b3 100644 --- a/src/files-mfs/mkdir.js +++ b/src/files-mfs/mkdir.js @@ -10,11 +10,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.mkdir', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-mfs/mv.js b/src/files-mfs/mv.js index 7cdbeaf05..fa54d598e 100644 --- a/src/files-mfs/mv.js +++ b/src/files-mfs/mv.js @@ -10,11 +10,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.mv', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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() + }) before(async () => { await ipfs.files.mkdir('/test/lv1/lv2', { parents: true }) diff --git a/src/files-mfs/read-pull-stream.js b/src/files-mfs/read-pull-stream.js index 6b70a494f..45b9af8dc 100644 --- a/src/files-mfs/read-pull-stream.js +++ b/src/files-mfs/read-pull-stream.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.readPullStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-mfs/read-readable-stream.js b/src/files-mfs/read-readable-stream.js index c6f286652..d8344ee17 100644 --- a/src/files-mfs/read-readable-stream.js +++ b/src/files-mfs/read-readable-stream.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.readReadableStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-mfs/read.js b/src/files-mfs/read.js index 6b97d91c5..91c6e533b 100644 --- a/src/files-mfs/read.js +++ b/src/files-mfs/read.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.read', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-mfs/rm.js b/src/files-mfs/rm.js index a8412ea98..9d13ca06b 100644 --- a/src/files-mfs/rm.js +++ b/src/files-mfs/rm.js @@ -10,11 +10,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.rm', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-mfs/stat.js b/src/files-mfs/stat.js index 9bc3ccb7b..b0619ea16 100644 --- a/src/files-mfs/stat.js +++ b/src/files-mfs/stat.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.files.stat', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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() + }) before(async () => { await ipfs.add(fixtures.smallFile.data) }) after(() => common.teardown()) diff --git a/src/files-mfs/write.js b/src/files-mfs/write.js index 6fc3e42d1..f81a1a36b 100644 --- a/src/files-mfs/write.js +++ b/src/files-mfs/write.js @@ -14,7 +14,13 @@ module.exports = (createCommon, options) => { 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()) diff --git a/src/files-regular/add-from-fs.js b/src/files-regular/add-from-fs.js index 5a0765e9b..dc5f892df 100644 --- a/src/files-regular/add-from-fs.js +++ b/src/files-regular/add-from-fs.js @@ -13,12 +13,18 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.addFromFs', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) const fixturesPath = path.join(__dirname, '../../test/fixtures') 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()) diff --git a/src/files-regular/add-from-stream.js b/src/files-regular/add-from-stream.js index 34ee1c3c7..9df66ee37 100644 --- a/src/files-regular/add-from-stream.js +++ b/src/files-regular/add-from-stream.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.addFromStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-regular/add-from-url.js b/src/files-regular/add-from-url.js index c57fc7e4f..d1e68baaa 100644 --- a/src/files-regular/add-from-url.js +++ b/src/files-regular/add-from-url.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.addFromURL', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-regular/add-pull-stream.js b/src/files-regular/add-pull-stream.js index 9dd753842..9606e2491 100644 --- a/src/files-regular/add-pull-stream.js +++ b/src/files-regular/add-pull-stream.js @@ -12,11 +12,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.addPullStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-regular/add-readable-stream.js b/src/files-regular/add-readable-stream.js index 749ac1e7f..6b5d33eae 100644 --- a/src/files-regular/add-readable-stream.js +++ b/src/files-regular/add-readable-stream.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.addReadableStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-regular/add.js b/src/files-regular/add.js index fdea60e4b..9faa37752 100644 --- a/src/files-regular/add.js +++ b/src/files-regular/add.js @@ -18,7 +18,13 @@ module.exports = (createCommon, options) => { 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()) diff --git a/src/files-regular/cat-pull-stream.js b/src/files-regular/cat-pull-stream.js index 28aa765e9..18842d13e 100644 --- a/src/files-regular/cat-pull-stream.js +++ b/src/files-regular/cat-pull-stream.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.catPullStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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() + }) before(() => ipfs.add(fixtures.smallFile.data)) after(() => common.teardown()) diff --git a/src/files-regular/cat-readable-stream.js b/src/files-regular/cat-readable-stream.js index 16f3e98db..17778b664 100644 --- a/src/files-regular/cat-readable-stream.js +++ b/src/files-regular/cat-readable-stream.js @@ -11,11 +11,15 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.catReadableStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 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() await ipfs.add(fixtures.bigFile.data) await ipfs.add(fixtures.smallFile.data) diff --git a/src/files-regular/cat.js b/src/files-regular/cat.js index 2681e689a..41523adf2 100644 --- a/src/files-regular/cat.js +++ b/src/files-regular/cat.js @@ -12,11 +12,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.cat', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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()) diff --git a/src/files-regular/get-pull-stream.js b/src/files-regular/get-pull-stream.js index 03f9c379b..ee50075e7 100644 --- a/src/files-regular/get-pull-stream.js +++ b/src/files-regular/get-pull-stream.js @@ -11,11 +11,17 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.getPullStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) 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() + }) before(() => ipfs.add(fixtures.smallFile.data)) diff --git a/src/files-regular/get-readable-stream.js b/src/files-regular/get-readable-stream.js index e82442479..ed1837bb6 100644 --- a/src/files-regular/get-readable-stream.js +++ b/src/files-regular/get-readable-stream.js @@ -12,11 +12,15 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.getReadableStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 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() await ipfs.add(fixtures.smallFile.data) }) diff --git a/src/files-regular/get.js b/src/files-regular/get.js index 2bfe5d690..8a940f2ba 100644 --- a/src/files-regular/get.js +++ b/src/files-regular/get.js @@ -12,11 +12,15 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.get', function () { - this.timeout(60 * 1000) + this.timeout(40 * 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() await ipfs.add(fixtures.smallFile.data) await ipfs.add(fixtures.bigFile.data) diff --git a/src/files-regular/ls-pull-stream.js b/src/files-regular/ls-pull-stream.js index 963b2da1e..8b9ff1739 100644 --- a/src/files-regular/ls-pull-stream.js +++ b/src/files-regular/ls-pull-stream.js @@ -11,11 +11,15 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.lsPullStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 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() }) diff --git a/src/files-regular/ls-readable-stream.js b/src/files-regular/ls-readable-stream.js index f3d0cbbca..ccf27dc65 100644 --- a/src/files-regular/ls-readable-stream.js +++ b/src/files-regular/ls-readable-stream.js @@ -11,11 +11,15 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.lsReadableStream', function () { - this.timeout(60 * 1000) + this.timeout(40 * 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() }) diff --git a/src/files-regular/ls.js b/src/files-regular/ls.js index 3dc3b73e0..9d54ca8a5 100644 --- a/src/files-regular/ls.js +++ b/src/files-regular/ls.js @@ -14,11 +14,15 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.ls', function () { - this.timeout(60 * 1000) + this.timeout(40 * 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() }) diff --git a/src/files-regular/refs-local-tests.js b/src/files-regular/refs-local-tests.js index 78c8e6702..6d5cda042 100644 --- a/src/files-regular/refs-local-tests.js +++ b/src/files-regular/refs-local-tests.js @@ -10,11 +10,15 @@ module.exports = (createCommon, suiteName, ipfsRefsLocal, options) => { const common = createCommon() describe(suiteName, function () { - this.timeout(60 * 1000) + this.timeout(40 * 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() }) diff --git a/src/files-regular/refs-tests.js b/src/files-regular/refs-tests.js index 60bdebc4d..3725800d8 100644 --- a/src/files-regular/refs-tests.js +++ b/src/files-regular/refs-tests.js @@ -13,11 +13,15 @@ module.exports = (createCommon, suiteName, ipfsRefs, options) => { const common = createCommon() describe(suiteName, function () { - this.timeout(60 * 1000) + this.timeout(40 * 1000) let ipfs, pbRootCb, dagRootCid - 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() }) diff --git a/src/key/export.js b/src/key/export.js index ddfb783b9..70d1588fa 100644 --- a/src/key/export.js +++ b/src/key/export.js @@ -9,11 +9,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.key.export', function () { - this.timeout(60 * 1000) + describe('.key.export', () => { 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() }) diff --git a/src/key/gen.js b/src/key/gen.js index 71d5be51e..726cfdb03 100644 --- a/src/key/gen.js +++ b/src/key/gen.js @@ -9,15 +9,18 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.key.gen', function () { - this.timeout(60 * 1000) + describe('.key.gen', () => { const keyTypes = [ { type: 'rsa', size: 2048 } ] 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() }) diff --git a/src/key/import.js b/src/key/import.js index 8669223cd..4ed73ba36 100644 --- a/src/key/import.js +++ b/src/key/import.js @@ -9,11 +9,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.key.import', function () { - this.timeout(60 * 1000) + describe('.key.import', () => { 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() }) diff --git a/src/key/list.js b/src/key/list.js index 383989435..62bc3b7cc 100644 --- a/src/key/list.js +++ b/src/key/list.js @@ -11,17 +11,22 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.key.list', function () { - this.timeout(60 * 1000) + describe('.key.list', () => { 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() }) after(() => common.teardown()) it('should list all the keys', async function () { + this.timeout(60 * 1000) + const keys = await pTimes(3, () => ipfs.key.gen(hat(), { type: 'rsa', size: 2048 }), { concurrency: 1 }) const res = await ipfs.key.list() diff --git a/src/key/rename.js b/src/key/rename.js index a18796059..9ee2b87a8 100644 --- a/src/key/rename.js +++ b/src/key/rename.js @@ -10,17 +10,22 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.key.rename', function () { - this.timeout(60 * 1000) + describe('.key.rename', () => { 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() }) after(() => common.teardown()) it('should rename a key', async function () { + this.timeout(30 * 1000) + const oldName = hat() const newName = hat() diff --git a/src/key/rm.js b/src/key/rm.js index 5140ed901..56d10e2b7 100644 --- a/src/key/rm.js +++ b/src/key/rm.js @@ -10,17 +10,22 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.key.rm', function () { - this.timeout(60 * 1000) + describe('.key.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() }) after(() => common.teardown()) it('should rm a key', async function () { + this.timeout(30 * 1000) + const key = await ipfs.key.gen(hat(), { type: 'rsa', size: 2048 }) const removeRes = await ipfs.key.rm(key.name) diff --git a/src/miscellaneous/dns.js b/src/miscellaneous/dns.js index 490c04db0..9a68ea808 100644 --- a/src/miscellaneous/dns.js +++ b/src/miscellaneous/dns.js @@ -13,7 +13,11 @@ module.exports = (createCommon, options) => { this.retries(3) 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() }) diff --git a/src/miscellaneous/resolve.js b/src/miscellaneous/resolve.js index 699c122b8..b0a049e43 100644 --- a/src/miscellaneous/resolve.js +++ b/src/miscellaneous/resolve.js @@ -77,6 +77,8 @@ module.exports = (createCommon, options) => { }) it('should resolve IPNS link recursively', async function () { + this.timeout(20 * 1000) + const node = await common.setup() await ipfs.swarm.connect(node.peerId.addresses.find((a) => a.includes('127.0.0.1'))) diff --git a/src/miscellaneous/stop.js b/src/miscellaneous/stop.js index d83fdc9e3..58ee8bea6 100644 --- a/src/miscellaneous/stop.js +++ b/src/miscellaneous/stop.js @@ -8,12 +8,10 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.stop', function () { - this.timeout(60 * 1000) - + describe('.stop', () => { it('should stop the node', async function () { - const ipfs = await common.setup() this.timeout(10 * 1000) + const ipfs = await common.setup() await ipfs.stop() diff --git a/src/miscellaneous/version.js b/src/miscellaneous/version.js index 1d8f58eb8..c38af691b 100644 --- a/src/miscellaneous/version.js +++ b/src/miscellaneous/version.js @@ -8,11 +8,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.version', function () { - this.timeout(60 * 1000) + describe('.version', () => { 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() }) diff --git a/src/name-pubsub/cancel.js b/src/name-pubsub/cancel.js index cf2a30d0e..45919c241 100644 --- a/src/name-pubsub/cancel.js +++ b/src/name-pubsub/cancel.js @@ -11,11 +11,15 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.name.pubsub.cancel', function () { + describe('.name.pubsub.cancel', () => { let ipfs let nodeId - 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() nodeId = ipfs.peerId.id }) diff --git a/src/name-pubsub/state.js b/src/name-pubsub/state.js index df40c7b20..13ec1e08e 100644 --- a/src/name-pubsub/state.js +++ b/src/name-pubsub/state.js @@ -8,11 +8,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.name.pubsub.state', function () { - this.timeout(60 * 1000) + describe('.name.pubsub.state', () => { 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() }) diff --git a/src/name-pubsub/subs.js b/src/name-pubsub/subs.js index 388d650dd..65493f79a 100644 --- a/src/name-pubsub/subs.js +++ b/src/name-pubsub/subs.js @@ -9,10 +9,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.name.pubsub.subs', function () { + describe('.name.pubsub.subs', () => { 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() }) diff --git a/src/name/publish.js b/src/name/publish.js index b21315ea7..7c4733db1 100644 --- a/src/name/publish.js +++ b/src/name/publish.js @@ -11,12 +11,16 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.name.publish offline', function () { + describe('.name.publish offline', () => { const keyName = hat() let ipfs let nodeId - 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() nodeId = ipfs.peerId.id await ipfs.add(fixture.data, { pin: false }) diff --git a/src/name/resolve.js b/src/name/resolve.js index 1f72a0c05..ff90d07ef 100644 --- a/src/name/resolve.js +++ b/src/name/resolve.js @@ -10,7 +10,7 @@ module.exports = (createCommon, options) => { const describe = getDescribe(options) const it = getIt(options) - describe('.name.resolve offline', function () { + describe('.name.resolve offline', () => { const common = createCommon() let ipfs let nodeId diff --git a/src/object/data.js b/src/object/data.js index 1c31b1736..698767c31 100644 --- a/src/object/data.js +++ b/src/object/data.js @@ -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() }) diff --git a/src/object/get.js b/src/object/get.js index 1ca870d22..c4f662dfa 100644 --- a/src/object/get.js +++ b/src/object/get.js @@ -19,7 +19,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() }) diff --git a/src/object/links.js b/src/object/links.js index 10400d911..72c4bc09e 100644 --- a/src/object/links.js +++ b/src/object/links.js @@ -19,7 +19,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() }) diff --git a/src/object/new.js b/src/object/new.js index b4732932c..6f20522d0 100644 --- a/src/object/new.js +++ b/src/object/new.js @@ -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() }) diff --git a/src/object/patch/add-link.js b/src/object/patch/add-link.js index c221f051d..1e97a70ba 100644 --- a/src/object/patch/add-link.js +++ b/src/object/patch/add-link.js @@ -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() }) diff --git a/src/object/patch/append-data.js b/src/object/patch/append-data.js index 3a35a958e..373244ca0 100644 --- a/src/object/patch/append-data.js +++ b/src/object/patch/append-data.js @@ -14,7 +14,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() }) diff --git a/src/object/patch/rm-link.js b/src/object/patch/rm-link.js index 331226837..f12ffefa7 100644 --- a/src/object/patch/rm-link.js +++ b/src/object/patch/rm-link.js @@ -14,7 +14,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() }) diff --git a/src/object/patch/set-data.js b/src/object/patch/set-data.js index b65afab97..1f1b795ba 100644 --- a/src/object/patch/set-data.js +++ b/src/object/patch/set-data.js @@ -14,7 +14,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() }) diff --git a/src/object/put.js b/src/object/put.js index da9e885ee..c1383e7f4 100644 --- a/src/object/put.js +++ b/src/object/put.js @@ -17,7 +17,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() }) diff --git a/src/object/stat.js b/src/object/stat.js index edac169c7..de717a6f3 100644 --- a/src/object/stat.js +++ b/src/object/stat.js @@ -17,7 +17,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() }) diff --git a/src/pin/add.js b/src/pin/add.js index 379ff6543..d8789080c 100644 --- a/src/pin/add.js +++ b/src/pin/add.js @@ -10,11 +10,15 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.pin.add', function () { - this.timeout(60 * 1000) + this.timeout(50 * 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() await Promise.all(fixtures.files.map(file => { return ipfs.add(file.data, { pin: false }) diff --git a/src/pin/ls.js b/src/pin/ls.js index 4d598281c..47caed6c3 100644 --- a/src/pin/ls.js +++ b/src/pin/ls.js @@ -10,11 +10,15 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.pin.ls', function () { - this.timeout(60 * 1000) + this.timeout(50 * 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() // two files wrapped in directories, only root CID pinned recursively const dir = fixtures.directory.files.map((file) => ({ path: file.path, content: file.data })) diff --git a/src/pin/rm.js b/src/pin/rm.js index 7b8e5dc58..6be13effe 100644 --- a/src/pin/rm.js +++ b/src/pin/rm.js @@ -10,11 +10,15 @@ module.exports = (createCommon, options) => { const common = createCommon() describe('.pin.rm', function () { - this.timeout(60 * 1000) + this.timeout(50 * 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() await ipfs.add(fixtures.files[0].data, { pin: false }) await ipfs.pin.add(fixtures.files[0].cid, { recursive: true }) diff --git a/src/ping/ping.js b/src/ping/ping.js index 95b914826..030a77f16 100644 --- a/src/ping/ping.js +++ b/src/ping/ping.js @@ -15,7 +15,11 @@ module.exports = (createCommon, options) => { let ipfsA let ipfsB - 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() await ipfsA.swarm.connect(ipfsB.peerId.addresses[0]) diff --git a/src/pubsub/ls.js b/src/pubsub/ls.js index 126be18ba..daf2e3586 100644 --- a/src/pubsub/ls.js +++ b/src/pubsub/ls.js @@ -16,7 +16,11 @@ module.exports = (createCommon, options) => { let ipfs let subscribedTopics = [] - 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() }) diff --git a/src/pubsub/peers.js b/src/pubsub/peers.js index 01084d2d5..88bef2d65 100644 --- a/src/pubsub/peers.js +++ b/src/pubsub/peers.js @@ -18,7 +18,11 @@ module.exports = (createCommon, options) => { let ipfs3 let subscribedTopics = [] - 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(100 * 1000) + ipfs1 = await common.setup() ipfs2 = await common.setup() ipfs3 = await common.setup() diff --git a/src/pubsub/publish.js b/src/pubsub/publish.js index 6eba0061f..3b8e93fcd 100644 --- a/src/pubsub/publish.js +++ b/src/pubsub/publish.js @@ -15,7 +15,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() }) diff --git a/src/pubsub/subscribe.js b/src/pubsub/subscribe.js index be5093fc0..d4bd6b87f 100644 --- a/src/pubsub/subscribe.js +++ b/src/pubsub/subscribe.js @@ -21,7 +21,11 @@ module.exports = (createCommon, options) => { let topic let subscribedTopics = [] - 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(100 * 1000) + ipfs1 = await common.setup() ipfs2 = await common.setup() }) diff --git a/src/pubsub/unsubscribe.js b/src/pubsub/unsubscribe.js index dd0be0f9a..2fe522df7 100644 --- a/src/pubsub/unsubscribe.js +++ b/src/pubsub/unsubscribe.js @@ -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() }) diff --git a/src/repo/gc.js b/src/repo/gc.js index 11fded58a..2c29c2dea 100644 --- a/src/repo/gc.js +++ b/src/repo/gc.js @@ -9,11 +9,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.repo.gc', function () { - this.timeout(60 * 1000) + describe('.repo.gc', () => { 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() }) diff --git a/src/repo/stat.js b/src/repo/stat.js index 662c24035..aaa7ad4b7 100644 --- a/src/repo/stat.js +++ b/src/repo/stat.js @@ -9,11 +9,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.repo.stat', function () { - this.timeout(60 * 1000) + describe('.repo.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() }) diff --git a/src/repo/version.js b/src/repo/version.js index 99c084326..d8384e383 100644 --- a/src/repo/version.js +++ b/src/repo/version.js @@ -8,11 +8,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.repo.version', function () { - this.timeout(60 * 1000) + describe('.repo.version', () => { 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() }) diff --git a/src/stats/bitswap.js b/src/stats/bitswap.js index 37a41828c..61bca7e61 100644 --- a/src/stats/bitswap.js +++ b/src/stats/bitswap.js @@ -12,7 +12,11 @@ module.exports = (createCommon, options) => { describe('.stats.bitswap', () => { 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() }) diff --git a/src/stats/bw-pull-stream.js b/src/stats/bw-pull-stream.js index 6d3c39331..97d96193c 100644 --- a/src/stats/bw-pull-stream.js +++ b/src/stats/bw-pull-stream.js @@ -10,11 +10,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.stats.bwPullStream', function () { - this.timeout(60 * 1000) + describe('.stats.bwPullStream', () => { 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() }) diff --git a/src/stats/bw-readable-stream.js b/src/stats/bw-readable-stream.js index 6ab0c711e..50e0a8c0d 100644 --- a/src/stats/bw-readable-stream.js +++ b/src/stats/bw-readable-stream.js @@ -10,11 +10,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.stats.bwReadableStream', function () { - this.timeout(60 * 1000) + describe('.stats.bwReadableStream', () => { 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() }) diff --git a/src/stats/bw.js b/src/stats/bw.js index 13937c77d..7994bca84 100644 --- a/src/stats/bw.js +++ b/src/stats/bw.js @@ -9,11 +9,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.stats.bw', function () { - this.timeout(60 * 1000) + describe('.stats.bw', () => { 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() }) diff --git a/src/stats/repo.js b/src/stats/repo.js index 792449307..e6fae8d37 100644 --- a/src/stats/repo.js +++ b/src/stats/repo.js @@ -9,11 +9,14 @@ module.exports = (createCommon, options) => { const it = getIt(options) const common = createCommon() - describe('.stats.repo', function () { - this.timeout(60 * 1000) + describe('.stats.repo', () => { 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() }) From 36e9749e022cfcf1f414b53e0fd147110527cb6c Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Fri, 29 Nov 2019 09:47:16 +0000 Subject: [PATCH 02/15] chore: code review changes --- src/bitswap/wantlist.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bitswap/wantlist.js b/src/bitswap/wantlist.js index 573bdf3d5..1f11e8ce0 100644 --- a/src/bitswap/wantlist.js +++ b/src/bitswap/wantlist.js @@ -24,7 +24,7 @@ module.exports = (createCommon, options) => { 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]) }) @@ -39,7 +39,7 @@ module.exports = (createCommon, options) => { return waitForWantlistKey(ipfsB, key) }) - it('should get the wantlist by peer ID for a diffreent node', () => { + it('should get the wantlist by peer ID for a different node', () => { return waitForWantlistKey(ipfsA, key, { peerId: ipfsB.peerId.id }) }) @@ -49,7 +49,7 @@ module.exports = (createCommon, options) => { 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() }) }) } From 9090b942961391f6615a9ccfc530cedaac9ecd8b Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 6 Dec 2019 16:05:57 +0000 Subject: [PATCH 03/15] chore: downgrade peer-id dep --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b930b3491..b28480745 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "p-timeout": "^3.2.0", "p-times": "^2.1.0", "p-whilst": "^2.1.0", - "peer-id": "~0.13.5", + "peer-id": "^0.12.3", "peer-info": "~0.15.0", "pull-stream": "^3.6.11", "pull-to-promise": "^1.0.1", From e9e807b889c5378acc1ea357a14b35451a482f44 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 6 Dec 2019 16:32:13 +0000 Subject: [PATCH 04/15] fix: promisify callback method --- src/name-pubsub/cancel.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/name-pubsub/cancel.js b/src/name-pubsub/cancel.js index d0f468c00..e11c049a7 100644 --- a/src/name-pubsub/cancel.js +++ b/src/name-pubsub/cancel.js @@ -2,6 +2,7 @@ 'use strict' const PeerId = require('peer-id') +const promisify = require('es6-promisify') const { getDescribe, getIt, expect } = require('../utils/mocha') @@ -37,7 +38,7 @@ module.exports = (createCommon, options) => { it('should cancel a subscription correctly returning true', async function () { this.timeout(300 * 1000) - const peerId = await PeerId.create({ bits: 512 }) + const peerId = await promisify(PeerId.create)({ bits: 512 }) const id = peerId.toB58String() const ipnsPath = `/ipns/${id}` From 9a6c49b449d0f6465ff65e824f8210cbaf070e5d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 6 Dec 2019 17:05:36 +0000 Subject: [PATCH 05/15] fix: use proper promisify export --- src/name-pubsub/cancel.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/name-pubsub/cancel.js b/src/name-pubsub/cancel.js index e11c049a7..2a887ca17 100644 --- a/src/name-pubsub/cancel.js +++ b/src/name-pubsub/cancel.js @@ -2,7 +2,7 @@ 'use strict' const PeerId = require('peer-id') -const promisify = require('es6-promisify') +const { promisify } = require('es6-promisify') const { getDescribe, getIt, expect } = require('../utils/mocha') @@ -38,8 +38,7 @@ module.exports = (createCommon, options) => { it('should cancel a subscription correctly returning true', async function () { this.timeout(300 * 1000) - const peerId = await promisify(PeerId.create)({ bits: 512 }) - + const peerId = await promisify(PeerId.create.bind(PeerId))({ bits: 512 }) const id = peerId.toB58String() const ipnsPath = `/ipns/${id}` From e59b971becc4b328d698d1c160ce89d8c9db6a2e Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 6 Dec 2019 18:27:32 +0000 Subject: [PATCH 06/15] chore: control peer id/info versions --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 20f7b01ea..0e774e250 100644 --- a/package.json +++ b/package.json @@ -66,8 +66,8 @@ "p-timeout": "^3.2.0", "p-times": "^2.1.0", "p-whilst": "^2.1.0", - "peer-id": "^0.12.3", - "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", From ff434003cf298774e2e5d26dc56d92cbbc6e93d7 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 6 Dec 2019 18:32:00 +0000 Subject: [PATCH 07/15] chore: increase timeout for bitswap tests --- src/bitswap/wantlist.js | 2 ++ src/miscellaneous/resolve.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bitswap/wantlist.js b/src/bitswap/wantlist.js index cf311ccc2..6b5d71c01 100644 --- a/src/bitswap/wantlist.js +++ b/src/bitswap/wantlist.js @@ -35,10 +35,12 @@ module.exports = (createCommon, options) => { }) it('should get the wantlist', () => { + this.timeout(60 * 1000) return waitForWantlistKey(ipfsB, key) }) it('should get the wantlist by peer ID for a different node', () => { + this.timeout(60 * 1000) return waitForWantlistKey(ipfsA, key, { peerId: ipfsB.peerId.id }) }) diff --git a/src/miscellaneous/resolve.js b/src/miscellaneous/resolve.js index d883b4600..b77463aed 100644 --- a/src/miscellaneous/resolve.js +++ b/src/miscellaneous/resolve.js @@ -75,7 +75,7 @@ module.exports = (createCommon, options) => { expect(isIpfs.ipfsPath(resolved)).to.be.true() }) - it('should resolve IPNS link recursively', async function () { + it.only('should resolve IPNS link recursively', async function () { this.timeout(20 * 1000) const node = await common.setup() From a005ddf45aad1edf1859db806ed2e4aff5a18942 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 6 Dec 2019 18:41:06 +0000 Subject: [PATCH 08/15] fix: remove .only --- src/miscellaneous/resolve.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miscellaneous/resolve.js b/src/miscellaneous/resolve.js index b77463aed..d883b4600 100644 --- a/src/miscellaneous/resolve.js +++ b/src/miscellaneous/resolve.js @@ -75,7 +75,7 @@ module.exports = (createCommon, options) => { expect(isIpfs.ipfsPath(resolved)).to.be.true() }) - it.only('should resolve IPNS link recursively', async function () { + it('should resolve IPNS link recursively', async function () { this.timeout(20 * 1000) const node = await common.setup() From 2e76e46e8ce6bb4608679a5eac06ffc7a53a58b9 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Sat, 7 Dec 2019 07:34:44 +0000 Subject: [PATCH 09/15] fix: swap arrow for function --- src/bitswap/wantlist.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitswap/wantlist.js b/src/bitswap/wantlist.js index 6b5d71c01..494239ea1 100644 --- a/src/bitswap/wantlist.js +++ b/src/bitswap/wantlist.js @@ -34,12 +34,12 @@ module.exports = (createCommon, options) => { 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 different node', () => { + 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 }) }) From 2db34f8afd039c190f1845cdb755fde2b06a0f36 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 9 Dec 2019 11:37:03 +0000 Subject: [PATCH 10/15] fix: remove the setup of extra nodes We previously set this node up and attempted to dial it without a relay node being present which failed and we accidentally-on-purpose ignored the error by resolving a promise with an error instead of rejecting it. The test does not assert anything to do with the other node, and the `allowOffline` option should allow us to publish IPNS names without having any peers so the other node is redundant and can be removed. --- src/miscellaneous/resolve.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/miscellaneous/resolve.js b/src/miscellaneous/resolve.js index d883b4600..17a5bc3e6 100644 --- a/src/miscellaneous/resolve.js +++ b/src/miscellaneous/resolve.js @@ -78,9 +78,6 @@ module.exports = (createCommon, options) => { it('should resolve IPNS link recursively', async function () { this.timeout(20 * 1000) - const node = await common.setup() - await ipfs.swarm.connect(node.peerId.addresses.find((a) => a.includes('127.0.0.1'))) - const [{ path }] = await ipfs.add(Buffer.from('should resolve a record recursive === true')) const { id: keyId } = await ipfs.key.gen('key-name', { type: 'rsa', size: 2048 }) From 890b021c7fa12b6a42fc8bbe8128b6469174a00b Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 9 Dec 2019 12:24:52 +0000 Subject: [PATCH 11/15] fix: increase timeout for want list wait --- src/bitswap/wantlist.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bitswap/wantlist.js b/src/bitswap/wantlist.js index 494239ea1..63ca125d7 100644 --- a/src/bitswap/wantlist.js +++ b/src/bitswap/wantlist.js @@ -41,7 +41,10 @@ module.exports = (createCommon, options) => { 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 }) + return waitForWantlistKey(ipfsA, key, { + peerId: ipfsB.peerId.id, + timeout: 60 * 1000 + }) }) it('should not get the wantlist when offline', async function () { From 6881e7274fb8c0e91eceeeaf862d7de3dffc4281 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 9 Dec 2019 15:23:21 +0000 Subject: [PATCH 12/15] fix: simpler wait for want list --- package.json | 1 - src/bitswap/utils.js | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 0e774e250..09fb86103 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,6 @@ "p-map-series": "^2.1.0", "p-timeout": "^3.2.0", "p-times": "^2.1.0", - "p-whilst": "^2.1.0", "peer-id": "~0.12.2", "peer-info": "~0.15.1", "pull-stream": "^3.6.11", diff --git a/src/bitswap/utils.js b/src/bitswap/utils.js index d2b0cd11e..1c9be3bef 100644 --- a/src/bitswap/utils.js +++ b/src/bitswap/utils.js @@ -1,24 +1,23 @@ '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 - - let list = { Keys: [] } - const start = Date.now() - const findKey = () => !list.Keys.some(k => k['/'] === key) + const end = start + opts.timeout + + while (Date.now() < end) { + const list = await ipfs.bitswap.wantlist(opts.peerId) - const iteratee = async () => { - if (Date.now() - start > opts.timeout) { - throw new Error(`Timed out waiting for ${key} in wantlist`) + if (list.Keys.some(k => k['/'] === key)) { + return } - list = await ipfs.bitswap.wantlist(opts.peerId) + delay(500) } - return pWhilst(findKey, iteratee) + throw new Error(`Timed out waiting for ${key} in wantlist`) } module.exports.waitForWantlistKey = waitForWantlistKey From 1e96e37d02986e96ab771804a781b4b5624c5a13 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 9 Dec 2019 15:37:43 +0000 Subject: [PATCH 13/15] fix: await delay --- src/bitswap/utils.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bitswap/utils.js b/src/bitswap/utils.js index 1c9be3bef..558fc5f11 100644 --- a/src/bitswap/utils.js +++ b/src/bitswap/utils.js @@ -4,8 +4,7 @@ const delay = require('delay') async function waitForWantlistKey (ipfs, key, opts = {}) { opts.timeout = opts.timeout || 10000 - const start = Date.now() - const end = start + opts.timeout + const end = Date.now() + opts.timeout while (Date.now() < end) { const list = await ipfs.bitswap.wantlist(opts.peerId) @@ -14,7 +13,7 @@ async function waitForWantlistKey (ipfs, key, opts = {}) { return } - delay(500) + await delay(500) } throw new Error(`Timed out waiting for ${key} in wantlist`) From 728ef5f6e61caf28a79ec663054d29f3889fea09 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 9 Dec 2019 16:28:34 +0000 Subject: [PATCH 14/15] chore: guard on list.Keys being set --- src/bitswap/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitswap/utils.js b/src/bitswap/utils.js index 558fc5f11..7e6ae646a 100644 --- a/src/bitswap/utils.js +++ b/src/bitswap/utils.js @@ -9,7 +9,7 @@ async function waitForWantlistKey (ipfs, key, opts = {}) { while (Date.now() < end) { const list = await ipfs.bitswap.wantlist(opts.peerId) - if (list.Keys.some(k => k['/'] === key)) { + if (list && list.Keys && list.Keys.some(k => k['/'] === key)) { return } From c0967bc165df5242fea987ec921ab8466ce4ecba Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 9 Dec 2019 17:33:38 +0000 Subject: [PATCH 15/15] fix: start the other node for go-ipfs only --- src/miscellaneous/resolve.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/miscellaneous/resolve.js b/src/miscellaneous/resolve.js index 17a5bc3e6..6eb65819d 100644 --- a/src/miscellaneous/resolve.js +++ b/src/miscellaneous/resolve.js @@ -78,6 +78,15 @@ module.exports = (createCommon, options) => { it('should resolve IPNS link recursively', async function () { this.timeout(20 * 1000) + // Ensure another node exists for publishing to - only required by go-ipfs + if (ipfs.peerId.agentVersion.includes('go-ipfs')) { + const node = await common.setup() + + // this fails in the browser because there is no relay node available to connect the two + // nodes, but we only need this for go-ipfs as it doesn't support the `allowOffline` flag yet + await ipfs.swarm.connect(node.peerId.addresses.find((a) => a.includes('127.0.0.1'))) + } + const [{ path }] = await ipfs.add(Buffer.from('should resolve a record recursive === true')) const { id: keyId } = await ipfs.key.gen('key-name', { type: 'rsa', size: 2048 })