Skip to content

Commit

Permalink
fix: use bundled ipfs in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Aug 13, 2018
1 parent 5bf528f commit b2e6e8f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ package-lock.json
dist
.nyc_output
coverage
docs
42 changes: 19 additions & 23 deletions test/blob-store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,40 @@ const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()
const which = require('which')

which('ipfs', (error, ipfs) => {
which('jsipfs', (error, ipfs) => {
if (error) {
throw error
}

df.spawn({
disposable: true,
args: ['--api=/ip4/127.0.0.1/tcp/13000'],
exec: ipfs
}, (err, node) => {
}, async (err, node) => {
if (err) {
throw err
}

abstractBlobTests(test, common)
const options = {
baseDir: '/tests/',
ipfs: node.api
}
const store = await ipfsBlobStore(options)

abstractBlobTests(test, {
setup: async (t, cb) => {
await store.ipfs.files.mkdir(options.baseDir, { p: true })
cb(null, store)
},
teardown: async (t, store, blob, cb) => {
await store.ipfs.files.rm(options.baseDir, { recursive: true })
cb()
}
})

// quick hack to stop the deamon
// TODO clean up later
setTimeout(function () {
node.stop(() => {})
}, 5000)
})
})

let store
const options = {
baseDir: '/tests/',
port: 13000,
host: '127.0.0.1'
}
const common = {
setup: async (t, cb) => {
store = await ipfsBlobStore(options)
await store.ipfs.files.mkdir(options.baseDir, { p: true })
cb(null, store)
},

teardown: async (t, store, blob, cb) => {
await store.ipfs.files.rm(options.baseDir, { recursive: true })
cb()
}
}

0 comments on commit b2e6e8f

Please sign in to comment.