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 . create ( )
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,19 +154,21 @@ describe('interface-ipfs-core tests', () => {
172
154
]
173
155
} )
174
156
175
- tests . name ( CommonFactory . create ( {
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
181
- // TODO: uncomment after https://github.com/ipfs/interface-ipfs-core/pull/361 being merged and a new release
182
- tests . namePubsub ( CommonFactory . create ( {
183
- spawnOptions : {
184
- args : [ '--enable-namesys-pubsub' ] ,
185
- initOptions : { bits : 1024 , profile : 'test' }
165
+ tests . namePubsub ( ctl . createTestsInterface ( merge ( commonOptions ,
166
+ {
167
+ spawnOptions : {
168
+ args : [ '--enable-namesys-pubsub' ]
169
+ }
186
170
}
187
- } ) , {
171
+ ) ) , {
188
172
skip : [
189
173
// name.pubsub.cancel
190
174
{
@@ -199,11 +183,11 @@ describe('interface-ipfs-core tests', () => {
199
183
]
200
184
} )
201
185
202
- tests . object ( defaultCommonFactory )
186
+ tests . object ( commonFactory )
203
187
204
- tests . pin ( defaultCommonFactory )
188
+ tests . pin ( commonFactory )
205
189
206
- tests . ping ( defaultCommonFactory , {
190
+ tests . ping ( commonFactory , {
207
191
skip : [
208
192
{
209
193
name : 'should fail when pinging an unknown peer over pull stream' ,
@@ -220,12 +204,13 @@ describe('interface-ipfs-core tests', () => {
220
204
]
221
205
} )
222
206
223
- tests . pubsub ( CommonFactory . create ( {
224
- spawnOptions : {
225
- args : [ '--enable-pubsub-experiment' ] ,
226
- initOptions : { bits : 1024 , profile : 'test' }
207
+ tests . pubsub ( ctl . createTestsInterface ( merge ( commonOptions ,
208
+ {
209
+ spawnOptions : {
210
+ args : [ '--enable-pubsub-experiment' ]
211
+ }
227
212
}
228
- } ) , {
213
+ ) ) , {
229
214
skip : isWindows ? [
230
215
// pubsub.subscribe
231
216
{
@@ -239,9 +224,9 @@ describe('interface-ipfs-core tests', () => {
239
224
] : null
240
225
} )
241
226
242
- tests . repo ( defaultCommonFactory )
227
+ tests . repo ( commonFactory )
243
228
244
- tests . stats ( defaultCommonFactory )
229
+ tests . stats ( commonFactory )
245
230
246
- tests . swarm ( CommonFactory . createAsync ( ) )
231
+ tests . swarm ( commonFactory )
247
232
} )
0 commit comments