1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

In nested MULTIBULK buffers, correctly recurse on an incomplete read buffer.

Signed-off-by: DTrejo <david.daniel.trejo@gmail.com>
This commit is contained in:
Bryce Baril
2013-02-23 21:15:11 -08:00
committed by DTrejo
parent 9127f34393
commit 92ed0befc1
2 changed files with 34 additions and 5 deletions

29
test.js
View File

@@ -291,6 +291,35 @@ tests.MULTI_6 = function () {
});
};
tests.MULTI_7 = function () {
var name = "MULTI_7";
if (bclient.reply_parser.name != "javascript") {
console.log("Skipping wire-protocol test for 3rd-party parser");
return next(name);
}
var p = require("./lib/parser/javascript");
var parser = new p.Parser(false);
var reply_count = 0;
function check_reply(reply) {
assert.deepEqual(reply, [['a']], "Expecting multi-bulk reply of [['a']]");
reply_count++;
assert.notEqual(reply_count, 4, "Should only parse 3 replies");
}
parser.on("reply", check_reply);
parser.execute(new Buffer('*1\r\n*1\r\n$1\r\na\r\n'));
parser.execute(new Buffer('*1\r\n*1\r'));
parser.execute(new Buffer('\n$1\r\na\r\n'));
parser.execute(new Buffer('*1\r\n*1\r\n'));
parser.execute(new Buffer('$1\r\na\r\n'));
next(name);
};
tests.FWD_ERRORS_1 = function () {
var name = "FWD_ERRORS_1";