Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 6d2e669

Browse files
refactor: use aegir
1 parent fe9fadb commit 6d2e669

File tree

12 files changed

+179
-98
lines changed

12 files changed

+179
-98
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ build/Release
2525
# Dependency directory
2626
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
2727
node_modules
28+
29+
lib
30+
dist

.npmignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# node-waf configuration
20+
.lock-wscript
21+
22+
# Compiled binary addons (http://nodejs.org/api/addons.html)
23+
build/Release
24+
25+
# Dependency directory
26+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27+
node_modules
28+
29+
test

.travis.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- 4
5+
- 5
6+
7+
# Make sure we have new NPM.
8+
before_install:
9+
- npm install -g npm
10+
11+
script:
12+
- npm run lint
13+
- npm test
14+
- npm run coverage
15+
16+
addons:
17+
firefox: 'latest'
18+
19+
before_script:
20+
- export DISPLAY=:99.0
21+
- sh -e /etc/init.d/xvfb start
22+
23+
after_success:
24+
- npm run coverage-publish

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
js-libp2p-railing
22
=================
33

4-
[![](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/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) ![](https://img.shields.io/badge/coverage-%3F-yellow.svg?style=flat-square) [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-railing.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-railing) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
4+
[![](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/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
5+
[![Coverage Status](https://coveralls.io/repos/github/diasdavid/js-libp2p-railing/badge.svg?branch=master)](https://coveralls.io/github/diasdavid/js-libp2p-railing?branch=master)
6+
[![Travis CI](https://travis-ci.org/diasdavid/js-libp2p-railing.svg?branch=master)](https://travis-ci.org/diasdavid/js-libp2p-railing)
7+
[![Circle CI](https://circleci.com/gh/diasdavid/js-libp2p-railing.svg?style=svg)](https://circleci.com/gh/diasdavid/js-libp2p-railing)
8+
[![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-railing.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-railing) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
59

610
> JavaScript libp2p Implementation of the railing process of a Node through a bootstrap peer list
711
@@ -11,7 +15,7 @@ js-libp2p-railing
1115
var Bootstrap = require('ipfs-libp2p')
1216

1317
var options = {
14-
verify: true // to verify that we can indeed open a connection to that peer, before declaring it as peer found
18+
verify: true // to verify that we can indeed open a connection to that peer, before declaring it as peer found
1519
}
1620

1721
var peerList = <your custom peerList> || Bootstrap.default

circle.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
machine:
2+
node:
3+
version: stable
4+
5+
dependencies:
6+
pre:
7+
- google-chrome --version
8+
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
9+
- sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
10+
- sudo apt-get update
11+
- sudo apt-get --only-upgrade install google-chrome-stable
12+
- google-chrome --version

examples/try.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
'use strict'
2+
13
var Bootstrap = require('./../src')
24
var b = new Bootstrap(Bootstrap.default)
5+
6+
console.log(b)

package.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
"name": "libp2p-railing",
33
"version": "0.2.1",
44
"description": "Node.js IPFS Implementation of the railing process of a Node through a bootstrap peer list",
5-
"main": "src/index.js",
5+
"main": "lib/index.js",
66
"scripts": {
7-
"test": "./node_modules/.bin/lab tests/*-test.js"
7+
"test": "aegir-test",
8+
"lint": "aegir-lint",
9+
"test:node": "aegir-test node",
10+
"test:browser": "aegir-test browser",
11+
"build": "aegir-build",
12+
"release": "aegir-release",
13+
"coverage": "aegir-coverage",
14+
"coverage-publish": "aegir-coverage publish"
815
},
916
"repository": {
1017
"type": "git",
@@ -23,17 +30,21 @@
2330
},
2431
"homepage": "https://github.com/diasdavid/js-ipfs-railing",
2532
"devDependencies": {
26-
"code": "^1.4.1",
27-
"lab": "^5.13.0",
33+
"aegir": "^2.1.1",
34+
"chai": "^3.5.0",
2835
"libp2p-swarm": "^0.5.0",
2936
"libp2p-tcp": "^0.1.1",
30-
"pre-commit": "^1.1.1",
31-
"standard": "^4.5.4"
37+
"pre-commit": "^1.1.2"
3238
},
3339
"dependencies": {
3440
"ipfs-logger": "^0.1.0",
3541
"peer-info": "^0.3.0",
3642
"peer-id": "^0.3.0",
3743
"multiaddr": "^1.0.0"
38-
}
44+
},
45+
"jsnext:main": "src/index.js",
46+
"pre-commit": [
47+
"lint",
48+
"test"
49+
]
3950
}

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
var Id = require('peer-id')
24
var Peer = require('peer-info')
35
var multiaddr = require('multiaddr')

test/verify-off.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-env mocha */
2+
'use strict'
3+
4+
var Bootstrap = require('./../src')
5+
6+
describe('Without verify on', function () {
7+
before(function (done) {
8+
done()
9+
})
10+
11+
it('Find the other peer', function (done) {
12+
this.timeout(1e3 * 10)
13+
14+
var bA = new Bootstrap(Bootstrap.default, {
15+
verify: false
16+
})
17+
18+
bA.once('peer', function (peer) {
19+
done()
20+
})
21+
})
22+
})

test/verify-on.spec.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* eslint-env mocha */
2+
'use strict'
3+
4+
var multiaddr = require('multiaddr')
5+
var Id = require('peer-id')
6+
var Peer = require('peer-info')
7+
var Swarm = require('libp2p-swarm')
8+
var tcp = require('libp2p-tcp')
9+
10+
var Broadcast = require('./../src')
11+
12+
var pA
13+
var pB
14+
var swA
15+
var swB
16+
17+
describe('With verify on', function () {
18+
before(function (done) {
19+
var mh1 = multiaddr('/ip4/127.0.0.1/tcp/8010')
20+
pA = new Peer(Id.create(), [])
21+
swA = new Swarm(pA)
22+
swA.addTransport('tcp', tcp, { multiaddr: mh1 }, {}, {port: 8010}, ready)
23+
24+
var mh2 = multiaddr('/ip4/127.0.0.1/tcp/8020')
25+
pB = new Peer(Id.create(), [])
26+
swB = new Swarm(pB)
27+
swB.addTransport('tcp', tcp, { multiaddr: mh2 }, {}, {port: 8020}, ready)
28+
29+
var readyCounter = 0
30+
31+
function ready () {
32+
readyCounter++
33+
if (readyCounter < 2) {
34+
return
35+
}
36+
done()
37+
}
38+
})
39+
40+
after(function (done) {
41+
swA.close()
42+
swB.close()
43+
done()
44+
})
45+
46+
it('Find the other peer', function (done) {
47+
this.timeout(1e3 * 10)
48+
var peerList = [
49+
pB.multiaddrs[0].toString() + '/ipfs/' + pB.id.toB58String()
50+
]
51+
var bA = new Broadcast(peerList, {
52+
verify: true
53+
}, swA)
54+
55+
bA.once('peer', function (peer) {
56+
done()
57+
})
58+
})
59+
})

0 commit comments

Comments
 (0)