Skip to content

Commit

Permalink
whitespace cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
einaros committed Nov 14, 2011
1 parent 2b28c46 commit 2d5dcc1
Show file tree
Hide file tree
Showing 10 changed files with 305 additions and 305 deletions.
2 changes: 1 addition & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function WSClient (port, sid, transport) {
this.transportName = transport || 'websocket';
WebSocket.call(
this
, 'ws://localhost:' + port + '/socket.io/'
, 'ws://localhost:' + port + '/socket.io/'
+ io.protocol + '/' + this.transportName + '/' + sid
);
};
Expand Down
8 changes: 4 additions & 4 deletions test/hybi-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ mask = function(buf, maskString) {
if (typeof buf == 'string') buf = new Buffer(buf);
var mask = getBufferFromHexString(maskString || '34 83 a8 68');
for (var i = 0; i < buf.length; ++i) {
buf[i] ^= mask[i % 4];
buf[i] ^= mask[i % 4];
}
return buf;
}

/**
* Returns a hex string representing the length of a message
*/
getHybiLengthAsHexString = function(len, masked) {

getHybiLengthAsHexString = function(len, masked) {
if (len < 126) {
var buf = new Buffer(1);
buf[0] = (masked ? 0x80 : 0) | len;
Expand Down Expand Up @@ -94,6 +94,6 @@ pack = function(length, number) {
* Left pads the string 's' to a total length of 'n' with char 'c'.
*/

padl = function(s, n, c) {
padl = function(s, n, c) {
return new Array(1 + n - s.length).join(c) + s;
}
2 changes: 1 addition & 1 deletion test/static.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module.exports = {

'test that the client is build with the enabled transports': function (done) {
var port = ++ports
, io = sio.listen(port)
, io = sio.listen(port)
, cl = client(port);

io.set('transports', ['websocket']);
Expand Down
2 changes: 1 addition & 1 deletion test/stores.memory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {

client.set('b', 'c', function (err) {
should.strictEqual(err, null);

client.set('c', 'd', function (err) {
should.strictEqual(err, null);

Expand Down
2 changes: 1 addition & 1 deletion test/stores.redis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports = {

client.set('b', 'c', function (err) {
should.strictEqual(err, null);

client.set('c', 'd', function (err) {
should.strictEqual(err, null);

Expand Down
2 changes: 1 addition & 1 deletion test/transports.flashsocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function FlashSocket (port, sid) {

WebSocket.call(
this
, 'ws://localhost:' + port + '/socket.io/'
, 'ws://localhost:' + port + '/socket.io/'
+ sio.protocol + '/flashsocket/' + sid
);
};
Expand Down
70 changes: 35 additions & 35 deletions test/transports.websocket.hybi07-12.parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Test dependencies.
*/

var assert = require('assert');
var assert = require('assert');
var Parser = require('../lib/transports/websocket/hybi-07-12.js').Parser;
require('./hybi-common');

Expand All @@ -14,38 +14,38 @@ module.exports = {
'can parse unmasked text message': function() {
var p = new Parser();
var packet = '81 05 48 65 6c 6c 6f';

var gotData = false;
p.on('data', function(data) {
gotData = true;
assert.equal('Hello', data);
});

p.add(getBufferFromHexString(packet));
assert.ok(gotData);
},
'can parse close message': function() {
var p = new Parser();
var packet = '88 00';

var gotClose = false;
p.on('close', function(data) {
gotClose = true;
});

p.add(getBufferFromHexString(packet));
assert.ok(gotClose);
},
'can parse masked text message': function() {
var p = new Parser();
var packet = '81 93 34 83 a8 68 01 b9 92 52 4f a1 c6 09 59 e6 8a 52 16 e6 cb 00 5b a1 d5';

var gotData = false;
p.on('data', function(data) {
gotData = true;
assert.equal('5:::{"name":"echo"}', data);
});

p.add(getBufferFromHexString(packet));
assert.ok(gotData);
},
Expand All @@ -54,13 +54,13 @@ module.exports = {
var message = 'A';
for (var i = 0; i < 300; ++i) message += (i % 5).toString();
var packet = '81 FE ' + pack(4, message.length) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(message, '34 83 a8 68'));

var gotData = false;
p.on('data', function(data) {
gotData = true;
assert.equal(message, data);
});

p.add(getBufferFromHexString(packet));
assert.ok(gotData);
},
Expand All @@ -75,7 +75,7 @@ module.exports = {
gotData = true;
assert.equal(message, data);
});

p.add(getBufferFromHexString(packet));
assert.ok(gotData);
},
Expand All @@ -87,13 +87,13 @@ module.exports = {
var msgpiece2 = message.substr(150);
var packet1 = '01 FE ' + pack(4, msgpiece1.length) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(msgpiece1, '34 83 a8 68'));
var packet2 = '80 FE ' + pack(4, msgpiece2.length) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(msgpiece2, '34 83 a8 68'));

var gotData = false;
p.on('data', function(data) {
gotData = true;
gotData = true;
assert.equal(message, data);
});

p.add(getBufferFromHexString(packet1));
p.add(getBufferFromHexString(packet2));
assert.ok(gotData);
Expand All @@ -102,42 +102,42 @@ module.exports = {
var p = new Parser();
var message = 'Hello';
var packet = '89 FE ' + pack(4, message.length) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(message, '34 83 a8 68'));

var gotPing = false;
p.on('ping', function(data) {
gotPing = true;
assert.equal(message, data);
});

p.add(getBufferFromHexString(packet));
assert.ok(gotPing);
},
'can parse a ping with no data': function() {
var p = new Parser();
var packet = '89 00';

var gotPing = false;
p.on('ping', function(data) {
gotPing = true;
});

p.add(getBufferFromHexString(packet));
assert.ok(gotPing);
},
'can parse a fragmented masked text message of 300 bytes with a ping in the middle': function() {
var p = new Parser();
var message = 'A';
for (var i = 0; i < 300; ++i) message += (i % 5).toString();

var msgpiece1 = message.substr(0, 150);
var packet1 = '01 FE ' + pack(4, msgpiece1.length) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(msgpiece1, '34 83 a8 68'));

var pingMessage = 'Hello';
var pingPacket = '89 FE ' + pack(4, pingMessage.length) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(pingMessage, '34 83 a8 68'));

var msgpiece2 = message.substr(150);
var packet2 = '80 FE ' + pack(4, msgpiece2.length) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(msgpiece2, '34 83 a8 68'));

var gotData = false;
p.on('data', function(data) {
gotData = true;
Expand All @@ -148,7 +148,7 @@ module.exports = {
gotPing = true;
assert.equal(pingMessage, data);
});

p.add(getBufferFromHexString(packet1));
p.add(getBufferFromHexString(pingPacket));
p.add(getBufferFromHexString(packet2));
Expand All @@ -159,16 +159,16 @@ module.exports = {
var p = new Parser();
var message = 'A';
for (var i = 0; i < 300; ++i) message += (i % 5).toString();

var msgpiece1 = message.substr(0, 150);
var packet1 = '01 FE ' + pack(4, msgpiece1.length) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(msgpiece1, '34 83 a8 68'));

var pingMessage = 'Hello';
var pingPacket = '89 FE ' + pack(4, pingMessage.length) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(pingMessage, '34 83 a8 68'));

var msgpiece2 = message.substr(150);
var packet2 = '80 FE ' + pack(4, msgpiece2.length) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(msgpiece2, '34 83 a8 68'));

var gotData = false;
p.on('data', function(data) {
gotData = true;
Expand All @@ -179,7 +179,7 @@ module.exports = {
gotPing = true;
assert.equal(pingMessage, data);
});

var buffers = [];
buffers = buffers.concat(splitBuffer(getBufferFromHexString(packet1)));
buffers = buffers.concat(splitBuffer(getBufferFromHexString(pingPacket)));
Expand All @@ -195,15 +195,15 @@ module.exports = {
var length = 100;
var message = new Buffer(length);
for (var i = 0; i < length; ++i) message[i] = i % 256;
var originalMessage = getHexStringFromBuffer(message);
var originalMessage = getHexStringFromBuffer(message);
var packet = '82 ' + getHybiLengthAsHexString(length, true) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(message, '34 83 a8 68'));

var gotData = false;
p.on('binary', function(data) {
gotData = true;
assert.equal(originalMessage, getHexStringFromBuffer(data));
});

p.add(getBufferFromHexString(packet));
assert.ok(gotData);
},
Expand All @@ -212,15 +212,15 @@ module.exports = {
var length = 256;
var message = new Buffer(length);
for (var i = 0; i < length; ++i) message[i] = i % 256;
var originalMessage = getHexStringFromBuffer(message);
var originalMessage = getHexStringFromBuffer(message);
var packet = '82 ' + getHybiLengthAsHexString(length, true) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(message, '34 83 a8 68'));

var gotData = false;
p.on('binary', function(data) {
gotData = true;
assert.equal(originalMessage, getHexStringFromBuffer(data));
});

p.add(getBufferFromHexString(packet));
assert.ok(gotData);
},
Expand All @@ -229,15 +229,15 @@ module.exports = {
var length = 200 * 1024;
var message = new Buffer(length);
for (var i = 0; i < length; ++i) message[i] = i % 256;
var originalMessage = getHexStringFromBuffer(message);
var originalMessage = getHexStringFromBuffer(message);
var packet = '82 ' + getHybiLengthAsHexString(length, true) + ' 34 83 a8 68 ' + getHexStringFromBuffer(mask(message, '34 83 a8 68'));

var gotData = false;
p.on('binary', function(data) {
gotData = true;
assert.equal(originalMessage, getHexStringFromBuffer(data));
});

p.add(getBufferFromHexString(packet));
assert.ok(gotData);
},
Expand All @@ -246,15 +246,15 @@ module.exports = {
var length = 200 * 1024;
var message = new Buffer(length);
for (var i = 0; i < length; ++i) message[i] = i % 256;
var originalMessage = getHexStringFromBuffer(message);
var originalMessage = getHexStringFromBuffer(message);
var packet = '82 ' + getHybiLengthAsHexString(length, false) + ' ' + getHexStringFromBuffer(message);

var gotData = false;
p.on('binary', function(data) {
gotData = true;
assert.equal(originalMessage, getHexStringFromBuffer(data));
});

p.add(getBufferFromHexString(packet));
assert.ok(gotData);
},
Expand Down
Loading

0 comments on commit 2d5dcc1

Please sign in to comment.