Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit eba0398

Browse files
committed
feat(factory): add ipfs factory to files
1 parent 3db096e commit eba0398

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"form-data": "^1.0.0-rc4",
4848
"gulp": "^3.9.1",
4949
"idb-plus-blob-store": "^1.1.2",
50-
"interface-ipfs-core": "^0.6.0",
50+
"interface-ipfs-core": "^0.7.0",
5151
"left-pad": "^1.1.1",
5252
"lodash": "^4.14.1",
5353
"ncp": "^2.0.0",
@@ -121,4 +121,4 @@
121121
"kumavis <kumavis@users.noreply.github.com>",
122122
"nginnever <ginneversource@gmail.com>"
123123
]
124-
}
124+
}

test/core/both/test-files.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,17 @@
22
'use strict'
33

44
const test = require('interface-ipfs-core')
5-
const IPFS = require('../../../src/core')
5+
const IPFSFactory = require('../../utils/factory')
66

7-
// let factory
7+
let factory
88

99
const common = {
1010
setup: function (cb) {
11-
// TODO change to factory
12-
const ipfs = new IPFS(require('../../utils/repo-path'))
13-
ipfs.load(() => {
14-
cb(null, ipfs)
15-
})
11+
factory = new IPFSFactory()
12+
cb(null, factory)
1613
},
1714
teardown: function (cb) {
18-
// factory.teardown
19-
cb()
15+
factory.dismantle(cb)
2016
}
2117
}
2218

test/utils/factory/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
'use strict'
22

3-
const fs = require('fs')
4-
const path = require('path')
53
const PeerId = require('peer-id')
64
const isNode = require('detect-node')
75
const IPFSRepo = require('ipfs-repo')
86
const cleanRepo = require('../clean')
97
const IPFS = require('../../../src/core')
108
const series = require('run-series')
9+
const defaultConfig = require('./default-config.json')
1110

1211
module.exports = Factory
1312

@@ -36,9 +35,8 @@ function Factory () {
3635
}
3736

3837
if (!config) {
39-
const defaultConfigPath = path.join(__dirname, 'default-config.json')
40-
config = JSON.parse(fs.readFileSync(defaultConfigPath).toString())
41-
const pId = PeerId.create().toJSON()
38+
config = JSON.parse(JSON.stringify(defaultConfig))
39+
const pId = PeerId.create({ bits: 32 }).toJSON()
4240
config.Identity.PeerID = pId.id
4341
config.Identity.PrivKey = pId.privKey
4442
}

0 commit comments

Comments
 (0)