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

Commit 224a4cc

Browse files
committed
fix: use new ipfsd-ctl setup
1 parent 47093d5 commit 224a4cc

File tree

2 files changed

+55
-161
lines changed

2 files changed

+55
-161
lines changed

test/interface.spec.js

Lines changed: 55 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,29 @@
22
'use strict'
33

44
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')
78
const isWindows = process.platform && process.platform === 'win32'
89

910
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)
1115

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)
3517

36-
tests.block(defaultCommonFactory, {
18+
tests.block(commonFactory, {
3719
skip: [{
3820
name: 'should get a block added as CIDv1 with a CIDv0',
3921
reason: 'go-ipfs does not support the `version` param'
4022
}]
4123
})
4224

43-
tests.bootstrap(defaultCommonFactory)
25+
tests.bootstrap(commonFactory)
4426

45-
tests.config(defaultCommonFactory, {
27+
tests.config(commonFactory, {
4628
skip: [
4729
// config.replace
4830
{
@@ -60,7 +42,7 @@ describe('interface-ipfs-core tests', () => {
6042
]
6143
})
6244

63-
tests.dag(defaultCommonFactory, {
45+
tests.dag(commonFactory, {
6446
skip: [
6547
// dag.tree
6648
{
@@ -87,7 +69,7 @@ describe('interface-ipfs-core tests', () => {
8769
]
8870
})
8971

90-
tests.dht(defaultCommonFactory, {
72+
tests.dht(commonFactory, {
9173
skip: [
9274
// dht.findpeer
9375
{
@@ -107,47 +89,47 @@ describe('interface-ipfs-core tests', () => {
10789
]
10890
})
10991

110-
tests.filesRegular(defaultCommonFactory, {
92+
tests.filesMFS(commonFactory, {
11193
skip: [
112-
// .addFromFs
113-
isNode ? null : {
114-
name: 'addFromFs',
115-
reason: 'Not designed to run in the browser'
116-
},
117-
// .catPullStream
11894
{
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'
12197
},
12298
{
123-
name: 'should export a chunk of a file in a Pull Stream',
99+
name: 'should read from outside of mfs',
124100
reason: 'TODO not implemented in go-ipfs yet'
125101
},
126102
{
127-
name: 'should export a chunk of a file in a Readable Stream',
103+
name: 'should ls from outside of mfs',
128104
reason: 'TODO not implemented in go-ipfs yet'
129105
}
130106
]
131107
})
132108

133-
tests.filesMFS(defaultCommonFactory, {
109+
tests.filesRegular(commonFactory, {
134110
skip: [
111+
// .addFromFs
112+
isNode ? null : {
113+
name: 'addFromFs',
114+
reason: 'Not designed to run in the browser'
115+
},
116+
// .catPullStream
135117
{
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'
138120
},
139121
{
140-
name: 'should read from outside of mfs',
122+
name: 'should export a chunk of a file in a Pull Stream',
141123
reason: 'TODO not implemented in go-ipfs yet'
142124
},
143125
{
144-
name: 'should ls from outside of mfs',
126+
name: 'should export a chunk of a file in a Readable Stream',
145127
reason: 'TODO not implemented in go-ipfs yet'
146128
}
147129
]
148130
})
149131

150-
tests.key(defaultCommonFactory, {
132+
tests.key(commonFactory, {
151133
skip: [
152134
// key.export
153135
{
@@ -162,7 +144,7 @@ describe('interface-ipfs-core tests', () => {
162144
]
163145
})
164146

165-
tests.miscellaneous(defaultCommonFactory, {
147+
tests.miscellaneous(commonFactory, {
166148
skip: [
167149
// stop
168150
{
@@ -172,11 +154,13 @@ describe('interface-ipfs-core tests', () => {
172154
]
173155
})
174156

175-
tests.name(CommonFactory.createAsync({
176-
spawnOptions: {
177-
args: ['--offline']
157+
tests.name(ctl.createTestsInterface(merge(commonOptions,
158+
{
159+
spawnOptions: {
160+
args: ['--offline']
161+
}
178162
}
179-
}), {
163+
)), {
180164
skip: [
181165
// stop
182166
{
@@ -186,12 +170,13 @@ describe('interface-ipfs-core tests', () => {
186170
]
187171
})
188172

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+
}
193178
}
194-
}), {
179+
)), {
195180
skip: [
196181
// name.pubsub.cancel
197182
{
@@ -206,11 +191,11 @@ describe('interface-ipfs-core tests', () => {
206191
]
207192
})
208193

209-
tests.object(defaultCommonFactory)
194+
tests.object(commonFactory)
210195

211-
tests.pin(defaultCommonFactory)
196+
tests.pin(commonFactory)
212197

213-
tests.ping(defaultCommonFactory, {
198+
tests.ping(commonFactory, {
214199
skip: [
215200
{
216201
name: 'should fail when pinging an unknown peer over pull stream',
@@ -227,12 +212,13 @@ describe('interface-ipfs-core tests', () => {
227212
]
228213
})
229214

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+
}
234220
}
235-
}), {
221+
)), {
236222
skip: isWindows ? [
237223
// pubsub.subscribe
238224
{
@@ -246,9 +232,9 @@ describe('interface-ipfs-core tests', () => {
246232
] : null
247233
})
248234

249-
tests.repo(defaultCommonFactory)
235+
tests.repo(commonFactory)
250236

251-
tests.stats(defaultCommonFactory)
237+
tests.stats(commonFactory)
252238

253-
tests.swarm(defaultCommonFactory)
239+
tests.swarm(commonFactory)
254240
})

test/utils/interface-common-factory.js

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)