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

Async Crypto Endeavour #99

Merged
merged 8 commits into from
Nov 11, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ready
  • Loading branch information
dignifiedquire committed Nov 2, 2016
commit 5b6cdb9cba6c2025812e1bbbd62b05df5fbab227
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ node_modules
# Optional REPL history
.node_repl_history

lib
dist
24 changes: 18 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
sudo: false
language: node_js
node_js:
- 4
- stable
matrix:
include:
- node_js: 4
env: CXX=g++-4.8
- node_js: 6
env:
- SAUCE=true
- CXX=g++-4.8
- node_js: stable
env: CXX=g++-4.8

# Make sure we have new NPM.
before_install:
Expand All @@ -13,12 +20,17 @@ script:
- npm test
- npm run coverage

addons:
firefox: 'latest'

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

after_success:
- npm run coverage-publish

addons:
firefox: 'latest'
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
[![Travis CI](https://travis-ci.org/ipfs/js-libp2p-ipfs-browser.svg?branch=master)](https://travis-ci.org/ipfs/js-libp2p-ipfs-browser)
[![Circle CI](https://circleci.com/gh/ipfs/js-libp2p-ipfs-browser.svg?style=svg)](https://circleci.com/gh/ipfs/js-libp2p-ipfs-browser)
[![Dependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs-browser.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs-browser) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square)

[![Sauce Test Status](https://saucelabs.com/browser-matrix/libp2p-ipfs-browser.svg)](https://saucelabs.com/u/libp2p-ipfs-browser)

> libp2p build (module) used in js-ipfs when running it on the browser.

Expand Down
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
"name": "libp2p-ipfs-browser",
"version": "0.15.1",
"description": "libp2p build (module) used in js-ipfs when running it on the browser",
"main": "lib/index.js",
"jsnext:main": "src/index.js",
"main": "src/index.js",
"pre-commit": [
"lint",
"test"
],
"scripts": {
"lint": "aegir-lint",
"test": "PHANTOM=off gulp test",
"test": "gulp test",
"test:node": "gulp test:node",
"test:browser": "PHANTOM=off gulp test:browser",
"test:browser": "gulp test:browser",
"build": "gulp build",
"release": "PHANTOM=off gulp release",
"release-minor": "PHANTOM=off gulp release --type minor",
"release-major": "PHANTOM=off gulp release --type major",
"release": "gulp release",
"release-minor": "gulp release --type minor",
"release-major": "gulp release --type major",
"coverage": "gulp coverage",
"coverage-publish": "aegir-coverage publish"
},
Expand All @@ -31,7 +30,8 @@
},
"homepage": "https://github.com/ipfs/js-libp2p-ipfs-browser#readme",
"devDependencies": {
"aegir": "^8.0.1",
"aegir": "^9.0.0",
"async": "^2.1.2",
"chai": "^3.5.0",
"gulp": "^3.9.1",
"libp2p-ipfs": "^0.14.1",
Expand All @@ -40,11 +40,9 @@
"pull-goodbye": "0.0.1",
"pull-serializer": "^0.3.2",
"pull-stream": "^3.4.5",
"run-parallel": "^1.1.6",
"webrtcsupport": "^2.2.0"
},
"dependencies": {
"babel-runtime": "^6.11.6",
"libp2p-secio": "^0.5.0",
"libp2p-spdy": "^0.9.0",
"libp2p-swarm": "^0.23.0",
Expand Down
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ exports.Node = function Node (pInfo, pBook) {
}

if (!pInfo) {
pInfo = new PeerInfo()
pInfo.multiaddr.add(multiaddr('/ip4/0.0.0.0/tcp/0'))
throw new Error('missing peer info')
}

if (!pBook) {
Expand Down
66 changes: 37 additions & 29 deletions test/webrtc-star-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
const expect = require('chai').expect
const multiaddr = require('multiaddr')
const PeerInfo = require('peer-info')
const peerId = require('peer-id')
const parallel = require('run-parallel')
const PeerId = require('peer-id')
const parallel = require('async/parallel')
const pull = require('pull-stream')

const libp2p = require('../src')
Expand All @@ -19,17 +19,22 @@ describe('libp2p-ipfs-browser (webrtc only)', function () {
let node2

it('create two peerInfo with webrtc-star addrs', (done) => {
const id1 = peerId.create()
peer1 = new PeerInfo(id1)
const mh1 = multiaddr('/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/' + id1.toB58String())
peer1.multiaddr.add(mh1)
parallel([
(cb) => PeerId.create(cb),
(cb) => PeerId.create(cb)
], (err, ids) => {
expect(err).to.not.exist

const id2 = peerId.create()
peer2 = new PeerInfo(id2)
const mh2 = multiaddr('/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/' + id2.toB58String())
peer2.multiaddr.add(mh2)
peer1 = new PeerInfo(ids[0])
const mh1 = multiaddr('/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/' + ids[0].toB58String())
peer1.multiaddr.add(mh1)

done()
peer2 = new PeerInfo(ids[1])
const mh2 = multiaddr('/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/' + ids[1].toB58String())
peer2.multiaddr.add(mh2)

done()
})
})

it('create two libp2p nodes with those peers', (done) => {
Expand Down Expand Up @@ -95,25 +100,28 @@ describe('libp2p-ipfs-browser (webrtc only)', function () {
})

it('create a third node and check that discovery works', (done) => {
const id3 = peerId.create()
const peer3 = new PeerInfo(id3)
const mh3 = multiaddr('/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/' + id3.toB58String())
peer3.multiaddr.add(mh3)

node1.discovery.on('peer', (peerInfo) => {
node1.dialByPeerInfo(peerInfo, () => {})
})
node2.discovery.on('peer', (peerInfo) => {
node2.dialByPeerInfo(peerInfo, () => {})
})
PeerId.create((err, id3) => {
expect(err).to.not.exist

const node3 = new libp2p.Node(peer3)
node3.start(() => {
setTimeout(() => {
expect(Object.keys(node1.swarm.muxedConns).length).to.equal(1)
expect(Object.keys(node2.swarm.muxedConns).length).to.equal(1)
done()
}, 2000)
const peer3 = new PeerInfo(id3)
const mh3 = multiaddr('/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/' + id3.toB58String())
peer3.multiaddr.add(mh3)

node1.discovery.on('peer', (peerInfo) => {
node1.dialByPeerInfo(peerInfo, () => {})
})
node2.discovery.on('peer', (peerInfo) => {
node2.dialByPeerInfo(peerInfo, () => {})
})

const node3 = new libp2p.Node(peer3)
node3.start(() => {
setTimeout(() => {
expect(Object.keys(node1.swarm.muxedConns).length).to.equal(1)
expect(Object.keys(node2.swarm.muxedConns).length).to.equal(1)
done()
}, 2000)
})
})
})
})
9 changes: 7 additions & 2 deletions test/websockets-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ describe('libp2p-ipfs-browser (websockets only)', () => {
nodeA.stop(done)
})

it('create libp2pNode', () => {
nodeA = new libp2p.Node()
it('create libp2pNode', (done) => {
PeerInfo.create((err, info) => {
expect(err).to.not.exist
info.multiaddr.add(multiaddr('/ip4/0.0.0.0/tcp/0'))
nodeA = new libp2p.Node(info)
done()
})
})

it('start libp2pNode', (done) => {
Expand Down