Created
May 21, 2013 02:50
-
-
Save davidbanham/5617210 to your computer and use it in GitHub Desktop.
Too something to fail.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var upnode = require('../'); | |
var dnode = require('dnode'); | |
var test = require('tap').test; | |
var net = require('net'); | |
test('simple', function (t) { | |
t.plan(1); | |
var port = Math.floor(Math.random() * 5e4 + 1e4); | |
var up = upnode.connect(port); | |
on(); | |
up.on('up', function () { | |
t.throws(function(){ | |
throw new Error('yay'); | |
}, new Error('yay'), 'Thrown error did not match'); // This succeeds even without my added code | |
off(); | |
up.close(); | |
t.end(); | |
}); | |
var server, ds; | |
function on () { | |
server = net.createServer(function (stream) { | |
ds = dnode(function (client, conn) { | |
this.time = function (cb) { cb(Date.now()) }; | |
this.ping = function (cb) { cb() }; | |
}); | |
ds.pipe(stream).pipe(ds); | |
}); | |
server.listen(port); | |
} | |
function off () { | |
ds.end(); | |
server.close(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment