mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-18 21:41:20 +00:00
Return conn on swarm.dial
This commit is contained in:
parent
f2df5586d5
commit
c726c252df
@ -197,6 +197,8 @@ function Swarm (peerInfo) {
|
|||||||
gotMuxer(this.muxedConns[b58Id].muxer)
|
gotMuxer(this.muxedConns[b58Id].muxer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return pt
|
||||||
|
|
||||||
function gotWarmedUpConn (conn) {
|
function gotWarmedUpConn (conn) {
|
||||||
attemptMuxerUpgrade(conn, (err, muxer) => {
|
attemptMuxerUpgrade(conn, (err, muxer) => {
|
||||||
if (!protocol) {
|
if (!protocol) {
|
||||||
|
@ -336,6 +336,19 @@ describe('high level API - 1st without stream multiplexing (on TCP)', function (
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('dial on protocol (returned conn)', (done) => {
|
||||||
|
swarmB.handle('/apples/1.0.0', (conn) => {
|
||||||
|
conn.pipe(conn)
|
||||||
|
})
|
||||||
|
|
||||||
|
const conn = swarmA.dial(peerB, '/apples/1.0.0', (err) => {
|
||||||
|
expect(err).to.not.exist
|
||||||
|
})
|
||||||
|
conn.end()
|
||||||
|
conn.on('data', () => {}) // let it flow.. let it flooooow
|
||||||
|
conn.on('end', done)
|
||||||
|
})
|
||||||
|
|
||||||
it('dial to warm a conn', (done) => {
|
it('dial to warm a conn', (done) => {
|
||||||
swarmA.dial(peerB, (err) => {
|
swarmA.dial(peerB, (err) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist
|
||||||
@ -618,6 +631,21 @@ describe('high level API - with everything mixed all together!', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('dial from tcp to tcp+ws (returned conn)', (done) => {
|
||||||
|
swarmB.handle('/grapes/1.0.0', (conn) => {
|
||||||
|
conn.pipe(conn)
|
||||||
|
})
|
||||||
|
|
||||||
|
const conn = swarmA.dial(peerB, '/grapes/1.0.0', (err, conn) => {
|
||||||
|
expect(err).to.not.exist
|
||||||
|
expect(Object.keys(swarmA.muxedConns).length).to.equal(1)
|
||||||
|
})
|
||||||
|
conn.end()
|
||||||
|
|
||||||
|
conn.on('data', () => {}) // let it flow.. let it flooooow
|
||||||
|
conn.on('end', done)
|
||||||
|
})
|
||||||
|
|
||||||
it('dial from tcp+ws to tcp+ws', (done) => {
|
it('dial from tcp+ws to tcp+ws', (done) => {
|
||||||
swarmC.handle('/mamao/1.0.0', (conn) => {
|
swarmC.handle('/mamao/1.0.0', (conn) => {
|
||||||
conn.pipe(conn)
|
conn.pipe(conn)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user