test/parser: add version test for height and relay / fix typo.

This commit is contained in:
Christopher Jeffrey 2014-05-24 02:09:49 -05:00
parent 24d9b2b2d8
commit 9dc0063ea9
3 changed files with 9 additions and 3 deletions

View File

@ -101,7 +101,6 @@ Peer.prototype._init = function init() {
height: this.options.startHeight != null
? this.options.startHeight
: 0,
//: this.pool.chain.index.heights[this.pool.chain.index.heights.length-1],
relay: this.options.relay
}));

View File

@ -123,7 +123,7 @@ Parser.prototype.parseVersion = function parseVersion(p) {
var nonce = { lo: readU32(p, 72), hi: readU32(p, 76) };
// Start height
var weight = readU32(p, 81);
var height = readU32(p, 81);
// Relay
var relay = p.length >= 86 ? p[85] === 1 : true;
@ -133,7 +133,7 @@ Parser.prototype.parseVersion = function parseVersion(p) {
services: services,
ts: ts,
nonce: nonce,
weight: weight,
height: height,
relay: relay
};
};

View File

@ -25,6 +25,13 @@ describe('Protocol', function() {
packetTest('version', {}, function(payload) {
assert.equal(payload.v, 70002);
assert.equal(payload.relay, false);
assert.equal(payload.height, 0);
});
packetTest('version', { relay: true, height: 10 }, function(payload) {
assert.equal(payload.v, 70002);
assert.equal(payload.relay, true);
assert.equal(payload.height, 10);
});
packetTest('verack', {}, function(payload) {