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

Commit ba18c86

Browse files
author
Pedro Santos
committed
refactor: dag before and after methods to async syntax
1 parent 444c6a5 commit ba18c86

File tree

3 files changed

+12
-54
lines changed

3 files changed

+12
-54
lines changed

src/dag/get.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,20 @@ const DAGNode = dagPB.DAGNode
77
const dagCBOR = require('ipld-dag-cbor')
88
const Unixfs = require('ipfs-unixfs')
99
const CID = require('cids')
10-
const { spawnNodeWithId } = require('../utils/spawn')
1110
const { getDescribe, getIt, expect } = require('../utils/mocha')
1211

1312
module.exports = (createCommon, options) => {
1413
const describe = getDescribe(options)
1514
const it = getIt(options)
1615
const common = createCommon()
1716

18-
describe('.dag.get', () => {
17+
describe('.dag.get', function () {
18+
this.timeout(60 * 1000)
1919
let ipfs
2020

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

26-
common.setup((err, factory) => {
27-
expect(err).to.not.exist()
28-
29-
spawnNodeWithId(factory, (err, node) => {
30-
expect(err).to.not.exist()
31-
ipfs = node
32-
done()
33-
})
34-
})
35-
})
36-
37-
after((done) => common.teardown(done))
23+
after(() => common.teardown())
3824

3925
let pbNode
4026
let cborNode

src/dag/put.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,20 @@ const DAGNode = dagPB.DAGNode
66
const dagCBOR = require('ipld-dag-cbor')
77
const CID = require('cids')
88
const multihash = require('multihashes')
9-
const { spawnNodeWithId } = require('../utils/spawn')
109
const { getDescribe, getIt, expect } = require('../utils/mocha')
1110

1211
module.exports = (createCommon, options) => {
1312
const describe = getDescribe(options)
1413
const it = getIt(options)
1514
const common = createCommon()
1615

17-
describe('.dag.put', () => {
16+
describe('.dag.put', function () {
17+
this.timeout(60 * 1000)
1818
let ipfs
1919

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

25-
common.setup((err, factory) => {
26-
expect(err).to.not.exist()
27-
28-
spawnNodeWithId(factory, (err, node) => {
29-
expect(err).to.not.exist()
30-
ipfs = node
31-
done()
32-
})
33-
})
34-
})
35-
36-
after((done) => common.teardown(done))
22+
after(() => common.teardown())
3723

3824
let pbNode
3925
let cborNode

src/dag/tree.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,20 @@ const pEachSeries = require('p-each-series')
55
const dagPB = require('ipld-dag-pb')
66
const DAGNode = dagPB.DAGNode
77
const dagCBOR = require('ipld-dag-cbor')
8-
const { spawnNodeWithId } = require('../utils/spawn')
98
const { getDescribe, getIt, expect } = require('../utils/mocha')
109

1110
module.exports = (createCommon, options) => {
1211
const describe = getDescribe(options)
1312
const it = getIt(options)
1413
const common = createCommon()
1514

16-
describe('.dag.tree', () => {
15+
describe('.dag.tree', function () {
16+
this.timeout(60 * 1000)
1717
let ipfs
1818

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

24-
common.setup((err, factory) => {
25-
expect(err).to.not.exist()
26-
27-
spawnNodeWithId(factory, (err, node) => {
28-
expect(err).to.not.exist()
29-
ipfs = node
30-
done()
31-
})
32-
})
33-
})
34-
35-
after((done) => common.teardown(done))
21+
after(() => common.teardown())
3622

3723
let nodePb
3824
let nodeCbor

0 commit comments

Comments
 (0)