Skip to content

Commit

Permalink
Merge pull request #43 from libp2p/feat/update-libp2p
Browse files Browse the repository at this point in the history
feat: new libp2p apis
  • Loading branch information
daviddias authored Apr 3, 2017
2 parents 5ac2122 + 21d8ff5 commit 6612623
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 39 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@
"homepage": "https://github.com/libp2p/js-libp2p-floodsub#readme",
"devDependencies": {
"aegir": "^11.0.1",
"benchmark": "^2.1.3",
"benchmark": "^2.1.4",
"chai": "^3.5.0",
"dirty-chai": "^1.2.2",
"libp2p-ipfs-nodejs": "~0.21.0",
"libp2p-ipfs-nodejs": "~0.23.0",
"lodash.times": "^4.3.2",
"multiaddr": "^2.2.3",
"peer-id": "~0.8.5",
"peer-info": "~0.8.5",
"multiaddr": "^2.3.0",
"peer-id": "~0.8.7",
"peer-info": "~0.9.2",
"pre-commit": "^1.2.2"
},
"dependencies": {
"async": "^2.2.0",
"async": "^2.3.0",
"debug": "^2.6.3",
"length-prefixed-stream": "^1.5.1",
"libp2p-crypto": "~0.8.7",
Expand Down
5 changes: 2 additions & 3 deletions test/2-nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe('basics between 2 nodes', () => {
fsA.once('Z', (msg) => {
fsA.once('Z', shouldNotHappen)
expect(msg.data.toString()).to.equal('banana')

setTimeout(() => {
fsA.removeListener('Z', shouldNotHappen)
fsB.removeListener('Z', shouldNotHappen)
Expand Down Expand Up @@ -137,9 +138,7 @@ describe('basics between 2 nodes', () => {
}
}

_times(10, () => {
fsB.publish('Z', new Buffer('banana'))
})
_times(10, () => fsB.publish('Z', new Buffer('banana')))
})

it('Unsubscribe from topic:Z in nodeA', (done) => {
Expand Down
15 changes: 4 additions & 11 deletions test/multiple-nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ describe('multiple nodes (more than 2)', () => {

it('establish the connections', (done) => {
parallel([
(cb) => {
a.libp2p.dial(b.libp2p.peerInfo, cb)
},
(cb) => {
b.libp2p.dial(c.libp2p.peerInfo, cb)
}
(cb) => a.libp2p.dial(b.libp2p.peerInfo, cb),
(cb) => b.libp2p.dial(c.libp2p.peerInfo, cb)
], (err) => {
expect(err).to.not.exist()
// wait for the pubsub pipes to be established
Expand Down Expand Up @@ -286,11 +282,8 @@ describe('multiple nodes (more than 2)', () => {
// ◉────◎────◉
// a b c

before((done) => {
})

after((done) => {
})
before((done) => {})
after((done) => {})
})

describe('1 level tree', () => {
Expand Down
10 changes: 3 additions & 7 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@ const expect = require('chai').expect
exports.first = (map) => map.values().next().value

exports.expectSet = (set, subs) => {
expect(
Array.from(set.values())
).to.be.eql(
subs
)
expect(Array.from(set.values())).to.eql(subs)
}

exports.createNode = (maddr, callback) => {
waterfall([
(cb) => PeerId.create(cb),
(cb) => PeerId.create({ bits: 1024 }, cb),
(id, cb) => PeerInfo.create(id, cb),
(peer, cb) => {
peer.multiaddr.add(multiaddr(maddr))
peer.multiaddrs.add(multiaddr(maddr))
cb(null, new Node(peer))
},
(node, cb) => {
Expand Down
18 changes: 6 additions & 12 deletions test/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('utils', () => {

expect(first).to.have.length(40)
expect(second).to.have.length(40)
expect(first).to.not.be.eql(second)
expect(first).to.not.eql(second)
})

it('msgId', () => {
Expand All @@ -28,17 +28,11 @@ describe('utils', () => {
[[], [], false],
[[1], [2], false]
].forEach((test) => {
expect(
utils.anyMatch(new Set(test[0]), new Set(test[1]))
).to.be.eql(
test[2]
)

expect(
utils.anyMatch(new Set(test[0]), test[1])
).to.be.eql(
test[2]
)
expect(utils.anyMatch(new Set(test[0]), new Set(test[1])))
.to.eql(test[2])

expect(utils.anyMatch(new Set(test[0]), test[1]))
.to.eql(test[2])
})
})

Expand Down

0 comments on commit 6612623

Please sign in to comment.