Skip to content

Commit

Permalink
Fix forward fd test
Browse files Browse the repository at this point in the history
  • Loading branch information
jfd committed Mar 5, 2011
1 parent d60370c commit 23471c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
14 changes: 9 additions & 5 deletions test/messaging/forward-fd/test.js
Expand Up @@ -24,11 +24,15 @@ for (var i = 0; i < POOL_SIZE; i++) {
spawn("./worker");
}

server = createServer(function(socket) {
master.send("hook-fd", socket, function(msg, status) {
equal(status, 'OK');
socket.destroy();
})
server = createServer(function(sock) {
var req;

req = master.send("hook", sock);

req.receive = function ok(msg) {
sock.destroy();
};

});
server.listen(TCP_PORT, TCP_HOST);

Expand Down
22 changes: 8 additions & 14 deletions test/messaging/forward-fd/worker.js
@@ -1,28 +1,22 @@
const Socket = require("net").Socket
, equal = require("assert").equal
, ok = require("assert").ok
, createChannel = require("../../../lib").createChannel
, send = require("../../../lib/").send
, mmatch = require("../../../lib/").mmatch
, when = require("../../../lib/").when
, Fd = require("../../../lib/").Fd

var worker = null

worker = createChannel("resp");
worker.connect("proc://worker-pool");
worker.on("message", function(msg) {
var socket;
worker.receive = function hook(msg, fd) {
var sock;

equal(msg.graph[0], "hook-fd");
ok(typeof msg.graph[1] == "number");
ok(typeof fd == "number");

socket = new Socket(msg.graph[1]);
socket.on("data", function(data) {
sock = new Socket(fd);
sock.on("data", function(data) {
this.write(data);
});

socket.resume();
sock.resume();

msg.ok();
});
msg.ok();
};

0 comments on commit 23471c7

Please sign in to comment.