Skip to content

Commit

Permalink
Merge 01680ad into 5d0820f
Browse files Browse the repository at this point in the history
  • Loading branch information
schinzelh committed Aug 5, 2016
2 parents 5d0820f + 01680ad commit 5d2f660
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
repo_token: OMJRNZCl018Yjy44nlG1hF6maKEyXcwPx
repo_token: 1B2Xx5vL5eVxFovRlME2jlOLkMBaK5Bc6
4 changes: 2 additions & 2 deletions lib/messages/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function builder(options) {
getheaders: 'GetHeaders',
mempool: 'MemPool',
getaddr: 'GetAddr',
dsq: 'dsq',
ssc: 'ssc'
dsq: 'DSQueue',
ssc: 'SyncStatusCount'
},
commands: {}
};
Expand Down
13 changes: 7 additions & 6 deletions lib/messages/commands/dsq.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ var BufferReader = bitcore.encoding.BufferReader;
* @extends Message
* @constructor
*/
function dsq(arg, options) {

function DsqueueMessage(arg, options) {
Message.call(this, options);
this.command = 'dsq';
}
inherits(dsq, Message);
inherits(DsqueueMessage, Message);

dsq.prototype.setPayload = function(payload) {
DsqueueMessage.prototype.setPayload = function(payload) {
var parser = new BufferReader(payload);
this.nonce = parser.read(8);

};

dsq.prototype.getPayload = function() {
DsqueueMessage.prototype.getPayload = function() {
return this.nonce;
};

module.exports = dsq;
module.exports = DsqueueMessage;
13 changes: 7 additions & 6 deletions lib/messages/commands/ssc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ var BufferReader = bitcore.encoding.BufferReader;
* @extends Message
* @constructor
*/
function ssc(arg, options) {

function SyncstatuscountMessage(arg, options) {
Message.call(this, options);
this.command = 'ssc';
}
inherits(ssc, Message);
inherits(SyncstatuscountMessage, Message);

ssc.prototype.setPayload = function(payload) {
SyncstatuscountMessage.prototype.setPayload = function(payload) {
var parser = new BufferReader(payload);
this.nonce = parser.read(8);

};

ssc.prototype.getPayload = function() {
SyncstatuscountMessage.prototype.getPayload = function() {
return this.nonce;
};

module.exports = ssc;
module.exports = SyncstatuscountMessage;
2 changes: 1 addition & 1 deletion test/bloomfilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('BloomFilter', function() {

it('serialize filter with public keys added', function() {

var privateKey = bitcore.PrivateKey.fromWIF('5Kg1gnAjaLfKiwhhPpGS3QfRg2m6awQvaj98JCZBZQ5SuS2F15C');
var privateKey = bitcore.PrivateKey.fromWIF('7sQb6QHALg4XyHsJHsSNXnEHGhZfzTTUPJXJqaqK7CavQkiL9Ms');
var publicKey = privateKey.toPublicKey();

var filter = BloomFilter.create(2, 0.001, 0, BloomFilter.BLOOM_UPDATE_ALL);
Expand Down
Binary file modified test/data/connection.log
Binary file not shown.
52 changes: 29 additions & 23 deletions test/data/messages.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions test/messages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ describe('Messages', function() {
outputBuffer.toString('hex').should.equal(payloadBuffer.toString('hex'));
outputBuffer.should.deep.equal(payloadBuffer);
var expectedBuffer = new Buffer(commandData[command].message, 'hex');
console.log('A: ' + expectedBuffer.toString('hex'));
console.log('B: ' + message.toBuffer().toString('hex'));
message.toBuffer().should.deep.equal(expectedBuffer);
done();
});
Expand Down Expand Up @@ -163,7 +165,7 @@ describe('Messages', function() {

describe('#parseBuffer', function() {
it('fails with invalid command', function() {
var invalidCommand = 'f9beb4d96d616c6963696f757300000025000000bd5e830c' +
var invalidCommand = 'bf0c6bbd6d616c6963696f757300000025000000bd5e830c' +
'0102000000ec3995c1bf7269ff728818a65e53af00cbbee6b6eca8ac9ce7bc79d87' +
'7041ed8';
var fails = function() {
Expand All @@ -178,10 +180,10 @@ describe('Messages', function() {
'1000100000000000000ba6288540000000001000000000000000000000000000000' +
'0000ffffba8886dceab0010000000000000000000000000000000000ffff0509552' +
'2208de7e1c1ef80a1cea70f2f5361746f7368693a302e392e312fa317050001';
var malformed2 = 'f9beb4d967657464617461000000000089000000d88134740102' +
var malformed2 = 'bf0c6bbd67657464617461000000000089000000d88134740102' +
'0000006308e4a380c949dbad182747b0f7b6a89e874328ca41f37287f74a81b8f84' +
'86d';
var malformed3 = 'f9beb4d967657464617461000000000025000000616263640102' +
var malformed3 = 'bf0c6bbd67657464617461000000000025000000616263640102' +
'00000069ebcbc34a4f9890da9aea0f773beba883a9afb1ab9ad7647dd4a1cd346c3' +
'728';
[malformed1, malformed2, malformed3].forEach(function(malformed) {
Expand Down
2 changes: 1 addition & 1 deletion test/messages/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Message', function() {
return new Buffer(0);
};
var buffer = message.toBuffer();
var expectedBuffer = new Buffer('f9beb4d9636f6d6d616e640000000000000000005df6e0e2', 'hex');
var expectedBuffer = new Buffer('bf0c6bbd636f6d6d616e640000000000000000005df6e0e2', 'hex');
buffer.should.deep.equal(expectedBuffer);
});
});
Expand Down

0 comments on commit 5d2f660

Please sign in to comment.