Fix error.decode API
This commit is contained in:
parent
3f0b881a58
commit
f619a066c6
|
@ -386,9 +386,12 @@ var error = exports.error = {
|
|||
var vectorLength = decodedVectorLength.value;
|
||||
var rest = decodedVectorLength.rest;
|
||||
assert(rest.length >= vectorLength, "Buffer is too small");
|
||||
var vector = new Buffer(vectorLength);
|
||||
var vector = null;
|
||||
if (vectorLength) {
|
||||
vector = new Buffer(vectorLength);
|
||||
rest.copy(vector);
|
||||
rest = rest.slice(vectorLength);
|
||||
}
|
||||
|
||||
var decodedErrorText = structs.var_str.decode(rest);
|
||||
var length = (
|
||||
|
|
|
@ -576,7 +576,7 @@ describe("Message types", function() {
|
|||
var res = error.decode(encoded);
|
||||
expect(res.fatal).to.equal(0);
|
||||
expect(res.banTime).to.equal(0);
|
||||
expect(res.vector).to.have.length(0);
|
||||
expect(res.vector).to.not.exist;
|
||||
expect(res.errorText).to.equal("test");
|
||||
expect(res.length).to.equal(8);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user