<commit_before>
var msgpack_rpc = require('../lib/msgpack-rpc');


module.exports = {
    'simple server handler' : function(test) {
	var addition_called = false;
	var response_received = false;
	var notification_recieved = false;

	var events = 2;

	var trigger = function () {
	    events--;
	    if (events == 0) {
		test.ok (addition_called);
		test.ok (notification_received);
		test.ok (response_received);
		test.finish ();
		server.close();
	    }
	}


	var handler = {
	    'add' : function(a, b, response) { 
		addition_called = true;
		response.result(a + b);
	    },
	    'temperature' : function(temp, response) {
		test.equal(102.1, temp);
		test.equal(undefined, response);
		notification_received = true;
		trigger ();
		
	    }
	};
	
	var server = msgpack_rpc.createServer();
	server.setHandler(handler);
	
	server.listen(8030, function() {
	    var client = msgpack_rpc.createClient(null, 8030, function() {
		client.invoke('add', 5, 7, function(err, response) {
		    response_received = true;
		    test.equal(5 + 7, response);
		    client.stream.end();
		    trigger ();
		});
		
		client.notify('temperature', 102.1);
	    });
	    
	});
	
    },
}<commit_msg>more testing<commit_after>
var msgpack_rpc = require('../lib/msgpack-rpc');


module.exports = {
    'simple server handler' : function(test) {
	var addition_called = false;
	var responses_received = 0;
	var notification_recieved = false;

	var events = 3;

	var trigger = function () {
	    events--;
	    if (events == 0) {
		test.ok (addition_called);
		test.ok (notification_received);
		test.equal (responses_received, 2);
		test.finish ();
		client.stream.end();
		server.close();
	    }
	}


	var handler = {
	    'add' : function(a, b, response) { 
		addition_called = true;
		response.result(a + b);
	    },
	    'temperature' : function(temp, response) {
		test.equal(102.1, temp);
		test.equal(undefined, response);
		notification_received = true;
		trigger ();
		
	    },
	    'smush' : function (d, response) {
		var tot = 0;
		for (var k in d) {
		    tot += parseInt (k) + d[k];
		}
		response.result (tot);
	    }
	};
	
	var client = null;
	var server = msgpack_rpc.createServer();
	server.setHandler(handler);
	
	server.listen(8030, function() {
	    client = msgpack_rpc.createClient(null, 8030, function() {
		client.invoke('add', 5, 7, function(err, response) {
		    responses_received ++;
		    test.equal(5 + 7, response);
		    trigger ();
		});
		
		client.notify('temperature', 102.1);
		
		client.invoke ('smush', { 1 : 2, 3 : 4, 5 : 6 }, 
			       function (err, response) {
				   responses_received++;
				   test.equal (response, 21);
				   trigger ();
			       });
	    });
	    
	});
	
    },
}
{'fraction_non_alphanumeric': 0.1555473645410984, 'fraction_numerical': 0.020272760781422778, 'mean_word_length': 2.8225352112676054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3083897', 'n_tokens_mistral': 1070, 'n_tokens_neox': 884, 'n_words': 199}