Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
add run sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Oct 25, 2015
1 parent 25f9077 commit bc72e36
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
some-test.js
npm-debug.log
sauce_connect.log
28 changes: 20 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ var Server = require('karma').Server
var mocha = require('gulp-mocha')
var ipfsd = require('ipfsd-ctl')
var fs = require('fs')
var runSequence = require('run-sequence')

gulp.task('default', function () {
gulp.start('test:node', 'test:browser')
gulp.task('default', function (done) {
runSequence(
'test:node',
// 'test:browser',
done)
})

gulp.task('test:node', function (done) {
Expand All @@ -19,16 +23,25 @@ gulp.task('test:node', function (done) {
.once('end', function () {
stopDisposableDaemons(daemons, function () {
process.exit()
// done()
})
})
})
})

gulp.task('test:browser', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start()
startDisposableDaemons(function (daemons) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, finish).start()

function finish () {
stopDisposableDaemons(daemons, function () {
done()
})
}
})
})

function startDisposableDaemons (callback) {
Expand All @@ -54,10 +67,9 @@ function startDisposableDaemons (callback) {
throw err
}

console.log('ipfs init done - ' + key)
ipfsNodes[key] = node

console.log('ipfs config (bootstrap and mdns off) - ' + key)
console.log(' ipfs init done - (bootstrap and mdns off) - ' + key)

ipfsNodes[key].setConfig('Bootstrap', null, function (err) {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function (config) {
basePath: '',
frameworks: ['browserify', 'mocha'],
files: [
'test/test.js'
'test/tests.js'
],
exclude: [],
preprocessors: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
"karma-sauce-launcher": "^0.3.0",
"mocha": "^2.3.3",
"pre-commit": "^1.0.6",
"run-sequence": "^1.1.4",
"standard": "^5.2.2",
"uglify-js": "^2.4.24"
},
"scripts": {
"test": "./node_modules/.bin/gulp",
"test:node": "./node_modules/.bin/gulp test:node",
"test:browser": "./node_modules/.bin/gulp test:browser",

"lint": "./node_modules/.bin/standard",
"build": "./node_modules/.bin/browserify -t brfs -s ipfsAPI -e ./src/index.js | tee dist/ipfsapi.js | ./node_modules/.bin/uglifyjs -m > dist/ipfsapi.min.js"
},
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function IpfsAPI (host_or_multiaddr, port) {

self.swarm = {
peers: command('swarm/peers'),
connect: argCommand('swarm/peers')
connect: argCommand('swarm/connect')
}

self.ping = function (id, cb) {
Expand Down
4 changes: 3 additions & 1 deletion test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ describe('IPFS Node.js API wrapper tests', function () {
}

function dial () {
apiClients['a'].swarm.connect(addrs['b'], function (err) {
console.log(addrs)
apiClients['a'].swarm.connect(addrs['b'], function (err, res) {
console.log('->', res)
if (err) {
throw err
}
Expand Down
2 changes: 1 addition & 1 deletion test/tmp-disposable-nodes-addrs.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"b":"/ip4/127.0.0.1/tcp/52153","c":"/ip4/127.0.0.1/tcp/52166","a":"/ip4/127.0.0.1/tcp/52169"}
{"a":"/ip4/127.0.0.1/tcp/56689","b":"/ip4/127.0.0.1/tcp/56694","c":"/ip4/127.0.0.1/tcp/56697"}

0 comments on commit bc72e36

Please sign in to comment.