forked from ipfs/js-ipfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.js
209 lines (183 loc) · 4.9 KB
/
interface.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/* eslint-env mocha */
'use strict'
const tests = require('interface-ipfs-core')
const CommonFactory = require('../utils/interface-common-factory')
const path = require('path')
describe('interface-ipfs-core over ipfs-http-client tests', () => {
const defaultCommonFactory = CommonFactory.create({
factoryOptions: { exec: path.resolve(`${__dirname}/../../src/cli/bin.js`) }
})
tests.bitswap(defaultCommonFactory)
tests.block(defaultCommonFactory)
tests.bootstrap(defaultCommonFactory)
tests.config(defaultCommonFactory, {
skip: [
{
name: 'should set a number',
reason: 'Failing - needs to be fixed'
},
{
name: 'should output changes but not save them for dry run',
reason: 'TODO unskip when https://github.com/ipfs/js-ipfs/pull/2165 is merged'
},
{
name: 'should set a config profile',
reason: 'TODO unskip when https://github.com/ipfs/js-ipfs/pull/2165 is merged'
}
]
})
tests.dag(defaultCommonFactory, {
skip: [{
name: 'should get only a CID, due to resolving locally only',
reason: 'Local resolve option is not implemented yet'
}, {
name: 'tree',
reason: 'dag.tree is not implemented yet'
}]
})
tests.dht(CommonFactory.create({
spawnOptions: {
initOptions: { bits: 512 },
config: {
Bootstrap: [],
Discovery: {
MDNS: {
Enabled: false
},
webRTCStar: {
Enabled: false
}
}
},
preload: { enabled: false }
}
}), {
skip: {
reason: 'TODO: unskip when DHT is enabled in 0.36'
}
})
tests.filesRegular(defaultCommonFactory)
tests.filesMFS(defaultCommonFactory)
tests.key(CommonFactory.create({
spawnOptions: {
args: ['--pass ipfs-is-awesome-software'],
initOptions: { bits: 512 },
config: {
Bootstrap: [],
Discovery: {
MDNS: {
Enabled: false
},
webRTCStar: {
Enabled: false
}
}
},
preload: { enabled: false }
}
}))
tests.miscellaneous(CommonFactory.create({
// No need to stop, because the test suite does a 'stop' test.
createTeardown: () => cb => cb()
}), {
skip: [
{
name: 'should resolve an IPNS DNS link',
reason: 'TODO: IPNS resolve not yet implemented https://github.com/ipfs/js-ipfs/issues/1918'
},
{
name: 'should resolve IPNS link recursively',
reason: 'TODO: IPNS resolve not yet implemented https://github.com/ipfs/js-ipfs/issues/1918'
},
{
name: 'should recursively resolve ipfs.io',
reason: 'TODO: ipfs.io dnslink=/ipns/website.ipfs.io & IPNS resolve not yet implemented https://github.com/ipfs/js-ipfs/issues/1918'
}
]
})
tests.name(CommonFactory.create({
spawnOptions: {
args: ['--pass ipfs-is-awesome-software', '--offline']
}
}))
tests.namePubsub(CommonFactory.create({
spawnOptions: {
args: ['--enable-namesys-pubsub'],
initOptions: { bits: 1024 },
config: {
Bootstrap: [],
Discovery: {
MDNS: {
Enabled: false
},
webRTCStar: {
Enabled: false
}
}
}
}
}))
tests.object(defaultCommonFactory, {
skip: [
{
name: 'should respect timeout option',
reason: 'js-ipfs doesn\'t support timeout yet'
}
]
})
tests.pin(defaultCommonFactory)
tests.ping(defaultCommonFactory)
tests.pubsub(CommonFactory.create({
spawnOptions: {
args: ['--enable-pubsub-experiment'],
initOptions: { bits: 512 }
}
}))
tests.repo(defaultCommonFactory, {
skip: [
// repo.gc
{
name: 'gc',
reason: 'TODO: repo.gc is not implemented in js-ipfs yet!'
}
]
})
tests.stats(defaultCommonFactory)
tests.swarm(CommonFactory.create({
createSetup ({ ipfsFactory, nodes }) {
return callback => {
callback(null, {
spawnNode (repoPath, config, cb) {
if (typeof repoPath === 'function') {
cb = repoPath
repoPath = undefined
}
if (typeof config === 'function') {
cb = config
config = undefined
}
config = config || {
Bootstrap: [],
Discovery: {
MDNS: {
Enabled: false
},
webRTCStar: {
Enabled: false
}
}
}
const spawnOptions = { repoPath, config, initOptions: { bits: 512 } }
ipfsFactory.spawn(spawnOptions, (err, _ipfsd) => {
if (err) {
return cb(err)
}
nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
}
}
}))
})