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

Commit

Permalink
Revert "feat: use new ipfsd-ctl (#186)"
Browse files Browse the repository at this point in the history
This reverts commit 4d4ef7f.
  • Loading branch information
dryajov committed Jan 19, 2018
1 parent 52e67ad commit 7133ecf
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 137 deletions.
10 changes: 4 additions & 6 deletions src/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,23 @@ function expectKey (block, expected, callback) {
module.exports = (common) => {
describe('.block', () => {
let ipfs
let ipfsd

before(function (done) {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

common.setup((err, df, type, exec) => {
common.setup((err, factory) => {
expect(err).to.not.exist()
df.spawn({ type, exec }, (err, node) => {
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfsd = node
ipfs = node.api
ipfs = node
done()
})
})
})

after((done) => ipfsd.stop(done))
after((done) => common.teardown(done))

describe('.put', () => {
it('a buffer, using defaults', (done) => {
Expand Down
10 changes: 4 additions & 6 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,23 @@ module.exports = (common) => {
describe('.config', function () {
this.timeout(30 * 1000)
let ipfs
let ipfsd

before(function (done) {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

common.setup((err, df, type, exec) => {
common.setup((err, factory) => {
expect(err).to.not.exist()
df.spawn({ type, exec }, (err, node) => {
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfsd = node
ipfs = node.api
ipfs = node
done()
})
})
})

after((done) => ipfsd.stop(done))
after((done) => common.teardown(done))

describe('.get', () => {
it('retrieve the whole config', (done) => {
Expand Down
10 changes: 4 additions & 6 deletions src/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,23 @@ const CID = require('cids')
module.exports = (common) => {
describe('.dag', () => {
let ipfs
let ipfsd

before(function (done) {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

common.setup((err, df, type, exec) => {
common.setup((err, factory) => {
expect(err).to.not.exist()
df.spawn({ type, exec }, (err, node) => {
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfs = node.api
ipfsd = node
ipfs = node
done()
})
})
})

after((done) => ipfsd.stop(done))
after((done) => common.teardown(done))

let pbNode
let cborNode
Expand Down
37 changes: 12 additions & 25 deletions src/dht.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,14 @@ const series = require('async/series')
const parallel = require('async/parallel')
const CID = require('cids')

function spawnWithId (df, type, exec, callback) {
if (typeof type === 'function') {
callback = type
type = undefined
}

if (typeof exec === 'function') {
callback = exec
exec = undefined
}

function spawnWithId (factory, callback) {
waterfall([
(cb) => df.spawn({ type, exec }, cb),
(node, cb) => node.api.id((err, peerId) => {
(cb) => factory.spawnNode(cb),
(node, cb) => node.id((err, peerId) => {
if (err) {
return cb(err)
}
node.api.peerId = peerId
node.peerId = peerId
cb(null, node)
})
], callback)
Expand All @@ -41,26 +31,23 @@ module.exports = (common) => {
let nodeB
let nodeC

let ipfsdNodes
before(function (done) {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

common.setup((err, df, type) => {
common.setup((err, factory) => {
expect(err).to.not.exist()
series([
(cb) => spawnWithId(df, type, cb),
(cb) => spawnWithId(df, type, cb),
(cb) => spawnWithId(df, type, cb)
(cb) => spawnWithId(factory, cb),
(cb) => spawnWithId(factory, cb),
(cb) => spawnWithId(factory, cb)
], (err, nodes) => {
expect(err).to.not.exist()

ipfsdNodes = nodes

nodeA = nodes[0].api
nodeB = nodes[1].api
nodeC = nodes[2].api
nodeA = nodes[0]
nodeB = nodes[1]
nodeC = nodes[2]

parallel([
(cb) => nodeA.swarm.connect(nodeB.peerId.addresses[0], cb),
Expand All @@ -71,7 +58,7 @@ module.exports = (common) => {
})
})

after((done) => parallel(ipfsdNodes.map((node) => (cb) => node.stop(cb)), done))
after((done) => common.teardown(done))

describe('.get and .put', () => {
it('errors when getting a non-existent key from the DHT', (done) => {
Expand Down
10 changes: 4 additions & 6 deletions src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module.exports = (common) => {
this.timeout(40 * 1000)

let ipfs
let ipfsd

function fixture (path) {
return loadFixture(__dirname, path, 'interface-ipfs-core')
Expand Down Expand Up @@ -56,18 +55,17 @@ module.exports = (common) => {
// timeout for the before step
this.timeout(60 * 1000)

common.setup((err, df, type, exec) => {
common.setup((err, factory) => {
expect(err).to.not.exist()
df.spawn({ type, exec }, (err, node) => {
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfs = node.api
ipfsd = node
ipfs = node
done()
})
})
})

after((done) => ipfsd.stop(done))
after((done) => common.teardown(done))

describe('.add', () => {
it('a Buffer', (done) => {
Expand Down
12 changes: 5 additions & 7 deletions src/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,22 @@ const hat = require('hat')
module.exports = (common) => {
describe('.key', () => {
const keyTypes = [
{ type: 'rsa', size: 2048 }
{type: 'rsa', size: 2048}
]
const keys = []
let ipfs
let ipfsd
let withGo

before(function (done) {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

common.setup((err, df, type, exec) => {
common.setup((err, factory) => {
expect(err).to.not.exist()
df.spawn({ type, exec }, (err, node) => {
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfsd = node
ipfs = node.api
ipfs = node
ipfs.id((err, id) => {
expect(err).to.not.exist()
withGo = id.agentVersion.startsWith('go-ipfs')
Expand All @@ -39,7 +37,7 @@ module.exports = (common) => {
})
})

after((done) => ipfsd.stop(done))
after((done) => common.teardown(done))

describe('.gen', () => {
keyTypes.forEach((kt) => {
Expand Down
12 changes: 6 additions & 6 deletions src/miscellaneous.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ chai.use(dirtyChai)
module.exports = (common) => {
describe('.miscellaneous', () => {
let ipfs
let ipfsd

before(function (done) {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

common.setup((err, df, type, exec) => {
common.setup((err, factory) => {
expect(err).to.not.exist()
df.spawn({ type, exec }, (err, node) => {
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfs = node.api
ipfsd = node
ipfs = node
done()
})
})
})

after((done) => ipfsd.stop(done))
after((done) => {
common.teardown(done)
})

it('.id', (done) => {
ipfs.id((err, res) => {
Expand Down
14 changes: 7 additions & 7 deletions src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ module.exports = (common) => {
this.timeout(80 * 1000)

let ipfs
let ipfsd

before(function (done) {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

common.setup((err, df, type, exec) => {
common.setup((err, factory) => {
expect(err).to.not.exist()
df.spawn({ type, exec }, (err, node) => {
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfs = node.api
ipfsd = node
ipfs = node
done()
})
})
})

after((done) => ipfsd.stop(done))
after((done) => {
common.teardown(done)
})

describe('callback API', () => {
describe('.new', () => {
Expand Down Expand Up @@ -843,7 +843,7 @@ module.exports = (common) => {
return ipfs.object.put(testObj, (err, node) => {
expect(err).to.not.exist()

return ipfs.object.stat('QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', { enc: 'base58' })
return ipfs.object.stat('QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', {enc: 'base58'})
.then((stats) => {
const expected = {
Hash: 'QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ',
Expand Down
10 changes: 4 additions & 6 deletions src/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@ module.exports = (common) => {
this.timeout(50 * 1000)

let ipfs
let ipfsd

before(function (done) {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(60 * 1000)

common.setup((err, df, type, exec) => {
common.setup((err, factory) => {
expect(err).to.not.exist()
df.spawn({ type, exec }, (err, node) => {
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfs = node.api
ipfsd = node
ipfs = node
populate()
})
})
Expand All @@ -45,7 +43,7 @@ module.exports = (common) => {
}
})

after((done) => ipfsd.stop(done))
after((done) => common.teardown(done))

describe('callback API', () => {
// 1st, because ipfs.files.add pins automatically
Expand Down
Loading

0 comments on commit 7133ecf

Please sign in to comment.