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

Commit af4dd75

Browse files
committed
feat: use the current ipfs-api
1 parent 01d7c16 commit af4dd75

16 files changed

+86
-52
lines changed

test/bitswap.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const dirtyChai = require('dirty-chai')
66
const expect = chai.expect
77
chai.use(dirtyChai)
88

9+
const IPFSApi = require('../src')
10+
911
const DaemonFactory = require('ipfsd-ctl')
1012
const df = DaemonFactory.create()
1113

@@ -16,10 +18,10 @@ describe('.bitswap', function () {
1618

1719
before((done) => {
1820
this.timeout(20 * 1000) // slow CI
19-
df.spawn((err, node) => {
21+
df.spawn((err, _ipfsd) => {
2022
expect(err).to.not.exist()
21-
ipfsd = node
22-
ipfs = node.api
23+
ipfsd = _ipfsd
24+
ipfs = IPFSApi(_ipfsd.apiAddr)
2325
done()
2426
})
2527
})

test/bootstrap.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const dirtyChai = require('dirty-chai')
77
const expect = chai.expect
88
chai.use(dirtyChai)
99

10+
const IPFSApi = require('../src')
11+
1012
const DaemonFactory = require('ipfsd-ctl')
1113
const df = DaemonFactory.create()
1214

@@ -20,10 +22,10 @@ describe('.bootstrap', function () {
2022
let ipfs
2123

2224
before((done) => {
23-
df.spawn((err, node) => {
25+
df.spawn((err, _ipfsd) => {
2426
expect(err).to.not.exist()
25-
ipfsd = node
26-
ipfs = node.api
27+
ipfsd = _ipfsd
28+
ipfs = IPFSApi(_ipfsd.apiAddr)
2729
done()
2830
})
2931
})

test/commands.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const dirtyChai = require('dirty-chai')
66
const expect = chai.expect
77
chai.use(dirtyChai)
88

9+
const IPFSApi = require('../src')
10+
911
const DaemonFactory = require('ipfsd-ctl')
1012
const df = DaemonFactory.create()
1113

@@ -16,10 +18,10 @@ describe('.commands', function () {
1618
let ipfs
1719

1820
before((done) => {
19-
df.spawn((err, node) => {
21+
df.spawn((err, _ipfsd) => {
2022
expect(err).to.not.exist()
21-
ipfsd = node
22-
ipfs = node.api
23+
ipfsd = _ipfsd
24+
ipfs = IPFSApi(_ipfsd.apiAddr)
2325
done()
2426
})
2527
})

test/diag.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const expect = chai.expect
77
chai.use(dirtyChai)
88
const os = require('os')
99

10+
const IPFSApi = require('../src')
11+
1012
const DaemonFactory = require('ipfsd-ctl')
1113
const df = DaemonFactory.create()
1214

@@ -22,10 +24,10 @@ describe('.diag', function () {
2224
let ipfs
2325

2426
before((done) => {
25-
df.spawn((err, node) => {
27+
df.spawn((err, _ipfsd) => {
2628
expect(err).to.not.exist()
27-
ipfsd = node
28-
ipfs = node.api
29+
ipfsd = _ipfsd
30+
ipfs = IPFSApi(_ipfsd.apiAddr)
2931
done()
3032
})
3133
})

test/files.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const loadFixture = require('aegir/fixtures')
1111
const mh = require('multihashes')
1212
const CID = require('cids')
1313

14+
const IPFSApi = require('../src')
15+
1416
const DaemonFactory = require('ipfsd-ctl')
1517
const df = DaemonFactory.create()
1618

@@ -39,10 +41,10 @@ describe('.files (the MFS API part)', function () {
3941
const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
4042

4143
before((done) => {
42-
df.spawn((err, node) => {
44+
df.spawn((err, _ipfsd) => {
4345
expect(err).to.not.exist()
44-
ipfsd = node
45-
ipfs = node.api
46+
ipfsd = _ipfsd
47+
ipfs = IPFSApi(_ipfsd.apiAddr)
4648
done()
4749
})
4850
})

test/fixtures/test-folder/hello-link

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/fixtures/test-folder/hello-link

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
files/hello.txt

test/get.spec.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const isNode = require('detect-node')
1111
const series = require('async/series')
1212
const loadFixture = require('aegir/fixtures')
1313

14+
const IPFSApi = require('../src')
15+
1416
const DaemonFactory = require('ipfsd-ctl')
1517
const df = DaemonFactory.create()
1618

@@ -31,13 +33,13 @@ describe('.get (specific go-ipfs features)', function () {
3133

3234
before((done) => {
3335
series([
34-
(cb) => df.spawn((err, node) => {
36+
(cb) => df.spawn((err, _ipfsd) => {
3537
expect(err).to.not.exist()
36-
ipfsd = node
37-
ipfs = node.api
38+
ipfsd = _ipfsd
39+
ipfs = IPFSApi(_ipfsd.apiAddr)
3840
cb()
3941
}),
40-
(cb) => ipfsd.api.files.add(smallFile.data, cb)
42+
(cb) => ipfs.files.add(smallFile.data, cb)
4143
], done)
4244
})
4345

@@ -79,7 +81,9 @@ describe('.get (specific go-ipfs features)', function () {
7981
})
8082

8183
it('add path containing "+"s (for testing get)', (done) => {
82-
if (!isNode) { return done() }
84+
if (!isNode) {
85+
return done()
86+
}
8387

8488
const filename = 'ti,c64x+mega++mod-pic.txt'
8589
const subdir = 'tmp/c++files'
@@ -95,7 +99,9 @@ describe('.get (specific go-ipfs features)', function () {
9599
})
96100

97101
it('get path containing "+"s', (done) => {
98-
if (!isNode) { return done() }
102+
if (!isNode) {
103+
return done()
104+
}
99105

100106
const cid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff'
101107
let count = 0

test/key.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const dirtyChai = require('dirty-chai')
77
const expect = chai.expect
88
chai.use(dirtyChai)
99

10+
const IPFSApi = require('../src')
11+
1012
const DaemonFactory = require('ipfsd-ctl')
1113
const df = DaemonFactory.create()
1214

@@ -17,10 +19,10 @@ describe('.key', function () {
1719
let ipfs
1820

1921
before((done) => {
20-
df.spawn((err, node) => {
22+
df.spawn((err, _ipfsd) => {
2123
expect(err).to.not.exist()
22-
ipfsd = node
23-
ipfs = node.api
24+
ipfsd = _ipfsd
25+
ipfs = IPFSApi(_ipfsd.apiAddr)
2426
done()
2527
})
2628
})
@@ -61,13 +63,13 @@ describe('.key', function () {
6163
describe('Promise API', () => {
6264
describe('.gen', () => {
6365
it('create a new rsa key', () => {
64-
return ipfs.key.gen('foobarsa2', {type: 'rsa', size: 2048}).then((res) => {
66+
return ipfs.key.gen('foobarsa2', { type: 'rsa', size: 2048 }).then((res) => {
6567
expect(res).to.exist()
6668
})
6769
})
6870

6971
it('create a new ed25519 key', () => {
70-
return ipfs.key.gen('bazed2', {type: 'ed25519'}).then((res) => {
72+
return ipfs.key.gen('bazed2', { type: 'ed25519' }).then((res) => {
7173
expect(res).to.exist()
7274
})
7375
})

test/log.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const dirtyChai = require('dirty-chai')
77
const expect = chai.expect
88
chai.use(dirtyChai)
99

10+
const IPFSApi = require('../src')
11+
1012
const DaemonFactory = require('ipfsd-ctl')
1113
const df = DaemonFactory.create()
1214

@@ -17,10 +19,10 @@ describe('.log', function () {
1719
let ipfs
1820

1921
before((done) => {
20-
df.spawn((err, node) => {
22+
df.spawn((err, _ipfsd) => {
2123
expect(err).to.not.exist()
22-
ipfsd = node
23-
ipfs = node.api
24+
ipfsd = _ipfsd
25+
ipfs = IPFSApi(_ipfsd.apiAddr)
2426
done()
2527
})
2628
})

test/name.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const isNode = require('detect-node')
1111
const series = require('async/series')
1212
const loadFixture = require('aegir/fixtures')
1313

14+
const IPFSApi = require('../src')
15+
1416
const DaemonFactory = require('ipfsd-ctl')
1517
const df = DaemonFactory.create()
1618

@@ -29,10 +31,10 @@ describe('.name', function () {
2931
before((done) => {
3032
series([
3133
(cb) => {
32-
df.spawn((err, node) => {
34+
df.spawn((err, _ipfsd) => {
3335
expect(err).to.not.exist()
34-
ipfsd = node
35-
ipfs = node.api
36+
ipfsd = _ipfsd
37+
ipfs = IPFSApi(_ipfsd.apiAddr)
3638
cb()
3739
})
3840
},

test/ping.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ chai.use(dirtyChai)
99
const parallel = require('async/parallel')
1010
const series = require('async/series')
1111

12+
const IPFSApi = require('../src')
13+
1214
const DaemonFactory = require('ipfsd-ctl')
1315
const df = DaemonFactory.create()
1416

@@ -22,10 +24,10 @@ describe.skip('.ping', () => {
2224
this.timeout(20 * 1000) // slow CI
2325
series([
2426
(cb) => {
25-
df.spawn((err, node) => {
27+
df.spawn((err, _ipfsd) => {
2628
expect(err).to.not.exist()
27-
ipfsd = node
28-
ipfs = node.api
29+
ipfsd = _ipfsd
30+
ipfs = IPFSApi(_ipfsd.apiAddr)
2931
cb()
3032
})
3133
},

test/pubsub-in-browser.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const dirtyChai = require('dirty-chai')
3232
const expect = chai.expect
3333
chai.use(dirtyChai)
3434

35+
const IPFSApi = require('../src')
36+
3537
const DaemonFactory = require('ipfsd-ctl')
3638
const df = DaemonFactory.create()
3739

@@ -50,10 +52,10 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun
5052
let ipfsd
5153

5254
before((done) => {
53-
df.spawn((err, node) => {
55+
df.spawn((err, _ipfsd) => {
5456
expect(err).to.not.exist()
55-
ipfs = node.api
56-
ipfsd = node
57+
ipfs = _ipfsd.api
58+
ipfs = IPFSApi(_ipfsd.apiAddr)
5759
done()
5860
})
5961
})

test/refs.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const waterfall = require('async/waterfall')
1010
const path = require('path')
1111
const fs = require('fs')
1212

13+
const IPFSApi = require('../src')
14+
1315
const DaemonFactory = require('ipfsd-ctl')
1416
const df = DaemonFactory.create()
1517

@@ -38,10 +40,10 @@ describe('.refs', function () {
3840

3941
waterfall([
4042
(cb) => df.spawn(cb),
41-
(node, cb) => {
42-
ipfsd = node
43-
ipfs = node.api
44-
ipfsd.api.util.addFromFs(filesPath, { recursive: true }, cb)
43+
(_ipfsd, cb) => {
44+
ipfsd = _ipfsd
45+
ipfs = IPFSApi(_ipfsd.apiAddr)
46+
ipfs.util.addFromFs(filesPath, { recursive: true }, cb)
4547
},
4648
(hashes, cb) => {
4749
folder = hashes[hashes.length - 1].hash
@@ -90,7 +92,7 @@ describe('.refs', function () {
9092

9193
describe('Promise API', () => {
9294
it('refs', () => {
93-
return ipfs.refs(folder, {format: '<src> <dst> <linkname>'})
95+
return ipfs.refs(folder, { format: '<src> <dst> <linkname>' })
9496
.then((objs) => {
9597
expect(objs).to.eql(result)
9698
})

test/repo.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const dirtyChai = require('dirty-chai')
66
const expect = chai.expect
77
chai.use(dirtyChai)
88

9+
const IPFSApi = require('../src')
10+
911
const DaemonFactory = require('ipfsd-ctl')
1012
const df = DaemonFactory.create()
1113

@@ -16,10 +18,10 @@ describe('.repo', function () {
1618
let ipfsd
1719

1820
before((done) => {
19-
df.spawn((err, node) => {
21+
df.spawn((err, _ipfsd) => {
2022
expect(err).to.not.exist()
21-
ipfsd = node
22-
ipfs = node.api
23+
ipfsd = _ipfsd
24+
ipfs = IPFSApi(_ipfsd.apiAddr)
2325
done()
2426
})
2527
})

test/stats.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const dirtyChai = require('dirty-chai')
66
const expect = chai.expect
77
chai.use(dirtyChai)
88

9+
const IPFSApi = require('../src')
10+
911
const DaemonFactory = require('ipfsd-ctl')
1012
const df = DaemonFactory.create()
1113

@@ -16,10 +18,10 @@ describe('stats', function () {
1618
let ipfsd
1719

1820
before((done) => {
19-
df.spawn((err, node) => {
21+
df.spawn((err, _ipfsd) => {
2022
expect(err).to.not.exist()
21-
ipfsd = node
22-
ipfs = node.api
23+
ipfsd = _ipfsd
24+
ipfs = IPFSApi(_ipfsd.apiAddr)
2325
done()
2426
})
2527
})

0 commit comments

Comments
 (0)