Merge pull request #52 from diasdavid/fix/warm-a-warm-up-the-other-way-around

make sure it does not try to dial on empty proto and write tests for it
This commit is contained in:
David Dias
2016-05-09 08:16:41 +01:00
2 changed files with 24 additions and 5 deletions

View File

@@ -246,6 +246,9 @@ function Swarm (peerInfo) {
gotWarmedUpConn(conn)
}
} else {
if (!protocol) {
return callback()
}
gotMuxer(this.muxedConns[b58Id].muxer)
}

View File

@@ -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())
})
@@ -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)