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

Commit

Permalink
Merge pull request #96 from ipfs/tests-update
Browse files Browse the repository at this point in the history
update tests to run against 0.3.9
  • Loading branch information
daviddias committed Nov 2, 2015
2 parents b7d9c6b + 883c4c7 commit cc9ec51
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
IPFS API wrapper library in JavaScript
======================================

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freejs-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) [![Dependency Status](https://david-dm.org/ipfs/js-ipfs-api.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-api)
[![Circle CI](https://circleci.com/gh/ipfs/js-ipfs-api.svg?style=svg)](https://circleci.com/gh/ipfs/js-ipfs-api)
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freejs-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) [![Dependency Status](https://david-dm.org/ipfs/js-ipfs-api.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-api) [![Circle CI](https://circleci.com/gh/ipfs/js-ipfs-api.svg?style=svg)](https://circleci.com/gh/ipfs/js-ipfs-api)

> A client library for the IPFS API.
# Usage

### NOTE - Current version only supports IPFS 0.3.7

## Installing the module

### In Node.js Through npm
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
"browserify": "^11.0.0",
"concurrently": "^0.1.1",
"eslint-config-standard": "^4.4.0",
"eslint-plugin-standard": "^1.3.1",
"gulp": "^3.9.0",
"gulp-eslint": "^1.0.0",
"gulp-load-plugins": "^1.0.0",
"gulp-mocha": "^2.1.3",
"ipfsd-ctl": "^0.5.5",
"ipfsd-ctl": "^0.6.0",
"karma": "^0.13.11",
"karma-browserify": "^4.4.0",
"karma-chrome-launcher": "^0.2.1",
Expand Down
46 changes: 25 additions & 21 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('IPFS Node.js API wrapper tests', function () {
throw err
}
var added = res[res.length - 1]
assert.equal(added.Hash, 'QmaMTzaGBmdLrispnPRTESta4yDQdK4uKSVcQez2No4h6q')
assert.equal(added.Hash, 'QmZdsefMGMeG6bL719gX44XSVQrL6psEgRZdw1SGadFaK2')
done()
})
})
Expand Down Expand Up @@ -475,6 +475,7 @@ describe('IPFS Node.js API wrapper tests', function () {
if (err) {
throw err
}

apiClients['a'].ping(id.ID, function (err, res) {
if (err) {
throw err
Expand Down Expand Up @@ -505,7 +506,7 @@ describe('IPFS Node.js API wrapper tests', function () {
it('.pin.add', function (done) {
this.timeout(5000)

apiClients['b'].pin.add('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', function (err, res) {
apiClients['b'].pin.add('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', {recursive: false}, function (err, res) {
if (err) {
throw err
}
Expand All @@ -529,12 +530,12 @@ describe('IPFS Node.js API wrapper tests', function () {
it('.pin.remove', function (done) {
this.timeout(5000)

apiClients['b'].pin.remove('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', {recursive: true}, function (err, res) {
apiClients['b'].pin.remove('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', {recursive: false}, function (err, res) {
if (err) {
throw err
}
assert(res)
apiClients['b'].pin.list(function (err, res) {
apiClients['b'].pin.list('direct', function (err, res) {
if (err) {
throw err
}
Expand Down Expand Up @@ -601,17 +602,17 @@ describe('IPFS Node.js API wrapper tests', function () {
}

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

assert.deepEqual(objs, result)
Expand All @@ -635,20 +636,23 @@ describe('IPFS Node.js API wrapper tests', function () {
it('puts and gets a key value pair in the DHT', function (done) {
this.timeout(20000)

apiClients['a'].dht.put('scope', 'interplanetary', function (err, cb) {
assert(!err)
apiClients['a'].dht.put('scope', 'interplanetary', function (err, res) {
if (err) {
done()
return
throw err
}

apiClients['a'].dht.get('scope', function (err, value) {
if (err) {
throw err
}
assert.equal(value, 'interplanetary')
done()
})
return done()

// non ipns or pk hashes fail to fetch, known bug
// bug: https://github.com/ipfs/go-ipfs/issues/1923#issuecomment-152932234
// apiClients['a'].dht.get('scope', function (err, value) {
// console.log('->>', err, value)
// if (err) {
// throw err
// }
// assert.equal(value, 'interplanetary')
// done()
// })
})
})

Expand Down

0 comments on commit cc9ec51

Please sign in to comment.