test-unix-domain-socket.js 759 B

123456789101112131415161718192021222324252627282930313233
  1. var common = require('../../common');
  2. var connection = common.createConnection({socketPath: common.fakeServerSocket});
  3. var assert = require('assert');
  4. var server = common.createFakeServer();
  5. var didConnect = false;
  6. server.listen(common.fakeServerSocket, function(err) {
  7. if (err) throw err;
  8. connection.connect(function(err) {
  9. if (err) throw err;
  10. assert.equal(didConnect, false);
  11. didConnect = true;
  12. connection.destroy();
  13. server.destroy();
  14. });
  15. });
  16. var hadConnection = false;
  17. server.on('connection', function(connection) {
  18. connection.handshake();
  19. assert.equal(hadConnection, false);
  20. hadConnection = true;
  21. });
  22. process.on('exit', function() {
  23. assert.equal(didConnect, true);
  24. assert.equal(hadConnection, true);
  25. });