Permalink
Browse files

test: beef up test

  • Loading branch information...
1 parent 402b58c commit c6b002057057e6f417d916d9604dc38418e2d48b @bnoordhuis committed Jun 18, 2012
Showing with 19 additions and 3 deletions.
  1. +19 −3 test/test-dgram-unix.js
@@ -1,18 +1,34 @@
-SOCKNAME = '/tmp/unix_dgram.sock';
+var assert = require('assert');
+var fs = require('fs');
var unix = require('../src/unix_dgram');
+var SOCKNAME = '/tmp/unix_dgram.sock';
+
+var sentPing = false;
+var seenPing = false;
+
+process.on('exit', function() {
+ assert.equal(sentPing, true);
+ assert.equal(seenPing, true);
+});
+
+try { fs.unlinkSync(SOCKNAME); } catch (e) { /* swallow */ }
var server = unix.createSocket('unix_dgram', function(buf, rinfo) {
console.error('server recv', arguments);
+ assert.equal('' + buf, 'PING');
+ seenPing = true;
server.close();
client.close();
- console.error('closed', server, client);
});
server.bind(SOCKNAME);
var client = unix.createSocket('unix_dgram', function(buf, rinfo) {
console.error('client recv', arguments);
+ assert(0);
});
+
client.send(Buffer('PING'), 0, 4, SOCKNAME, function() {
console.error('client send', arguments);
-});
+ sentPing = true;
+});

0 comments on commit c6b0020

Please sign in to comment.