Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
Merge pull request #52 from diasdavid/fix/warm-a-warm-up-the-other-wa…
Browse files Browse the repository at this point in the history
…y-around

make sure it does not try to dial on empty proto and write tests for it
  • Loading branch information
daviddias committed May 9, 2016
2 parents 20994f5 + 074e7e3 commit 5c76907
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ function Swarm (peerInfo) {
gotWarmedUpConn(conn)
}
} else {
if (!protocol) {
return callback()
}
gotMuxer(this.muxedConns[b58Id].muxer)
}

Expand Down
26 changes: 21 additions & 5 deletions test/09-swarm-with-muxing.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ describe('high level API - with everything mixed all together!', function () {

it.skip('add multiplex', (done) => {})

it('dial from tcp to tcp+ws', (done) => {
swarmB.handle('/anona/1.0.0', (conn) => {
conn.pipe(conn)
})

it('warm up from A to B on tcp to tcp+ws', (done) => {
swarmB.once('peer-mux-established', (peerInfo) => {
expect(peerInfo.id.toB58String()).to.equal(peerA.id.toB58String())
})
Expand All @@ -138,6 +134,26 @@ describe('high level API - with everything mixed all together!', function () {
expect(peerInfo.id.toB58String()).to.equal(peerB.id.toB58String())
})

swarmA.dial(peerB, (err) => {
expect(err).to.not.exist
expect(Object.keys(swarmA.muxedConns).length).to.equal(1)
done()
})
})

it('warm up a warmed up, from B to A', (done) => {
swarmB.dial(peerA, (err) => {
expect(err).to.not.exist
expect(Object.keys(swarmA.muxedConns).length).to.equal(1)
done()
})
})

it('dial from tcp to tcp+ws, on protocol', (done) => {
swarmB.handle('/anona/1.0.0', (conn) => {
conn.pipe(conn)
})

swarmA.dial(peerB, '/anona/1.0.0', (err, conn) => {
expect(err).to.not.exist
expect(Object.keys(swarmA.muxedConns).length).to.equal(1)
Expand Down

0 comments on commit 5c76907

Please sign in to comment.