Skip to content

Commit

Permalink
Merge pull request #37 from libp2p/feat/new-libp2p-api
Browse files Browse the repository at this point in the history
Use the libp2p simplified API
  • Loading branch information
daviddias authored Mar 27, 2017
2 parents 9d746b7 + 798c2ae commit d73c025
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 27 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-floodsub#readme",
"devDependencies": {
"aegir": "^11.0.0",
"async": "^2.1.4",
"aegir": "^11.0.1",
"async": "^2.2.0",
"benchmark": "^2.1.3",
"chai": "^3.5.0",
"dirty-chai": "^1.2.2",
"libp2p-ipfs-nodejs": "~0.20.0",
"libp2p-ipfs-nodejs": "~0.21.0",
"lodash.times": "^4.3.2",
"multiaddr": "^2.2.1",
"peer-id": "~0.8.2",
"peer-info": "~0.8.3",
"multiaddr": "^2.2.3",
"peer-id": "~0.8.5",
"peer-info": "~0.8.5",
"pre-commit": "^1.2.2"
},
"dependencies": {
"debug": "^2.6.0",
"debug": "^2.6.3",
"length-prefixed-stream": "^1.5.1",
"libp2p-crypto": "~0.8.1",
"libp2p-crypto": "~0.8.7",
"lodash.values": "^4.3.0",
"pull-pushable": "^2.0.1",
"time-cache": "~0.3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class FloodSub extends EventEmitter {
return
}

this.libp2p.dialByPeerInfo(peerInfo, multicodec, (err, conn) => {
this.libp2p.dial(peerInfo, multicodec, (err, conn) => {
if (err) {
return log.err(err)
}
Expand Down
8 changes: 4 additions & 4 deletions test/2-nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('basics between 2 nodes', () => {

it('Dial from nodeA to nodeB', (done) => {
series([
(cb) => nodeA.dialByPeerInfo(nodeB.peerInfo, cb),
(cb) => nodeA.dial(nodeB.peerInfo, cb),
(cb) => setTimeout(() => {
expect(fsA.peers.size).to.equal(1)
expect(fsB.peers.size).to.equal(1)
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('basics between 2 nodes', () => {
})

it('existing subscriptions are sent upon peer connection', (done) => {
nodeA.dialByPeerInfo(nodeB.peerInfo, (err) => {
nodeA.dial(nodeB.peerInfo, (err) => {
expect(err).to.not.exist()
setTimeout(() => {
expect(fsA.peers.size).to.equal(1)
Expand Down Expand Up @@ -288,7 +288,7 @@ describe('basics between 2 nodes', () => {
})

it('peer is removed from the state when connection ends', (done) => {
nodeA.dialByPeerInfo(nodeB.peerInfo, (err) => {
nodeA.dial(nodeB.peerInfo, (err) => {
expect(err).to.not.exist()
setTimeout(() => {
expect(fsA.peers.size).to.equal(1)
Expand Down Expand Up @@ -318,7 +318,7 @@ describe('basics between 2 nodes', () => {
], (cb, nodes) => {
nodeA = nodes[0]
nodeB = nodes[1]
nodeA.dialByPeerInfo(nodeB.peerInfo, () => setTimeout(done, 1000))
nodeA.dial(nodeB.peerInfo, () => setTimeout(done, 1000))
})
})

Expand Down
20 changes: 6 additions & 14 deletions test/multiple-nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ describe('multiple nodes (more than 2)', () => {
it('establish the connections', (done) => {
parallel([
(cb) => {
a.libp2p.dialByPeerInfo(b.libp2p.peerInfo, cb)
a.libp2p.dial(b.libp2p.peerInfo, cb)
},
(cb) => {
b.libp2p.dialByPeerInfo(c.libp2p.peerInfo, cb)
b.libp2p.dial(c.libp2p.peerInfo, cb)
}
], (err) => {
expect(err).to.not.exist()
Expand Down Expand Up @@ -226,18 +226,10 @@ describe('multiple nodes (more than 2)', () => {

it('establish the connections', (done) => {
parallel([
(cb) => {
a.libp2p.dialByPeerInfo(b.libp2p.peerInfo, cb)
},
(cb) => {
b.libp2p.dialByPeerInfo(c.libp2p.peerInfo, cb)
},
(cb) => {
c.libp2p.dialByPeerInfo(d.libp2p.peerInfo, cb)
},
(cb) => {
d.libp2p.dialByPeerInfo(e.libp2p.peerInfo, cb)
}
(cb) => a.libp2p.dial(b.libp2p.peerInfo, cb),
(cb) => b.libp2p.dial(c.libp2p.peerInfo, cb),
(cb) => c.libp2p.dial(d.libp2p.peerInfo, cb),
(cb) => d.libp2p.dial(e.libp2p.peerInfo, cb)
], (err) => {
expect(err).to.not.exist()
// wait for the pubsub pipes to be established
Expand Down

0 comments on commit d73c025

Please sign in to comment.