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

chore: async await refactor #562

Merged
merged 45 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2fb718c
chore: bitswap async/await refactor
Nov 20, 2019
14aa336
chore: block async/await refactor
Nov 20, 2019
a22f248
chore: bootstrap async/await refactor
Nov 20, 2019
70f8bc7
chore: config async/await refactor
Nov 20, 2019
fd72f40
chore: dag async/await refactor
Nov 20, 2019
a2c6b12
chore: dht async/await refactor
Nov 20, 2019
8bc5fc9
chore: files-mfs async/await refactor
Nov 20, 2019
2154ebe
chore: files-regular async/await refactor
Nov 20, 2019
7e4eabc
chore: key async/await refactor
Nov 20, 2019
1f810f9
chore: miscellaneous async/await refactor
Nov 20, 2019
7ba7a2d
chore: name-pubsub async/await refactor
Nov 20, 2019
6a4c1bb
chore: name async/await refactor
Nov 20, 2019
3910b68
chore: object async/await refactor
Nov 20, 2019
f8caf5c
chore: pin async/await refactor
Nov 20, 2019
b49666b
chore: ping async/await refactor
Nov 20, 2019
3c9610c
chore: pubsub async/await refactor
Nov 20, 2019
08c455d
chore: repo async/await refactor
Nov 20, 2019
143a2c4
chore: stats async/await refactor
Nov 20, 2019
6d4d5bb
chore: swarm async/await refactor
Nov 20, 2019
abe108d
chore: remove unnecessary util file
Nov 20, 2019
e242e09
chore: update dependencies
Nov 20, 2019
3fd2a8b
refactor: remove async dep and unnecessary utils
Nov 22, 2019
79e4e6b
refactor: bitswap before and after methods to async syntax
Nov 22, 2019
571b35b
refactor: block before and after methods to async syntax
Nov 22, 2019
20e842b
refactor: bootstrap before and after methods to async syntax
Nov 22, 2019
444c6a5
refactor: config before and after methods to async syntax
Nov 22, 2019
ba18c86
refactor: dag before and after methods to async syntax
Nov 22, 2019
bc7dcef
refactor: dht before and after methods to async syntax
Nov 22, 2019
50eabf6
refactor: files-mfs before and after methods to async syntax
Nov 22, 2019
4172720
refactor: files-regular before and after methods to async syntax
Nov 22, 2019
dd446e8
refactor: key before and after methods to async syntax
Nov 22, 2019
1cb16c8
refactor: miscellaneous before and after methods to async syntax
Nov 22, 2019
3f95aab
refactor: name before and after methods to async syntax
Nov 22, 2019
03b5d6f
refactor: name-pubsub before and after methods to async syntax
Nov 22, 2019
187c89e
refactor: object before and after methods to async syntax
Nov 22, 2019
cb07f73
refactor: pin before and after methods to async syntax
Nov 22, 2019
9953c7f
refactor: ping before and after methods to async syntax
Nov 22, 2019
4479df9
refactor: pubsub before and after methods to async syntax
Nov 22, 2019
25a99bf
refactor: repo before and after methods to async syntax
Nov 22, 2019
f00b03d
refactor: stats before and after methods to async syntax
Nov 22, 2019
514ffed
chore: remove 'only' from files-mfs/cp
Nov 22, 2019
a0c1e6a
chore: uncomment bootstrap rm test assertion
Nov 22, 2019
f3a8224
refactor: name resolve test
Nov 22, 2019
2720e57
fix: increase dht findProvs test timeout
Nov 24, 2019
2aaff5e
fix: miscellaneous stop test
Nov 26, 2019
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
Prev Previous commit
Next Next commit
refactor: dht before and after methods to async syntax
  • Loading branch information
Pedro Santos committed Nov 22, 2019
commit bc7dcef48d5541ff51a33e163a1bbc493816be4b
29 changes: 5 additions & 24 deletions src/dht/find-peer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* eslint-env mocha */
'use strict'

const { spawnNodesWithId } = require('../utils/spawn')
const { getDescribe, getIt, expect } = require('../utils/mocha')
const { connect } = require('../utils/swarm')

module.exports = (createCommon, options) => {
const describe = getDescribe(options)
Expand All @@ -16,30 +14,13 @@ module.exports = (createCommon, options) => {
let nodeA
let nodeB

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

common.setup((err, factory) => {
expect(err).to.not.exist()

spawnNodesWithId(2, factory, (err, nodes) => {
expect(err).to.not.exist()

nodeA = nodes[0]
nodeB = nodes[1]

connect(nodeB, nodeA.peerId.addresses[0], done)
})
})
before(async () => {
nodeA = await common.setup()
nodeB = await common.setup()
await nodeB.swarm.connect(nodeA.peerId.addresses[0])
})

after(function (done) {
this.timeout(50 * 1000)

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

it('should find other peers', async () => {
const res = await nodeA.dht.findPeer(nodeB.peerId.id)
Expand Down
34 changes: 10 additions & 24 deletions src/dht/find-provs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
'use strict'

const multihashing = require('multihashing-async')
const parallel = require('async/parallel')
const CID = require('cids')
const { spawnNodesWithId } = require('../utils/spawn')
const { getDescribe, getIt, expect } = require('../utils/mocha')
const { connect } = require('../utils/swarm')

async function fakeCid () {
const bytes = Buffer.from(`TEST${Date.now()}`)
Expand All @@ -26,29 +23,18 @@ module.exports = (createCommon, options) => {
let nodeB
let nodeC

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

common.setup((err, factory) => {
expect(err).to.not.exist()

spawnNodesWithId(3, factory, (err, nodes) => {
expect(err).to.not.exist()

nodeA = nodes[0]
nodeB = nodes[1]
nodeC = nodes[2]

parallel([
(cb) => connect(nodeB, nodeA.peerId.addresses[0], cb),
(cb) => connect(nodeC, nodeB.peerId.addresses[0], cb)
], done)
})
})
before(async () => {
nodeA = await common.setup()
nodeB = await common.setup()
nodeC = await common.setup()
await Promise.all([
nodeB.swarm.connect(nodeA.peerId.addresses[0]),
nodeC.swarm.connect(nodeB.peerId.addresses[0])
])
})

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

let providedCid
before('add providers for the same cid', async function () {
const cids = await Promise.all([
Expand Down
29 changes: 5 additions & 24 deletions src/dht/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
'use strict'

const hat = require('hat')
const { spawnNodesWithId } = require('../utils/spawn')
const { getDescribe, getIt, expect } = require('../utils/mocha')
const { connect } = require('../utils/swarm')

module.exports = (createCommon, options) => {
const describe = getDescribe(options)
Expand All @@ -17,30 +15,13 @@ module.exports = (createCommon, options) => {
let nodeA
let nodeB

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

common.setup((err, factory) => {
expect(err).to.not.exist()

spawnNodesWithId(2, factory, (err, nodes) => {
expect(err).to.not.exist()

nodeA = nodes[0]
nodeB = nodes[1]

connect(nodeA, nodeB.peerId.addresses[0], done)
})
})
before(async () => {
nodeA = await common.setup()
nodeB = await common.setup()
await nodeA.swarm.connect(nodeB.peerId.addresses[0])
})

after(function (done) {
this.timeout(50 * 1000)

common.teardown(done)
})
after(() => 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
Expand Down
26 changes: 5 additions & 21 deletions src/dht/provide.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
'use strict'

const CID = require('cids')
const { spawnNodesWithId } = require('../utils/spawn')
const { getDescribe, getIt, expect } = require('../utils/mocha')
const { connect } = require('../utils/swarm')

module.exports = (createCommon, options) => {
const describe = getDescribe(options)
Expand All @@ -16,27 +14,13 @@ module.exports = (createCommon, options) => {

let ipfs

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

common.setup((err, factory) => {
expect(err).to.not.exist()

spawnNodesWithId(2, factory, (err, nodes) => {
expect(err).to.not.exist()
ipfs = nodes[0]
connect(ipfs, nodes[1].peerId.addresses[0], done)
})
})
before(async () => {
ipfs = await common.setup()
const nodeB = await common.setup()
await ipfs.swarm.connect(nodeB.peerId.addresses[0])
})

after(function (done) {
this.timeout(50 * 1000)

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

it('should provide local CID', async () => {
const res = await ipfs.add(Buffer.from('test'))
Expand Down
26 changes: 6 additions & 20 deletions src/dht/put.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* eslint-env mocha */
'use strict'

const { spawnNodesWithId } = require('../utils/spawn')
const { getDescribe, getIt, expect } = require('../utils/mocha')
const { connect } = require('../utils/swarm')
const { getDescribe, getIt } = require('../utils/mocha')

module.exports = (createCommon, options) => {
const describe = getDescribe(options)
Expand All @@ -16,25 +14,13 @@ module.exports = (createCommon, options) => {
let nodeA
let nodeB

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

common.setup((err, factory) => {
expect(err).to.not.exist()

spawnNodesWithId(2, factory, (err, nodes) => {
expect(err).to.not.exist()

nodeA = nodes[0]
nodeB = nodes[1]
connect(nodeA, nodeB.peerId.addresses[0], done)
})
})
before(async () => {
nodeA = await common.setup()
nodeB = await common.setup()
await nodeA.swarm.connect(nodeB.peerId.addresses[0])
})

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

it('should put a value to the DHT', async () => {
const key = Buffer.from('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn')
Expand Down
29 changes: 5 additions & 24 deletions src/dht/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
'use strict'

const pTimeout = require('p-timeout')
const { spawnNodesWithId } = require('../utils/spawn')
const { getDescribe, getIt, expect } = require('../utils/mocha')
const { connect } = require('../utils/swarm')

module.exports = (createCommon, options) => {
const describe = getDescribe(options)
Expand All @@ -17,30 +15,13 @@ module.exports = (createCommon, options) => {
let nodeA
let nodeB

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

common.setup((err, factory) => {
expect(err).to.not.exist()

spawnNodesWithId(2, factory, (err, nodes) => {
expect(err).to.not.exist()

nodeA = nodes[0]
nodeB = nodes[1]

connect(nodeB, nodeA.peerId.addresses[0], done)
})
})
before(async () => {
nodeA = await common.setup()
nodeB = await common.setup()
await nodeB.swarm.connect(nodeA.peerId.addresses[0])
})

after(function (done) {
this.timeout(50 * 1000)

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

it('should return the other node in the query', async function () {
const timeout = 150 * 1000
Expand Down