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

Update aegir and ipfsd-ctl #262

Merged
merged 3 commits into from
May 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
},
"devDependencies": {
"chai": "^3.5.0",
"aegir": "^2.1.1",
"aegir": "^3.0.1",
"gulp": "^3.9.1",
"ipfsd-ctl": "^0.11.0",
"ipfsd-ctl": "^0.13.0",
"pre-commit": "^1.1.2",
"raw-loader": "^0.5.1",
"stream-equal": "^0.1.8",
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ const loadCommands = require('./load-commands')
const getConfig = require('./config')
const getRequestAPI = require('./request-api')

function IpfsAPI (host_or_multiaddr, port, opts) {
function IpfsAPI (hostOrMultiaddr, port, opts) {
const config = getConfig()

try {
const maddr = multiaddr(host_or_multiaddr).nodeAddress()
const maddr = multiaddr(hostOrMultiaddr).nodeAddress()
config.host = maddr.address
config.port = maddr.port
} catch (e) {
if (typeof host_or_multiaddr === 'string') {
config.host = host_or_multiaddr
if (typeof hostOrMultiaddr === 'string') {
config.host = hostOrMultiaddr
config.port = port && typeof port !== 'object' ? port : config.port
}
}
Expand Down
24 changes: 12 additions & 12 deletions test/api/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ describe('.config', () => {
const confKey = 'arbitraryKey'
const confVal = 'arbitraryVal'

apiClients['a'].config.set(confKey, confVal, (err, res) => {
apiClients.a.config.set(confKey, confVal, (err, res) => {
expect(err).to.not.exist
apiClients['a'].config.get(confKey, (err, res) => {
apiClients.a.config.get(confKey, (err, res) => {
expect(err).to.not.exist
expect(res).to.have.a.property('Value', confVal)
done()
Expand All @@ -26,9 +26,9 @@ describe('.config', () => {
const confKey = 'otherKey'
const confVal = true

apiClients['a'].config.set(confKey, confVal, (err, res) => {
apiClients.a.config.set(confKey, confVal, (err, res) => {
expect(err).to.not.exist
apiClients['a'].config.get(confKey, (err, res) => {
apiClients.a.config.get(confKey, (err, res) => {
expect(err).to.not.exist
expect(res.Value).to.deep.equal(confVal)
done()
Expand All @@ -40,9 +40,9 @@ describe('.config', () => {
const confKey = 'API.HTTPHeaders.Access-Control-Allow-Origin'
const confVal = ['http://example.io']

apiClients['a'].config.set(confKey, confVal, (err, res) => {
apiClients.a.config.set(confKey, confVal, (err, res) => {
expect(err).to.not.exist
apiClients['a'].config.get(confKey, (err, res) => {
apiClients.a.config.get(confKey, (err, res) => {
expect(err).to.not.exist
expect(res.Value).to.deep.equal(confVal)
done()
Expand Down Expand Up @@ -77,9 +77,9 @@ describe('.config', () => {
const confKey = 'arbitraryKey'
const confVal = 'arbitraryVal'

return apiClients['a'].config.set(confKey, confVal)
return apiClients.a.config.set(confKey, confVal)
.then((res) => {
return apiClients['a'].config.get(confKey)
return apiClients.a.config.get(confKey)
})
.then((res) => {
expect(res).to.have.a.property('Value', confVal)
Expand All @@ -90,9 +90,9 @@ describe('.config', () => {
const confKey = 'otherKey'
const confVal = true

return apiClients['a'].config.set(confKey, confVal)
return apiClients.a.config.set(confKey, confVal)
.then((res) => {
return apiClients['a'].config.get(confKey)
return apiClients.a.config.get(confKey)
})
.then((res) => {
expect(res.Value).to.deep.equal(confVal)
Expand All @@ -103,9 +103,9 @@ describe('.config', () => {
const confKey = 'API.HTTPHeaders.Access-Control-Allow-Origin'
const confVal = ['http://example.com']

return apiClients['a'].config.set(confKey, confVal)
return apiClients.a.config.set(confKey, confVal)
.then((res) => {
return apiClients['a'].config.get(confKey)
return apiClients.a.config.get(confKey)
})
.then((res) => {
expect(res.Value).to.deep.equal(confVal)
Expand Down
24 changes: 8 additions & 16 deletions test/api/object.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ describe('.object', () => {
expect(err).to.not.exist

expect(res).to.be.eql({
Hash: 'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD',
Links: []
Hash: 'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD'
})
done()
})
Expand All @@ -87,8 +86,7 @@ describe('.object', () => {
.addLink(testObjectHash, 'next', testPatchObjectHash, (err, res) => {
expect(err).to.not.exist
expect(res).to.be.eql({
Hash: 'QmZFdJ3CQsY4kkyQtjoUo8oAzsEs5BNguxBhp8sjQMpgkd',
Links: null
Hash: 'QmZFdJ3CQsY4kkyQtjoUo8oAzsEs5BNguxBhp8sjQMpgkd'
})
apiClients.a.object.get(res.Hash, (err, res) => {
expect(err).to.not.exist
Expand All @@ -110,8 +108,7 @@ describe('.object', () => {
.rmLink('QmZFdJ3CQsY4kkyQtjoUo8oAzsEs5BNguxBhp8sjQMpgkd', 'next', (err, res) => {
expect(err).to.not.exist
expect(res).to.be.eql({
Hash: testObjectHash,
Links: null
Hash: testObjectHash
})
apiClients.a.object.get(res.Hash, (err, res) => {
expect(err).to.not.exist
Expand All @@ -129,8 +126,7 @@ describe('.object', () => {
.appendData(testObjectHash, new Buffer(' hello'), (err, res) => {
expect(err).to.not.exist
expect(res).to.be.eql({
Hash: 'Qmcjhr2QztQxCAoEf8tJPTGTVkTsUrTQ36JurH14DNYNsc',
Links: null
Hash: 'Qmcjhr2QztQxCAoEf8tJPTGTVkTsUrTQ36JurH14DNYNsc'
})
apiClients.a.object.get(res.Hash, (err, res) => {
expect(err).to.not.exist
Expand All @@ -147,8 +143,7 @@ describe('.object', () => {
.setData(testObjectHash, new Buffer('hello world'), (err, res) => {
expect(err).to.not.exist
expect(res).to.be.eql({
Hash: 'QmU1Sq1B7RPQD2XcQNLB58qJUyJffVJqihcxmmN1STPMxf',
Links: null
Hash: 'QmU1Sq1B7RPQD2XcQNLB58qJUyJffVJqihcxmmN1STPMxf'
})
apiClients.a.object.get(res.Hash, (err, res) => {
expect(err).to.not.exist
Expand All @@ -166,8 +161,7 @@ describe('.object', () => {
apiClients.a.object.new('unixfs-dir', (err, res) => {
expect(err).to.not.exist
expect(res).to.deep.equal({
Hash: 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn',
Links: null
Hash: 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'
})
done()
})
Expand Down Expand Up @@ -226,8 +220,7 @@ describe('.object', () => {
return apiClients.a.object.links(testObjectHash)
.then((res) => {
expect(res).to.be.eql({
Hash: 'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD',
Links: []
Hash: 'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD'
})
})
})
Expand All @@ -236,8 +229,7 @@ describe('.object', () => {
return apiClients.a.object.new('unixfs-dir')
.then((res) => {
expect(res).to.deep.equal({
Hash: 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn',
Links: null
Hash: 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'
})
})
})
Expand Down
8 changes: 4 additions & 4 deletions test/api/swarm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('.swarm', () => {
})

it('.swarm.addrs', (done) => {
apiClients['a'].swarm.addrs((err, res) => {
apiClients.a.swarm.addrs((err, res) => {
expect(err).to.not.exist

expect(Object.keys(res.Addrs)).to.have.length.above(1)
Expand All @@ -34,7 +34,7 @@ describe('.swarm', () => {
})

it('.swarm.localAddrs', (done) => {
apiClients['a'].swarm.localAddrs((err, res) => {
apiClients.a.swarm.localAddrs((err, res) => {
expect(err).to.not.exist

expect(res.Strings).to.have.length.above(1)
Expand All @@ -51,14 +51,14 @@ describe('.swarm', () => {
})

it('.swarm.addrs', () => {
return apiClients['a'].swarm.addrs()
return apiClients.a.swarm.addrs()
.then((res) => {
expect(Object.keys(res.Addrs)).to.have.length.above(1)
})
})

it('.swarm.localAddrs', () => {
return apiClients['a'].swarm.localAddrs()
return apiClients.a.swarm.localAddrs()
.then((res) => {
expect(res.Strings).to.have.length.above(1)
})
Expand Down