2
2
'use strict'
3
3
4
4
const tests = require ( 'interface-ipfs-core' )
5
- const isNode = require ( 'detect-node' )
6
- const CommonFactory = require ( './utils/interface-common-factory' )
5
+ const merge = require ( 'merge-options' )
6
+ const { isNode } = require ( 'ipfs-utils/src/env' )
7
+ const ctl = require ( 'ipfsd-ctl' )
7
8
const isWindows = process . platform && process . platform === 'win32'
8
9
9
10
describe ( 'interface-ipfs-core tests' , ( ) => {
10
- const defaultCommonFactory = CommonFactory . createAsync ( )
11
+ const commonOptions = {
12
+ factoryOptions : { IpfsClient : require ( '../src' ) }
13
+ }
14
+ const commonFactory = ctl . createTestsInterface ( commonOptions )
11
15
12
- tests . bitswap ( defaultCommonFactory , {
13
- skip : [
14
- // bitswap.stat
15
- {
16
- name : 'should not get bitswap stats when offline' ,
17
- reason : 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078'
18
- } ,
19
- // bitswap.wantlist
20
- {
21
- name : 'should not get the wantlist when offline' ,
22
- reason : 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078'
23
- } ,
24
- // bitswap.unwant
25
- {
26
- name : 'should remove a key from the wantlist' ,
27
- reason : 'FIXME why is this skipped?'
28
- } ,
29
- {
30
- name : 'should not remove a key from the wantlist when offline' ,
31
- reason : 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078'
32
- }
33
- ]
34
- } )
16
+ tests . bitswap ( commonFactory )
35
17
36
- tests . block ( defaultCommonFactory , {
18
+ tests . block ( commonFactory , {
37
19
skip : [ {
38
20
name : 'should get a block added as CIDv1 with a CIDv0' ,
39
21
reason : 'go-ipfs does not support the `version` param'
40
22
} ]
41
23
} )
42
24
43
- tests . bootstrap ( defaultCommonFactory )
25
+ tests . bootstrap ( commonFactory )
44
26
45
- tests . config ( defaultCommonFactory , {
27
+ tests . config ( commonFactory , {
46
28
skip : [
47
29
// config.replace
48
30
{
@@ -60,7 +42,7 @@ describe('interface-ipfs-core tests', () => {
60
42
]
61
43
} )
62
44
63
- tests . dag ( defaultCommonFactory , {
45
+ tests . dag ( commonFactory , {
64
46
skip : [
65
47
// dag.tree
66
48
{
@@ -87,7 +69,7 @@ describe('interface-ipfs-core tests', () => {
87
69
]
88
70
} )
89
71
90
- tests . dht ( defaultCommonFactory , {
72
+ tests . dht ( commonFactory , {
91
73
skip : [
92
74
// dht.findpeer
93
75
{
@@ -107,47 +89,47 @@ describe('interface-ipfs-core tests', () => {
107
89
]
108
90
} )
109
91
110
- tests . filesRegular ( defaultCommonFactory , {
92
+ tests . filesMFS ( commonFactory , {
111
93
skip : [
112
- // .addFromFs
113
- isNode ? null : {
114
- name : 'addFromFs' ,
115
- reason : 'Not designed to run in the browser'
116
- } ,
117
- // .catPullStream
118
94
{
119
- name : 'should export a chunk of a file ' ,
120
- reason : 'TODO not implemented in go-ipfs yet '
95
+ name : 'should ls directory with long option ' ,
96
+ reason : 'TODO unskip when go-ipfs supports --long https://github.com/ipfs/go-ipfs/pull/6528 '
121
97
} ,
122
98
{
123
- name : 'should export a chunk of a file in a Pull Stream ' ,
99
+ name : 'should read from outside of mfs ' ,
124
100
reason : 'TODO not implemented in go-ipfs yet'
125
101
} ,
126
102
{
127
- name : 'should export a chunk of a file in a Readable Stream ' ,
103
+ name : 'should ls from outside of mfs ' ,
128
104
reason : 'TODO not implemented in go-ipfs yet'
129
105
}
130
106
]
131
107
} )
132
108
133
- tests . filesMFS ( defaultCommonFactory , {
109
+ tests . filesRegular ( commonFactory , {
134
110
skip : [
111
+ // .addFromFs
112
+ isNode ? null : {
113
+ name : 'addFromFs' ,
114
+ reason : 'Not designed to run in the browser'
115
+ } ,
116
+ // .catPullStream
135
117
{
136
- name : 'should ls directory with long option ' ,
137
- reason : 'TODO unskip when go-ipfs supports --long https://github.com/ipfs/ go-ipfs/pull/6528 '
118
+ name : 'should export a chunk of a file ' ,
119
+ reason : 'TODO not implemented in go-ipfs yet '
138
120
} ,
139
121
{
140
- name : 'should read from outside of mfs ' ,
122
+ name : 'should export a chunk of a file in a Pull Stream ' ,
141
123
reason : 'TODO not implemented in go-ipfs yet'
142
124
} ,
143
125
{
144
- name : 'should ls from outside of mfs ' ,
126
+ name : 'should export a chunk of a file in a Readable Stream ' ,
145
127
reason : 'TODO not implemented in go-ipfs yet'
146
128
}
147
129
]
148
130
} )
149
131
150
- tests . key ( defaultCommonFactory , {
132
+ tests . key ( commonFactory , {
151
133
skip : [
152
134
// key.export
153
135
{
@@ -162,7 +144,7 @@ describe('interface-ipfs-core tests', () => {
162
144
]
163
145
} )
164
146
165
- tests . miscellaneous ( defaultCommonFactory , {
147
+ tests . miscellaneous ( commonFactory , {
166
148
skip : [
167
149
// stop
168
150
{
@@ -172,11 +154,13 @@ describe('interface-ipfs-core tests', () => {
172
154
]
173
155
} )
174
156
175
- tests . name ( CommonFactory . createAsync ( {
176
- spawnOptions : {
177
- args : [ '--offline' ]
157
+ tests . name ( ctl . createTestsInterface ( merge ( commonOptions ,
158
+ {
159
+ spawnOptions : {
160
+ args : [ '--offline' ]
161
+ }
178
162
}
179
- } ) , {
163
+ ) ) , {
180
164
skip : [
181
165
// stop
182
166
{
@@ -186,12 +170,13 @@ describe('interface-ipfs-core tests', () => {
186
170
]
187
171
} )
188
172
189
- tests . namePubsub ( CommonFactory . createAsync ( {
190
- spawnOptions : {
191
- args : [ '--enable-namesys-pubsub' ] ,
192
- initOptions : { bits : 1024 , profile : 'test' }
173
+ tests . namePubsub ( ctl . createTestsInterface ( merge ( commonOptions ,
174
+ {
175
+ spawnOptions : {
176
+ args : [ '--enable-namesys-pubsub' ]
177
+ }
193
178
}
194
- } ) , {
179
+ ) ) , {
195
180
skip : [
196
181
// name.pubsub.cancel
197
182
{
@@ -206,11 +191,11 @@ describe('interface-ipfs-core tests', () => {
206
191
]
207
192
} )
208
193
209
- tests . object ( defaultCommonFactory )
194
+ tests . object ( commonFactory )
210
195
211
- tests . pin ( defaultCommonFactory )
196
+ tests . pin ( commonFactory )
212
197
213
- tests . ping ( defaultCommonFactory , {
198
+ tests . ping ( commonFactory , {
214
199
skip : [
215
200
{
216
201
name : 'should fail when pinging an unknown peer over pull stream' ,
@@ -227,12 +212,13 @@ describe('interface-ipfs-core tests', () => {
227
212
]
228
213
} )
229
214
230
- tests . pubsub ( CommonFactory . createAsync ( {
231
- spawnOptions : {
232
- args : [ '--enable-pubsub-experiment' ] ,
233
- initOptions : { bits : 1024 , profile : 'test' }
215
+ tests . pubsub ( ctl . createTestsInterface ( merge ( commonOptions ,
216
+ {
217
+ spawnOptions : {
218
+ args : [ '--enable-pubsub-experiment' ]
219
+ }
234
220
}
235
- } ) , {
221
+ ) ) , {
236
222
skip : isWindows ? [
237
223
// pubsub.subscribe
238
224
{
@@ -246,9 +232,9 @@ describe('interface-ipfs-core tests', () => {
246
232
] : null
247
233
} )
248
234
249
- tests . repo ( defaultCommonFactory )
235
+ tests . repo ( commonFactory )
250
236
251
- tests . stats ( defaultCommonFactory )
237
+ tests . stats ( commonFactory )
252
238
253
- tests . swarm ( defaultCommonFactory )
239
+ tests . swarm ( commonFactory )
254
240
} )
0 commit comments