1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix UDP in test

This commit is contained in:
Dave Conway-Jones 2018-10-29 22:23:03 +00:00
parent d0bf4a5329
commit 8dba0dac9e
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4

View File

@ -38,8 +38,8 @@ describe('UDP out Node', function() {
function recvData(data, done) {
var sock = dgram.createSocket('udp4');
sock.on('message', function(msg, rinfo) {
msg.should.deepEqual(data);
sock.close(done);
msg.should.deepEqual(data);
});
sock.bind(port, '127.0.0.1');
port++;
@ -50,14 +50,14 @@ describe('UDP out Node', function() {
var dst_port = dest_in_msg ? undefined : port;
var flow = [{id:"n1", type:"udp out",
addr:dst_ip, port:dst_port, iface: "",
ipv:proto, outport: "random",
ipv:proto, outport: "",
base64:decode, multicast:false,
wires:[] }];
helper.load(udpNode, flow, function() {
var n1 = helper.getNode("n1");
var msg = {};
if (decode) {
msg.payload = Buffer("hello").toString('base64');
msg.payload = Buffer.from("hello").toString('base64');
}
else {
msg.payload = "hello";
@ -67,20 +67,22 @@ describe('UDP out Node', function() {
msg.port = port;
}
recvData(val1, done);
setTimeout(function() {
n1.receive(msg);
}, 200);
});
}
it('should send IPv4 data', function(done) {
checkSend('udp4', 'hello', Buffer('hello'), false, false, done);
checkSend('udp4', 'hello', Buffer.from('hello'), false, false, done);
});
it('should send IPv4 data (base64)', function(done) {
checkSend('udp4', 'hello', Buffer('hello'), true, false, done);
checkSend('udp4', 'hello', Buffer.from('hello'), true, false, done);
});
it('should send IPv4 data with dest from msg', function(done) {
checkSend('udp4', 'hello', Buffer('hello'), false, true, done);
checkSend('udp4', 'hello', Buffer.from('hello'), false, true, done);
});
});