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

Commit

Permalink
feat: integrate new ipfsd-ctl
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias authored Jan 23, 2018
1 parent 98000af commit 2b1820b
Show file tree
Hide file tree
Showing 34 changed files with 479 additions and 582 deletions.
11 changes: 7 additions & 4 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
'use strict'

const factory = require('./test/ipfs-factory/tasks')
const createServer = require('ipfsd-ctl').createServer

const server = createServer()
module.exports = {
karma: {
files: [{
pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*',
watched: false,
served: true,
included: false
}]
}],
browserNoActivityTimeout: 100 * 1000,
singleRun: true
},
hooks: {
pre: factory.start,
post: factory.stop
pre: server.start.bind(server),
post: server.stop.bind(server)
}
}
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"http": "stream-http"
},
"scripts": {
"test": "aegir test ",
"test:node": "aegir test -t node ",
"test": "aegir test",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser",
"test:webworker": "aegir test -t webworker",
"lint": "aegir lint",
"build": "aegir build",
"release": "aegir release ",
Expand Down Expand Up @@ -65,10 +66,11 @@
"chai": "^4.1.2",
"dirty-chai": "^2.0.1",
"eslint-plugin-react": "^7.5.1",
"go-ipfs-dep": "^0.4.13",
"gulp": "^3.9.1",
"interface-ipfs-core": "~0.40.0",
"interface-ipfs-core": "~0.41.0",
"hapi": "^16.6.2",
"ipfsd-ctl": "~0.26.0",
"ipfsd-ctl": "~0.27.0",
"pre-commit": "^1.2.2",
"socket.io": "^2.0.4",
"socket.io-client": "^2.0.4",
Expand Down
92 changes: 32 additions & 60 deletions test/bitswap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,86 +5,58 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const FactoryClient = require('./ipfs-factory/client')

const IPFSApi = require('../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

describe('.bitswap', function () {
this.timeout(20 * 1000) // slow CI
let ipfs
let fc
let ipfsd = null

before((done) => {
this.timeout(20 * 1000) // slow CI
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, _ipfsd) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = _ipfsd
ipfs = IPFSApi(_ipfsd.apiAddr)
done()
})
})

after((done) => {
fc.dismantle(done)
})

describe('Callback API', () => {
it('.wantlist', (done) => {
ipfs.bitswap.wantlist((err, res) => {
expect(err).to.not.exist()
expect(res).to.have.to.be.eql({
Keys: null
})
done()
})
})

it('.stat', (done) => {
ipfs.bitswap.stat((err, res) => {
expect(err).to.not.exist()
expect(res).to.have.property('BlocksReceived')
expect(res).to.have.property('DupBlksReceived')
expect(res).to.have.property('DupDataReceived')
expect(res).to.have.property('Peers')
expect(res).to.have.property('ProvideBufLen')
expect(res).to.have.property('Wantlist')

done()
})
})
after((done) => ipfsd.stop(done))

it('.unwant', (done) => {
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
ipfs.bitswap.unwant(key, (err) => {
expect(err).to.not.exist()
done()
it('.wantlist', (done) => {
ipfs.bitswap.wantlist((err, res) => {
expect(err).to.not.exist()
expect(res).to.have.to.eql({
Keys: null
})
done()
})
})

describe('Promise API', () => {
it('.wantlist', () => {
return ipfs.bitswap.wantlist()
.then((res) => {
expect(res).to.have.to.be.eql({
Keys: null
})
})
})
it('.stat', (done) => {
ipfs.bitswap.stat((err, res) => {
expect(err).to.not.exist()
expect(res).to.have.property('BlocksReceived')
expect(res).to.have.property('DupBlksReceived')
expect(res).to.have.property('DupDataReceived')
expect(res).to.have.property('Peers')
expect(res).to.have.property('ProvideBufLen')
expect(res).to.have.property('Wantlist')

it('.stat', () => {
return ipfs.bitswap.stat()
.then((res) => {
expect(res).to.have.property('BlocksReceived')
expect(res).to.have.property('DupBlksReceived')
expect(res).to.have.property('DupDataReceived')
expect(res).to.have.property('Peers')
expect(res).to.have.property('ProvideBufLen')
expect(res).to.have.property('Wantlist')
})
done()
})
})

it('.unwant', () => {
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
return ipfs.bitswap.unwant(key)
it('.unwant', (done) => {
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
ipfs.bitswap.unwant(key, (err) => {
expect(err).to.not.exist()
done()
})
})
})
18 changes: 10 additions & 8 deletions test/bootstrap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const FactoryClient = require('./ipfs-factory/client')

const IPFSApi = require('../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

const invalidArg = 'this/Is/So/Invalid/'
const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z'

describe('.bootstrap', function () {
this.timeout(100 * 1000)

let ipfsd
let ipfs
let fc

before((done) => {
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, _ipfsd) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = _ipfsd
ipfs = IPFSApi(_ipfsd.apiAddr)
done()
})
})

after((done) => {
fc.dismantle(done)
})
after((done) => ipfsd.stop(done))

let peers

Expand Down
17 changes: 9 additions & 8 deletions test/commands.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,27 @@ const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const FactoryClient = require('./ipfs-factory/client')
const IPFSApi = require('../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

describe('.commands', function () {
this.timeout(20 * 1000)

let ipfsd
let ipfs
let fc

before((done) => {
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, _ipfsd) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = _ipfsd
ipfs = IPFSApi(_ipfsd.apiAddr)
done()
})
})

after((done) => {
fc.dismantle(done)
})
after((done) => ipfsd.stop(done))

it('lists commands', (done) => {
ipfs.commands((err, res) => {
Expand Down
14 changes: 8 additions & 6 deletions test/constructor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const FactoryClient = require('./ipfs-factory/client')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

const ipfsAPI = require('../src/index.js')

Expand All @@ -22,19 +24,19 @@ function clientWorks (client, done) {
describe('ipfs-api constructor tests', () => {
describe('parameter permuations', () => {
let apiAddr
let fc
let ipfsd

before(function (done) {
this.timeout(20 * 1000) // slow CI
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, node) => {
expect(err).to.not.exist()
apiAddr = node.apiAddr
ipfsd = node
apiAddr = node.apiAddr.toString()
done()
})
})

after((done) => fc.dismantle(done))
after((done) => ipfsd.stop(done))

it('opts', (done) => {
const splitted = apiAddr.split('/')
Expand Down
16 changes: 10 additions & 6 deletions test/diag.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/* eslint-env mocha */
'use strict'

const FactoryClient = require('./ipfs-factory/client')
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const os = require('os')

const IPFSApi = require('../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

describe('.diag', function () {
this.timeout(50 * 1000)

Expand All @@ -16,19 +20,19 @@ describe('.diag', function () {
return
}

let ipfsd
let ipfs
let fc

before((done) => {
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, _ipfsd) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = _ipfsd
ipfs = IPFSApi(_ipfsd.apiAddr)
done()
})
})

after((done) => fc.dismantle(done))
after((done) => ipfsd.stop(done))

describe('Callback API', () => {
// Disabled in go-ipfs 0.4.10
Expand Down
15 changes: 9 additions & 6 deletions test/files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const loadFixture = require('aegir/fixtures')
const mh = require('multihashes')
const CID = require('cids')

const FactoryClient = require('./ipfs-factory/client')
const IPFSApi = require('../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

const testfile = isNode
? loadFixture(__dirname, '/fixtures/testfile.txt')
Expand All @@ -32,21 +35,21 @@ const HASH_ALGS = [
describe('.files (the MFS API part)', function () {
this.timeout(120 * 1000)

let ipfsd
let ipfs
let fc

const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'

before((done) => {
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, _ipfsd) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = _ipfsd
ipfs = IPFSApi(_ipfsd.apiAddr)
done()
})
})

after((done) => fc.dismantle(done))
after((done) => ipfsd.stop(done))

describe('Callback API', function () {
this.timeout(120 * 1000)
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/test-folder/hello-link

This file was deleted.

1 change: 1 addition & 0 deletions test/fixtures/test-folder/hello-link
Loading

0 comments on commit 2b1820b

Please sign in to comment.