Permalink
Browse files

run streams sync

  • Loading branch information...
1 parent 38b97a3 commit a096926b47829ff44261f9362a798b5ccd94b0f1 @dominictarr committed Mar 13, 2013
Showing with 2 additions and 69 deletions.
  1. +2 −69 test/disconnections.js
View
@@ -87,7 +87,8 @@ test('simple', function simple (a) {
var server = MuxDemux({error: true, wrapper: wrapper})
client.pipe(server).pipe(client)
-
+ client.resume()
+ server.resume()
var r1 = Math.random()
server.on('connection', function (stream) {
stream.on('data', function (data) {
@@ -106,74 +107,6 @@ test('simple', function simple (a) {
});
-test('disconnect', function disconnect (a) {
-
- var client = MuxDemux({error: true, wrapper: wrapper})
- var server = MuxDemux({error: true, wrapper: wrapper})
-
- client.pipe(server).pipe(client)
-
- var randoms = []
- function rand() {
- var r
- randoms.push(r = Math.random())
- return r
- }
- var clientErr = false, serverErr = false
-
- var streams = 0, ended = 0
- server.on('connection', function (stream) {
- streams ++
- stream
- .on('data', function (data) {
- var r
- a.equal(data, r = randoms.shift())
- console.log('data', r)
- })
- .on('error', function () {
- //I'm expecting this
- serverErr = true
- a.equal(streams, 1)
- next()
- })
- var r = Math.random()
- var _ended = false
- stream.on('end', function () {
- a.ok(!_ended, 'end MUST only be emitted once')
- _ended = true
- a.equal(streams, ++ ended)
- console.log('end!!!!')
-// a.end()
- })
- })
-
- var c = client.createWriteStream('A')
- c.on('error', function (err) {
- //expecting this!
- clientErr = true
- next()
- })
-
- var n = 1
- function next() {
- if(n--) return
- a.ok(clientErr, 'expected client to emit an error')
- a.ok(serverErr, 'expected server to emit an error')
- console.log('end point emitted errors correctly')
- a.end()
- }
-
- c.write(rand())
- c.write(rand())
- c.write(rand())
- c.write(rand())
- client.destroy()
-
- if(c.writable)
- c.write(rand())
- a.throws(function () { c.write(rand()) })
-
-});
}

0 comments on commit a096926

Please sign in to comment.