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

Commit dc6fa51

Browse files
author
Pedro Santos
committed
chore: change interface tests to async node creation
1 parent 876ae7c commit dc6fa51

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"cross-env": "^6.0.0",
8585
"detect-node": "^2.0.4",
8686
"go-ipfs-dep": "^0.4.22",
87-
"interface-ipfs-core": "^0.121.0",
87+
"interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#chore/async-await-refactor",
8888
"ipfsd-ctl": "^0.47.1",
8989
"ndjson": "^1.5.0",
9090
"nock": "^11.4.0",

test/interface.spec.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const CommonFactory = require('./utils/interface-common-factory')
77
const isWindows = process.platform && process.platform === 'win32'
88

99
describe('interface-ipfs-core tests', () => {
10-
const defaultCommonFactory = CommonFactory.create()
10+
const defaultCommonFactory = CommonFactory.createAsync()
1111

1212
tests.bitswap(defaultCommonFactory, {
1313
skip: [
@@ -172,7 +172,7 @@ describe('interface-ipfs-core tests', () => {
172172
]
173173
})
174174

175-
tests.name(CommonFactory.create({
175+
tests.name(CommonFactory.createAsync({
176176
spawnOptions: {
177177
args: ['--offline']
178178
}
@@ -186,8 +186,7 @@ describe('interface-ipfs-core tests', () => {
186186
]
187187
})
188188

189-
// TODO: uncomment after https://github.com/ipfs/interface-ipfs-core/pull/361 being merged and a new release
190-
tests.namePubsub(CommonFactory.create({
189+
tests.namePubsub(CommonFactory.createAsync({
191190
spawnOptions: {
192191
args: ['--enable-namesys-pubsub'],
193192
initOptions: { bits: 1024, profile: 'test' }
@@ -228,7 +227,7 @@ describe('interface-ipfs-core tests', () => {
228227
]
229228
})
230229

231-
tests.pubsub(CommonFactory.create({
230+
tests.pubsub(CommonFactory.createAsync({
232231
spawnOptions: {
233232
args: ['--enable-pubsub-experiment'],
234233
initOptions: { bits: 1024, profile: 'test' }
@@ -251,5 +250,5 @@ describe('interface-ipfs-core tests', () => {
251250

252251
tests.stats(defaultCommonFactory)
253252

254-
tests.swarm(CommonFactory.createAsync())
253+
tests.swarm(defaultCommonFactory)
255254
})

test/utils/interface-common-factory.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ const IPFSFactory = require('ipfsd-ctl')
66
const ipfsClient = require('../../src')
77
const merge = require('merge-options')
88

9+
const DEFAULT_FACTORY_OPTIONS = {
10+
IpfsClient: ipfsClient
11+
}
12+
913
function createFactory (options) {
1014
options = options || {}
1115

12-
options.factoryOptions = options.factoryOptions || { IpfsClient: ipfsClient }
16+
options.factoryOptions = options.factoryOptions || DEFAULT_FACTORY_OPTIONS
1317
options.spawnOptions = options.spawnOptions || { initOptions: { bits: 1024, profile: 'test' } }
1418

1519
const ipfsFactory = IPFSFactory.create(options.factoryOptions)
@@ -52,19 +56,17 @@ function createFactory (options) {
5256
}
5357
}
5458

55-
function createAsync (createFactoryOptions, createSpawnOptions) {
59+
function createAsync (options = {}) {
5660
return () => {
5761
const nodes = []
58-
const setup = async (factoryOptions = {}, spawnOptions) => {
62+
const setup = async (setupOptions = {}) => {
5963
const ipfsFactory = IPFSFactory.create(merge(
60-
{ IpfsClient: ipfsClient },
61-
factoryOptions,
62-
createFactoryOptions
64+
setupOptions.factoryOptions,
65+
options.factoryOptions || DEFAULT_FACTORY_OPTIONS
6366
))
6467
const node = await ipfsFactory.spawn(merge(
65-
{ initOptions: { profile: 'test' } },
66-
spawnOptions,
67-
createSpawnOptions
68+
setupOptions.spawnOptions,
69+
options.spawnOptions || { initOptions: { profile: 'test' } }
6870
))
6971
nodes.push(node)
7072

0 commit comments

Comments
 (0)