Skip to content

Instantly share code, notes, and snippets.

@daviddias daviddias/test.js
Created Jan 18, 2017

Embed
What would you like to do?
test('underlying error is propagated to muxed streams', function (t) {
t.plan(2)
var plex1 = multiplex()
var plex2 = multiplex()
var socket
plex2.on('stream', function (stream) {
console.log('stream incomming plex2')
stream.on('error', function (err) {
t.ok(err)
})
socket.destroy('no more socket')
})
var stream1to2 = plex1.createStream(1337)
stream1to2.on('error', function (err) {
t.ok(err)
})
stream1to2.write('hey')
var server = net.createServer(function (stream) {
pump(plex2, stream)
pump(stream, plex2)
})
server.listen(0, function () {
var port = server.address().port
socket = net.connect(port)
socket.on('error', function () {
console.log('error')
plex1.emit('error', 'eeeerrr')
})
pump(plex1, socket, function () {
console.log('pipe finished')
})
pump(socket, plex1)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.