Add tests
This commit is contained in:
parent
2d4b26a6a1
commit
228e7e214a
|
@ -48,6 +48,9 @@ var parseMessage = function(network, dataBuffer) {
|
|||
return;
|
||||
}
|
||||
|
||||
console.log(command, 'FULL MESSAGE', dataBuffer.slice(0, messageLength).toString('hex'));
|
||||
console.log(command, 'PAYLOAD MESSAGE', payload.toString('hex'));
|
||||
|
||||
dataBuffer.skip(messageLength);
|
||||
return Message.buildMessage(command, payload);
|
||||
};
|
||||
|
@ -165,7 +168,7 @@ Version.prototype.fromBuffer = function(payload) {
|
|||
this.addr_me = parser.read(26);
|
||||
this.addr_you = parser.read(26);
|
||||
this.nonce = parser.read(8);
|
||||
this.subversion = parser.readVarintBuf();
|
||||
this.subversion = parser.readVarintBuf().toString();
|
||||
this.start_height = parser.readUInt32LE();
|
||||
|
||||
return this;
|
||||
|
@ -217,8 +220,8 @@ Inventory.prototype.getPayload = function() {
|
|||
|
||||
put.varint(this.inventory.length);
|
||||
this.inventory.forEach(function(value) {
|
||||
value instanceof Block ? put.word32le(2) : put.word32le(1);
|
||||
put.put(value.getHash());
|
||||
put.word32le(value.type);
|
||||
put.put(value.hash);
|
||||
});
|
||||
|
||||
return put.buffer();
|
||||
|
@ -272,7 +275,7 @@ function Pong(nonce) {
|
|||
}
|
||||
|
||||
util.inherits(Pong, Ping);
|
||||
module.exports.Pong = Pong;
|
||||
module.exports.Pong = Message.COMMANDS['pong'] = Pong;
|
||||
|
||||
/**
|
||||
* Addr Message
|
||||
|
@ -358,8 +361,10 @@ module.exports.Reject = Message.COMMANDS['reject'] = Reject;
|
|||
* Alert Message
|
||||
*
|
||||
*/
|
||||
function Alert() {
|
||||
function Alert(payload, signature) {
|
||||
this.command = 'alert';
|
||||
this.payload = payload || new Buffer(32);
|
||||
this.signature = signature || new Buffer(32);
|
||||
}
|
||||
util.inherits(Alert, Message);
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue