updated TLS socket examples
This commit is contained in:
parent
ae5685fd19
commit
b51b57b987
20 changed files with 27 additions and 732 deletions
|
@ -10,8 +10,8 @@ var ipc=require('../../../node-ipc');
|
|||
ipc.config.id = 'world';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key'
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
||||
}
|
||||
|
||||
var messages={
|
||||
|
|
|
@ -10,11 +10,11 @@ var ipc=require('../../../node-ipc');
|
|||
ipc.config.id = 'hello';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.tls={
|
||||
private: '../../../local-node-ipc-certs/private/client.key',
|
||||
public: '../../../local-node-ipc-certs/client.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/client.key',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/client.pub',
|
||||
rejectUnauthorized:false,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/server.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/server.pub'
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
@ -10,13 +10,13 @@ var ipc=require('../../../node-ipc');
|
|||
ipc.config.id = 'world';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: '../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: __dirname+'/../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
requestCert: true,
|
||||
rejectUnauthorized:false,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/client.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ ipc.config.id = 'hello';
|
|||
ipc.config.retry= 1500;
|
||||
ipc.config.networkHost='localhost';
|
||||
ipc.config.tls={
|
||||
private: '../../../local-node-ipc-certs/private/client.key',
|
||||
public: '../../../local-node-ipc-certs/client.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/client.key',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/client.pub',
|
||||
rejectUnauthorized:true,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/server.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/server.pub'
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ ipc.config.id = 'world';
|
|||
ipc.config.retry= 1500;
|
||||
ipc.config.networkHost='localhost';
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: '../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: __dirname+'/../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
requestCert: true,
|
||||
rejectUnauthorized:true,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/client.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ var ipc=require('../../../node-ipc');
|
|||
ipc.config.id = 'world';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key'
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
||||
}
|
||||
|
||||
ipc.serveNet(
|
||||
|
|
|
@ -11,8 +11,8 @@ ipc.config.id = 'world';
|
|||
ipc.config.retry= 1500;
|
||||
ipc.config.sync= true;
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key'
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
||||
}
|
||||
|
||||
ipc.serveNet(
|
||||
|
|
|
@ -14,11 +14,11 @@ ipc.config.encoding='ascii';
|
|||
ipc.config.networkHost='localhost';
|
||||
|
||||
ipc.config.tls={
|
||||
private: '../../../local-node-ipc-certs/private/client.key',
|
||||
public: '../../../local-node-ipc-certs/client.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/client.key',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/client.pub',
|
||||
rejectUnauthorized:true,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/server.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/server.pub'
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@ ipc.config.encoding='ascii';
|
|||
ipc.config.networkHost='localhost';
|
||||
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: '../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: __dirname+'/../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
requestCert: true,
|
||||
rejectUnauthorized:true,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/client.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
#node-ipc test harness
|
||||
***TestHarness was intended to be run on linux.***
|
||||
*the test.js file is intended to start and run all of the files in the test folder*
|
||||
|
||||
A full regression test should be done before each release to npm to insure that no expected or previously documented bugs pop up again.
|
||||
This will also help to ensure that each new release does not create any additional bugs. However, it can never fully ensure no new bugs will be created.
|
||||
Any bug that is reported and testable, which should be 99.9% of bugs, should have a test written and added to the test folder after fixing.
|
||||
|
||||
> Written with [StackEdit](https://stackedit.io/).
|
|
@ -1,170 +0,0 @@
|
|||
var ipc = require('../node-ipc'),
|
||||
cmd = require('node-cmd'),
|
||||
fs = require('fs'),
|
||||
tests = {},
|
||||
testCount=0,
|
||||
fails=[],
|
||||
passes=[],
|
||||
debug=true;
|
||||
|
||||
ipc.config.id = 'testHarness';
|
||||
|
||||
ipc.serve(
|
||||
function(){
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'pass',
|
||||
function(test,socket){
|
||||
ipc.log(socket.id.good,'passed',test.data);
|
||||
tests[socket.id].pass.push(test);
|
||||
passes.push(test);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'fail',
|
||||
function(test,socket){
|
||||
ipc.log(socket.id.warn,'failed',test.data);
|
||||
tests[socket.id].fail.push(test);
|
||||
fails.push(test);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'start.test',
|
||||
function(data,socket){
|
||||
|
||||
socket.id=data.id;
|
||||
|
||||
if(!data.id){
|
||||
ipc.log('start.test duration not passed for unknown test, so failing test'.error);
|
||||
socket.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!data.duration){
|
||||
ipc.log(data.id.notice, 'start.test duration not passed, so failing test'.error);
|
||||
ipc.disconnect(data.id);
|
||||
return;
|
||||
}
|
||||
|
||||
ipc.log(data.id.notice, 'started'.debug);
|
||||
|
||||
tests[data.id].started=true;
|
||||
clearTimeout(
|
||||
tests[data.id].delay
|
||||
);
|
||||
|
||||
tests[data.id].delay=setTimeout(
|
||||
(
|
||||
function(test){
|
||||
return function(){
|
||||
ipc.log(test.warn," failed to complete ".error);
|
||||
tests[test].fail.push('end.test');
|
||||
fails.push(test+' >> end.test');
|
||||
testCount--;
|
||||
tests[socket.id].delay=null;
|
||||
checkComplete();
|
||||
}
|
||||
}
|
||||
)(data.id),
|
||||
data.duration
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'end.test',
|
||||
function(data,socket){
|
||||
ipc.log(socket.id.notice, 'completed'.debug);
|
||||
clearTimeout(
|
||||
tests[socket.id].delay
|
||||
);
|
||||
|
||||
tests[socket.id].delay=null;
|
||||
|
||||
testCount--;
|
||||
checkComplete();
|
||||
}
|
||||
);
|
||||
|
||||
ipc.log('TestHarness started.'.debug, 'Loading Tests.'.notice);
|
||||
|
||||
ipc.server.define.listen['start.test']='This event should be called when a test is starting. It accepts an object with test details including the test id and duration';
|
||||
ipc.server.define.listen['end.test']='This event should be called when a test is completed.';
|
||||
ipc.server.define.listen['pass']='This event should be called when a test has passed, it accepts the name of the test portion which passed';
|
||||
ipc.server.define.listen['fail']='This event should be called when a test has failed, it accepts the name of the test portion which failed';
|
||||
|
||||
ipc.server.start();
|
||||
|
||||
fs.readdir(
|
||||
'tests',
|
||||
function(err,testFolders){
|
||||
if(err){
|
||||
ipc.log(err,'You must execute the testHarness from the testHarness directory'.error)
|
||||
return;
|
||||
}
|
||||
testCount=testFolders.length;
|
||||
|
||||
for(var i =0; i<testFolders.length; i++){
|
||||
tests[testFolders[i]]={
|
||||
started : false,
|
||||
pass : [],
|
||||
fail : [],
|
||||
delay : setTimeout(
|
||||
(
|
||||
function(test){
|
||||
return function(){
|
||||
ipc.log(test.warn," failed to start ".error);
|
||||
tests[test].fail.push('start.test');
|
||||
fails.push(test+' >> start.test');
|
||||
testCount--;
|
||||
checkComplete();
|
||||
}
|
||||
}
|
||||
)(testFolders[i]),
|
||||
1000
|
||||
)
|
||||
};
|
||||
|
||||
runTests(testFolders[i])
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function runTests(dir){
|
||||
fs.readdir(
|
||||
'tests/'+dir,
|
||||
function(err,testFiles){
|
||||
if(err){
|
||||
ipc.log(err,'You must execute the testHarness from the testHarness directory'.error)
|
||||
return;
|
||||
}
|
||||
for(var i =0; i<testFiles.length; i++){
|
||||
cmd.run(
|
||||
'node tests/'+dir+'/'+testFiles[i]
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function checkComplete(){
|
||||
if(testCount)
|
||||
return;
|
||||
|
||||
ipc.log('####################################\n\n RESULTS\n\n####################################\n\n'.rainbow,tests,'\n\n');
|
||||
ipc.log('####################################\n\n PASSES\n\n####################################\n\n'.good,passes.join('\n').good,'\n\n');
|
||||
ipc.log('####################################\n\n FAILS\n\n####################################\n\n'.warn,fails.join('\n').warn,'\n\n');
|
||||
ipc.log('####################################\n\n PASS/FAIL COUNT\n\n####################################\n\n'.data,(passes.length+' ').good,(fails.length+' ').warn,'\n\n');
|
||||
|
||||
fs.unlink('/tmp/app.testHarness');
|
||||
fs.unlink('/tmp/app.stopRetrieing-unix-socket-test');
|
||||
fs.unlink('/tmp/app.unix-socket-test');
|
||||
|
||||
if(!debug)
|
||||
process.exit(0);
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
var ipc = require('../../../node-ipc'),
|
||||
server=__dirname.split('/'),
|
||||
server=server[server.length-1]
|
||||
|
||||
ipc.config.id = server+'-client';
|
||||
ipc.config.stopRetrying=true;
|
||||
|
||||
//Wait to connect to ensure test server is started
|
||||
setTimeout(
|
||||
function(){
|
||||
ipc.connectTo(
|
||||
server,
|
||||
function(){
|
||||
ipc.of[server].on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.disconnect(server);
|
||||
|
||||
//wait long enough that the test will fail if disconnect does not happen
|
||||
setTimeout(
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
2000
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
400
|
||||
);
|
|
@ -1,48 +0,0 @@
|
|||
var ipc = require('../../../node-ipc'),
|
||||
expectedClient=ipc.config.id+'-client';
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1800
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
ipc.serve(
|
||||
function(){
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'socket.disconnected',
|
||||
function(socket,id){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'stopRetrying-unix-server'
|
||||
);
|
||||
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.start();
|
|
@ -1,39 +0,0 @@
|
|||
var ipc=require('../../../node-ipc'),
|
||||
server=__dirname.split('/'),
|
||||
server=server[server.length-1]
|
||||
|
||||
ipc.config.id = server+'-client';
|
||||
ipc.config.maxRetries=50;
|
||||
|
||||
ipc.connectToNet(
|
||||
server,
|
||||
function(){
|
||||
ipc.of[server].on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of[server].emit(
|
||||
'test-test',
|
||||
{
|
||||
id:ipc.config.id
|
||||
}
|
||||
);
|
||||
|
||||
//wait to ensure above event has opportunity to tranfer and register client properly
|
||||
setTimeout(
|
||||
function(){
|
||||
ipc.disconnect(server);
|
||||
},
|
||||
100
|
||||
);
|
||||
|
||||
//wait long enough that the test will fail if disconnect does not happen
|
||||
setTimeout(
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
2000
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
|
@ -1,92 +0,0 @@
|
|||
var ipc=require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
expectedClient=ipc.config.id+'-client';
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1200
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
ipc.serveNet(
|
||||
function(){
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'tcp-server-connection'
|
||||
);
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.on(
|
||||
'socket.disconnected',
|
||||
function(socket,id){
|
||||
var test='tcp-server-detected-correct-id-disconnection';
|
||||
if(id==ipc.config.id+'-client'){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
test
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+socket.id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.on(
|
||||
'test-test',
|
||||
function(data,socket){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'tcp-client-message'
|
||||
);
|
||||
|
||||
var test='tcp-client-registered with proper id'
|
||||
|
||||
if(socket.id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
test
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.define.listen.message='This event type listens for message strings as value of data key.';
|
||||
|
||||
ipc.server.start();
|
|
@ -1,42 +0,0 @@
|
|||
var ipc = require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1200
|
||||
}
|
||||
);
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'test-harness-pass-test'
|
||||
);
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
'test-harness-this-test-should-fail'
|
||||
);
|
||||
setTimeout(
|
||||
function(){
|
||||
//delay exit incase you want to test failure of start.test by modifying event name
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
ipc.of.testHarness.disconnect();
|
||||
},
|
||||
1000
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
var ipc=require('../../../node-ipc'),
|
||||
server=__dirname.split('/'),
|
||||
server=server[server.length-1]
|
||||
|
||||
ipc.config.id = server+'-client';
|
||||
|
||||
ipc.serveNet(
|
||||
8002, // tcp test uses default of 8000 udp server.js using 8001 increment to ensure no collision
|
||||
'udp4',
|
||||
function(){
|
||||
setTimeout( //wait to ensure UDP server.js running
|
||||
function(){
|
||||
ipc.server.emit(
|
||||
{
|
||||
address : 'localhost',
|
||||
port : 8001
|
||||
},
|
||||
'test-test',
|
||||
{
|
||||
id : ipc.config.id
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout( //wait to ensure test-test event sent
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
400
|
||||
);
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.start();
|
|
@ -1,101 +0,0 @@
|
|||
var ipc=require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
var expectedClient=ipc.config.id+'-client'
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1200
|
||||
}
|
||||
);
|
||||
|
||||
ipc.serveNet(
|
||||
8001, // tcp test uses default of 8000 increment to ensure no collision
|
||||
'udp4',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'udp-server-started'
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'test-test',
|
||||
function(data,socket){
|
||||
var event={
|
||||
id : 'udp-client-id',
|
||||
address : 'udp-client-address',
|
||||
port : 'udp-client-port'
|
||||
}
|
||||
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'udp-client-message'
|
||||
);
|
||||
|
||||
if(socket.id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
event.id
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
event.id+' : detected wrong id of '+socket.id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
|
||||
if(socket.address=='127.0.0.1'){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
event.address
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
event.port
|
||||
);
|
||||
}
|
||||
|
||||
if(socket.port==8002){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
event.port
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
event.port
|
||||
);
|
||||
}
|
||||
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
|
||||
setTimeout( //wait to ensure events sent to testHarness
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.start();
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
|
@ -1,39 +0,0 @@
|
|||
var ipc = require('../../../node-ipc'),
|
||||
server=__dirname.split('/'),
|
||||
server=server[server.length-1]
|
||||
|
||||
ipc.config.id = server+'-client';
|
||||
ipc.config.maxRetries=50;
|
||||
|
||||
ipc.connectTo(
|
||||
server,
|
||||
function(){
|
||||
ipc.of[server].on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of[server].emit(
|
||||
'test-test',
|
||||
{
|
||||
id:ipc.config.id
|
||||
}
|
||||
);
|
||||
|
||||
//wait to ensure above event has opportunity to tranfer and register client properly
|
||||
setTimeout(
|
||||
function(){
|
||||
ipc.disconnect(server);
|
||||
},
|
||||
100
|
||||
);
|
||||
|
||||
//wait long enough that the test will fail if disconnect does not happen
|
||||
setTimeout(
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
2000
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
|
@ -1,97 +0,0 @@
|
|||
var ipc = require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
var expectedClient=ipc.config.id+'-client';
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1400
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
ipc.serve(
|
||||
function(){
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'unix-server-connection'
|
||||
);
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.on(
|
||||
'socket.disconnected',
|
||||
function(socket,id){
|
||||
var test='unix-server-detected-correct-id-disconnection';
|
||||
if(id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
test
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
|
||||
setTimeout(
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
400
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.on(
|
||||
'test-test',
|
||||
function(data,socket){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'unix-client-message'
|
||||
);
|
||||
|
||||
var test='unix-client-registered with proper id'
|
||||
|
||||
if(socket.id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
test
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+socket.id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.define.listen['test-test']='Registers and tests ipc communication.';
|
||||
|
||||
ipc.server.start();
|
Loading…
Reference in a new issue