This repository was archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathmiscellaneous.js
107 lines (94 loc) · 2.68 KB
/
miscellaneous.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
module.exports = (common) => {
describe('.miscellaneous', () => {
let ipfs
let withGo
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()
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfs = node
ipfs.id((err, id) => {
expect(err).to.not.exist()
withGo = id.agentVersion.startsWith('go-ipfs')
done()
})
})
})
})
after((done) => {
common.teardown(done)
})
it('.id', (done) => {
ipfs.id((err, res) => {
expect(err).to.not.exist()
expect(res).to.have.a.property('id')
expect(res).to.have.a.property('publicKey')
done()
})
})
it('.version', (done) => {
ipfs.version((err, result) => {
expect(err).to.not.exist()
expect(result).to.have.a.property('version')
expect(result).to.have.a.property('commit')
expect(result).to.have.a.property('repo')
done()
})
})
it('.dns', (done) => {
ipfs.dns('ipfs.io', (err, path) => {
expect(err).to.not.exist()
expect(path).to.exist()
done()
})
})
it('.id Promises support', () => {
return ipfs.id()
.then((res) => {
expect(res).to.have.a.property('id')
expect(res).to.have.a.property('publicKey')
})
})
it('.version Promises support', () => {
return ipfs.version()
.then((result) => {
expect(result).to.have.a.property('version')
expect(result).to.have.a.property('commit')
expect(result).to.have.a.property('repo')
})
})
it('.dns Promises support', () => {
return ipfs.dns('ipfs.io')
.then((res) => {
expect(res).to.exist()
})
})
// must be last test to run
it('.stop', function (done) {
this.timeout(10 * 1000)
ipfs.stop((err) => {
// TODO: go-ipfs returns an error, https://github.com/ipfs/go-ipfs/issues/4078
if (!withGo) {
expect(err).to.not.exist()
}
// Trying to stop an already stopped node should return an error
// as the node can't respond to requests anymore
ipfs.stop((err) => {
expect(err).to.exist()
done()
})
})
})
})
}