Fix bug in Request.getPayload()
Apparently, node v0.12 buffer.writeUInt8 is more lenient than v0.10
This commit is contained in:
parent
6a88aaae9b
commit
0ea205d0eb
@ -57,7 +57,7 @@ RejectMessage.prototype.getPayload = function() {
|
||||
var bw = new BufferWriter();
|
||||
bw.writeVarintNum(this.message.length);
|
||||
bw.write(new Buffer(this.message, 'utf-8'));
|
||||
bw.writeUInt8(this.cccode);
|
||||
bw.writeUInt8(this.ccode);
|
||||
bw.writeVarintNum(this.reason.length);
|
||||
bw.write(new Buffer(this.reason, 'utf-8'));
|
||||
bw.write(this.data);
|
||||
|
||||
@ -284,6 +284,26 @@ describe('Command Messages', function() {
|
||||
expect(message.reason).to.be.undefined;
|
||||
expect(message.data).to.be.undefined;
|
||||
});
|
||||
it('should write payload correctly', function() {
|
||||
var message = messages.Reject({
|
||||
message: 'tx',
|
||||
ccode: 0x01,
|
||||
reason: 'transaction is malformed',
|
||||
data: new Buffer('12345678901234567890123456789012', 'hex')
|
||||
});
|
||||
var payload = message.getPayload();
|
||||
message = messages.Reject();
|
||||
message.setPayload(payload);
|
||||
message.message.should.equal('tx');
|
||||
message.ccode.should.equal(0x01);
|
||||
message.reason.should.equal('transaction is malformed');
|
||||
message.data.toString('hex').should.equal('12345678901234567890123456789012');
|
||||
//var message = messages.Reject();
|
||||
//expect(message.message).to.be.undefined;
|
||||
//expect(message.ccode).to.be.undefined;
|
||||
//expect(message.reason).to.be.undefined;
|
||||
//expect(message.data).to.be.undefined;
|
||||
});
|
||||
});
|
||||
|
||||
describe('Version', function() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user