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

make sure it does not try to dial on empty proto and write tests for it #52

Merged
merged 1 commit into from
May 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
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