mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-22 07:12:30 +00:00
fix: improve the close test
This commit is contained in:
parent
f8569f2586
commit
d9c868195a
@ -35,8 +35,6 @@ module.exports = (common) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('closing underlying socket closes streams (tcp)', (done) => {
|
it('closing underlying socket closes streams (tcp)', (done) => {
|
||||||
expect(2).checks(done)
|
|
||||||
|
|
||||||
const tcp = new Tcp()
|
const tcp = new Tcp()
|
||||||
const tcpListener = tcp.createListener((conn) => {
|
const tcpListener = tcp.createListener((conn) => {
|
||||||
const listener = muxer.listener(conn)
|
const listener = muxer.listener(conn)
|
||||||
@ -45,11 +43,21 @@ module.exports = (common) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Wait for the streams to open
|
||||||
|
expect(2).checks(() => {
|
||||||
|
// Once everything is closed, we're done
|
||||||
|
expect(3).checks(done)
|
||||||
|
tcpListener.close((err) => {
|
||||||
|
expect(err).to.not.exist.mark()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
tcpListener.listen(mh, () => {
|
tcpListener.listen(mh, () => {
|
||||||
const dialerConn = tcp.dial(mh, tcpListener.close)
|
const dialerConn = tcp.dial(mh, () => {
|
||||||
|
|
||||||
const dialerMuxer = muxer.dialer(dialerConn)
|
const dialerMuxer = muxer.dialer(dialerConn)
|
||||||
const s1 = dialerMuxer.newStream(() => {
|
const s1 = dialerMuxer.newStream((err) => {
|
||||||
|
expect(err).to.not.exist.mark()
|
||||||
pull(
|
pull(
|
||||||
s1,
|
s1,
|
||||||
pull.onEnd((err) => {
|
pull.onEnd((err) => {
|
||||||
@ -58,7 +66,8 @@ module.exports = (common) => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const s2 = dialerMuxer.newStream(() => {
|
const s2 = dialerMuxer.newStream((err) => {
|
||||||
|
expect(err).to.not.exist.mark()
|
||||||
pull(
|
pull(
|
||||||
s2,
|
s2,
|
||||||
pull.onEnd((err) => {
|
pull.onEnd((err) => {
|
||||||
@ -68,6 +77,7 @@ module.exports = (common) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('closing one of the muxed streams doesn\'t close others', (done) => {
|
it('closing one of the muxed streams doesn\'t close others', (done) => {
|
||||||
const p = pair()
|
const p = pair()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user