diff --git a/integration/bitcoind.js b/integration/bitcoind.js index 4659249..5ba5634 100644 --- a/integration/bitcoind.js +++ b/integration/bitcoind.js @@ -39,7 +39,7 @@ var txHash = { describe('Integration with ' + network.name + ' bitcoind', function() { this.timeout(15000); - it('handshakes', function(cb) { + it.only('handshakes', function(cb) { var peer = new Peer('localhost', network); peer.once('version', function(m) { m.version.should.be.above(70000); @@ -47,6 +47,7 @@ describe('Integration with ' + network.name + ' bitcoind', function() { Math.abs(new Date() - m.timestamp).should.be.below(10000); // less than 10 seconds of time difference m.nonce.length.should.equal(8); m.start_height.should.be.above(300000); + console.log(peer.host); cb(); }); peer.once('verack', function(m) { diff --git a/lib/messages.js b/lib/messages.js index 1bf88e9..68ea8a3 100644 --- a/lib/messages.js +++ b/lib/messages.js @@ -254,6 +254,10 @@ Version.prototype.fromBuffer = function(payload) { }; Version.writeAddr = function(addr, parser) { + if (_.isUndefined(addr)) { + parser.pad(26); + return; + } parser.word64le(addr.services); parser.put(addr.ip); parser.word16be(addr.port); diff --git a/test/peer.js b/test/peer.js index bd11e14..fdc788a 100644 --- a/test/peer.js +++ b/test/peer.js @@ -12,15 +12,15 @@ var sinon = require('sinon'); var fs = require('fs'); var bitcore = require('bitcore'); -var P2P = require('../'); -var Peer = P2P.Peer; +var p2p = require('../'); +var Peer = p2p.Peer; var Networks = bitcore.Networks; describe('Peer', function() { describe('Integration test', function() { it('parses this stream of data from a connection', function(callback) { - var peer = new P2P.Peer(''); + var peer = new p2p.Peer(''); var stub = sinon.stub(); var dataCallback; var connectCallback;