Added default relay value for Version message.

This commit is contained in:
Braydon Fuller 2015-03-27 11:40:19 -04:00
parent aa0b0e2bc8
commit e933dac898
2 changed files with 18 additions and 0 deletions

View File

@ -39,6 +39,7 @@ function VersionMessage(obj) {
this.timestamp = this.timestamp || new Date();
this.subversion = this.subversion || '/bitcore:' + packageInfo.version + '/';
this.startHeight = this.startHeight || 0;
this.relay = this.relay === false ? false : true;
}
inherits(VersionMessage, Message);

View File

@ -129,7 +129,24 @@ describe('Command Messages', function() {
var message = messages.MerkleBlock({merkleBlock: 'not a merkle block'});
}).should.throw('An instance of MerkleBlock');
});
});
describe('Version', function() {
it('should set the default relay property as true', function() {
var message = messages.Version();
should.exist(message.relay);
message.relay.should.equal(true);
});
it('should set the relay as false', function() {
var message = messages.Version({relay: false});
should.exist(message.relay);
message.relay.should.equal(false);
});
it('should set the relay as true', function() {
var message = messages.Version({relay: true});
should.exist(message.relay);
message.relay.should.equal(true);
});
});
});