Skip to content

Commit

Permalink
Merge pull request libp2p#34 from dignifiedquire/dignfied
Browse files Browse the repository at this point in the history
Use dignified.js
  • Loading branch information
daviddias committed Apr 14, 2016
2 parents d7a0246 + cea42f5 commit 7906f05
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 95 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ node_modules


coverage
.jshintrc
.jshintignore

dist
lib
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
sudo: false
language: node_js
node_js:
- "4.0"
- 4
- 5

# Make sure we have new NPM.
before_install:
Expand Down
33 changes: 13 additions & 20 deletions tests/browser-nodejs/test.js → gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
const Server = require('karma').Server
const path = require('path')
'use strict'

const gulp = require('gulp')
const Peer = require('peer-info')
const Id = require('peer-id')
const WebSockets = require('libp2p-websockets')
const Swarm = require('./../../src')

const Swarm = require('./src')
const multiaddr = require('multiaddr')

var swarmA
var swarmB
let swarmA
let swarmB

function createListeners (done) {
gulp.task('test:browser:before', (done) => {
function createListenerA (cb) {
const b58IdA = 'QmWg2L4Fucx1x4KXJTfKHGixBJvveubzcd7DdhB2Mqwfh1'
const peerA = new Peer(Id.createFromB58String(b58IdA))
Expand All @@ -35,7 +36,7 @@ function createListeners (done) {
swarmB.handle('/echo/1.0.0', echo)
}

var count = 0
let count = 0
const ready = () => ++count === 2 ? done() : null

createListenerA(ready)
Expand All @@ -44,22 +45,14 @@ function createListeners (done) {
function echo (conn) {
conn.pipe(conn)
}
}
})

function stop (done) {
var count = 0
gulp.task('test:browser:after', (done) => {
let count = 0
const ready = () => ++count === 2 ? done() : null

swarmA.transport.close('ws', ready)
swarmB.transport.close('ws', ready)
}

function run (done) {
const karma = new Server({
configFile: path.join(__dirname, '../../karma.conf.js')
}, done)

karma.start()
}
})

createListeners(() => run(() => stop(() => null)))
require('dignified.js/gulp')(gulp)
54 changes: 0 additions & 54 deletions karma.conf.js

This file was deleted.

38 changes: 21 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
"name": "libp2p-swarm",
"version": "0.9.2",
"description": "libp2p swarm implementation in JavaScript",
"main": "src/index.js",
"main": "lib/index.js",
"jsnext:main": "src/index.js",
"scripts": {
"test:node": "mocha tests/*-test.js",
"test:browser": "node tests/browser-nodejs/test.js",
"test": "npm run test:node && npm run test:browser",
"coverage": "istanbul cover --print both -- _mocha tests/*-test.js",
"lint": "standard"
"lint": "dignified-lint",
"build": "dignified-build",
"test": "gulp test",
"test:node": "gulp test:node",
"test:browser": "gulp test:browser",
"release": "dignified-release",
"coverage": "istanbul cover --print both -- _mocha test/node.js"
},
"repository": {
"type": "git",
Expand All @@ -34,31 +37,32 @@
"bl": "^1.1.2",
"buffer-loader": "0.0.1",
"chai": "^3.5.0",
"dignified.js": "^1.0.0",
"gulp": "^3.9.1",
"istanbul": "^0.4.2",
"json-loader": "^0.5.4",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.2",
"karma-firefox-launcher": "^0.1.7",
"karma-mocha": "^0.2.2",
"karma-spec-reporter": "0.0.24",
"karma-webpack": "^1.7.0",
"libp2p-multiplex": "^0.2.1",
"libp2p-spdy": "^0.2.3",
"libp2p-tcp": "^0.4.0",
"libp2p-websockets": "^0.2.1",
"mocha": "^2.4.5",
"multiaddr": "^1.3.0",
"peer-id": "^0.6.0",
"peer-info": "^0.6.0",
"pre-commit": "^1.1.2",
"standard": "^6.0.7",
"stream-pair": "^1.0.3",
"webpack": "^2.1.0-beta.4"
"stream-pair": "^1.0.3"
},
"dependencies": {
"duplex-passthrough": "github:diasdavid/duplex-passthrough",
"ip-address": "^5.0.2",
"multistream-select": "^0.6.1",
"protocol-buffers-stream": "^1.2.0"
},
"dignified": {
"webpack": {
"resolve": {
"alias": {
"node-forge": "../deps/forge.bundle.js"
}
}
}
}
}
2 changes: 2 additions & 0 deletions src/identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* established, so a conn can be reused
*/

'use strict'

const multistream = require('multistream-select')
const fs = require('fs')
const path = require('path')
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const multistream = require('multistream-select')
const identify = require('./identify')
const DuplexPassThrough = require('duplex-passthrough')
Expand Down
1 change: 1 addition & 0 deletions tests/00-basic-test.js → test/00-basic.node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
'use strict'

describe('transport - utp', function () {
this.timeout(10000)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
'use strict'

describe('secio conn upgrade (on TCP)', function () {
this.timeout(20000)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
'use strict'

describe('tls conn upgrade (on TCP)', function () {
before((done) => { done() })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect

Expand Down
4 changes: 3 additions & 1 deletion tests/browser-nodejs/browser.js → test/browser.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect
const multiaddr = require('multiaddr')
const Id = require('peer-id')
const Peer = require('peer-info')
const Swarm = require('./../../src')
const WebSockets = require('libp2p-websockets')
const bl = require('bl')

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

describe('basics', () => {
it('throws on missing peerInfo', (done) => {
expect(Swarm).to.throw(Error)
Expand Down
12 changes: 12 additions & 0 deletions test/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-env mocha */
'use strict'

const fs = require('fs')

describe('libp2p-swarm', () => {
fs.readdirSync(__dirname)
.filter((file) => file.match(/\.node\.js$/))
.forEach((file) => {
require(`./${file}`)
})
})

0 comments on commit 7906f05

Please sign in to comment.