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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs-inactive/js-ipfs-http-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e427e916fceb
Choose a base ref
...
head repository: ipfs-inactive/js-ipfs-http-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: faf9495eaa1b
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Oct 25, 2015

  1. fix ls

    daviddias committed Oct 25, 2015
    Copy the full SHA
    5becd24 View commit details
  2. fix refs

    daviddias committed Oct 25, 2015
    Copy the full SHA
    faf9495 View commit details
Showing with 68 additions and 46 deletions.
  1. +67 −45 test/tests.js
  2. +1 −1 test/tmp-disposable-nodes-addrs.json
112 changes: 67 additions & 45 deletions test/tests.js
Original file line number Diff line number Diff line change
@@ -44,7 +44,8 @@ describe('IPFS Node.js API wrapper tests', function () {
if (err) {
throw err
}
addrs[key] = id.Addresses[0] // apiAddrs[key] + '/ipfs/' + id.ID
// note to self: HTTP API port !== Node port
addrs[key] = id.Addresses[0]
cb()
})
}
@@ -162,31 +163,50 @@ describe('IPFS Node.js API wrapper tests', function () {
})

describe('.ls', function () {
var initDocs = 'Qmcqtw8FfrVSBaRmbWwHxt3AuySBhJLcvmFYi3Lbc4xnwj'
var initDocsLs = {
'help': 'QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7',
'about': 'QmfE3nUohq2nEYwieF7YFnJF1VfiL4i3wDxkMq8aGUg8Mt',
'readme': 'QmUFtMrBHqdjTtbebsL6YGebvjShh3Jud1insUv12fEVdA',
'contact': 'QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y',
'quick-start': 'QmeEqpsKrvdhuuuVsguHaVdJcPnnUHHZ5qEWjCHavYbNqU',
'security-notes': 'QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ'
}
it.skip('ls', function (done) {
this.timeout(10000)
var folder = 'QmaMTzaGBmdLrispnPRTESta4yDQdK4uKSVcQez2No4h6q'
it('ls', function (done) {
this.timeout(100000)

apiClients['a'].ls(initDocs, function (err, res) {
if (err) throw err
apiClients['a'].ls(folder, function (err, res) {
if (err) {
throw err
}

var dir = res.Objects[0]
for (var i in dir.Links) {
var link = dir.Links[i]
assert.equal(link.Hash, initDocsLs[link.Name])
var objs = {
Hash: 'QmaMTzaGBmdLrispnPRTESta4yDQdK4uKSVcQez2No4h6q',
Links: [{
Name: 'add.js',
Hash: 'QmaeuuKLHzirbVoTjb3659fyyV381amjaGrU2pecHEWPrN',
Size: 481,
Type: 2
}, {
Name: 'cat.js',
Hash: 'QmTQhTtDWeaaP9pttDd1CuoVTLQm1w51ABfjgmGUbCUF6i',
Size: 364,
Type: 2
}, {
Name: 'files',
Hash: 'QmTYFLz5vsdMpq4XXw1a1pSxujJc9Z5V3Aw1Qg64d849Zy',
Size: 132,
Type: 1
}, {
Name: 'ipfs-add.js',
Hash: 'QmTjXxUemcuMAZ2KNN3iJGWHwrkMsW8SWEwkYVSBi1nFD9',
Size: 315,
Type: 2
}, {
Name: 'ls.js',
Hash: 'QmXYUXDFNNh1wgwtX5QDG7MsuhAAcE9NzDYnz8SjnhvQrK',
Size: 428,
Type: 2
}, {
Name: 'version.js',
Hash: 'QmUmDmH4hZgN5THnVP1VjJ1YWh5kWuhLGUihch8nFiD9iy',
Size: 153,
Type: 2 }]
}
assert.equal(dir.Hash, initDocs)
assert.equal(dir.Links.length, 6)
assert.equal(dir.Links[0].Name, 'about')
assert.equal(dir.Links[5].Name, 'security-notes')

assert.deepEqual(res.Objects[0], objs)
done()
})
})
@@ -313,9 +333,9 @@ describe('IPFS Node.js API wrapper tests', function () {

describe('.object', function () {
var testObject =
Buffer(JSON.stringify({Data: 'testdata', Links: []}))
Buffer(JSON.stringify({Data: 'testdata', Links: []}))
var testObjectHash =
'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD'
'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD'

it('object.put', function (done) {
apiClients['a'].object.put(testObject, 'json', function (err, res) {
@@ -413,8 +433,7 @@ describe('IPFS Node.js API wrapper tests', function () {
})
})

describe('.ping', function () {
})
describe('.ping', function () {})

describe('.id', function () {
it('id', function (done) {
@@ -450,28 +469,31 @@ describe('IPFS Node.js API wrapper tests', function () {
})

describe('.refs', function () {
var initDocs = 'Qmcqtw8FfrVSBaRmbWwHxt3AuySBhJLcvmFYi3Lbc4xnwj'
var initDocsLs = {
'help': 'QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7',
'about': 'QmfE3nUohq2nEYwieF7YFnJF1VfiL4i3wDxkMq8aGUg8Mt',
'readme': 'QmUFtMrBHqdjTtbebsL6YGebvjShh3Jud1insUv12fEVdA',
'contact': 'QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y',
'quick-start': 'QmeEqpsKrvdhuuuVsguHaVdJcPnnUHHZ5qEWjCHavYbNqU',
'security-notes': 'QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ'
}
var folder = 'QmaMTzaGBmdLrispnPRTESta4yDQdK4uKSVcQez2No4h6q'

it.skip('refs', function (done) {
it('refs', function (done) {
this.timeout(10000)
apiClients['a'].refs(initDocs, {'format': '<src> <dst> <linkname>'}, function (err, objs) {
if (err) throw err
for (var i in objs) {
var ref = objs[i]
var refp = ref.Ref.replace('\n', '').split(' ')
assert.equal(refp[0], initDocs)
assert(initDocsLs[refp[2]])
assert.equal(refp[1], initDocsLs[refp[2]])
assert.equal(ref.Err, '')
apiClients['a'].refs(folder, {'format': '<src> <dst> <linkname>'}, function (err, objs) {
if (err) {
throw err
}

var result = [{
Ref: 'QmaMTzaGBmdLrispnPRTESta4yDQdK4uKSVcQez2No4h6q QmaeuuKLHzirbVoTjb3659fyyV381amjaGrU2pecHEWPrN add.js\n',
Err: '' },
{ Ref: 'QmaMTzaGBmdLrispnPRTESta4yDQdK4uKSVcQez2No4h6q QmTQhTtDWeaaP9pttDd1CuoVTLQm1w51ABfjgmGUbCUF6i cat.js\n',
Err: '' },
{ Ref: 'QmaMTzaGBmdLrispnPRTESta4yDQdK4uKSVcQez2No4h6q QmTYFLz5vsdMpq4XXw1a1pSxujJc9Z5V3Aw1Qg64d849Zy files\n',
Err: '' },
{ Ref: 'QmaMTzaGBmdLrispnPRTESta4yDQdK4uKSVcQez2No4h6q QmTjXxUemcuMAZ2KNN3iJGWHwrkMsW8SWEwkYVSBi1nFD9 ipfs-add.js\n',
Err: '' },
{ Ref: 'QmaMTzaGBmdLrispnPRTESta4yDQdK4uKSVcQez2No4h6q QmXYUXDFNNh1wgwtX5QDG7MsuhAAcE9NzDYnz8SjnhvQrK ls.js\n',
Err: '' },
{ Ref: 'QmaMTzaGBmdLrispnPRTESta4yDQdK4uKSVcQez2No4h6q QmUmDmH4hZgN5THnVP1VjJ1YWh5kWuhLGUihch8nFiD9iy version.js\n',
Err: '' } ]

assert.deepEqual(objs, result)

done()
})
})
2 changes: 1 addition & 1 deletion test/tmp-disposable-nodes-addrs.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"a":"/ip4/127.0.0.1/tcp/57144","b":"/ip4/127.0.0.1/tcp/57167","c":"/ip4/127.0.0.1/tcp/57172"}
{"c":"/ip4/127.0.0.1/tcp/58191","b":"/ip4/127.0.0.1/tcp/58198","a":"/ip4/127.0.0.1/tcp/58213"}