Added preconditions to filteradd message.
This commit is contained in:
parent
28b05e3cc1
commit
81047d73bd
@ -8,6 +8,7 @@ var BufferUtil = bitcore.util.buffer;
|
|||||||
var BufferWriter = bitcore.encoding.BufferWriter;
|
var BufferWriter = bitcore.encoding.BufferWriter;
|
||||||
var BufferReader = bitcore.encoding.BufferReader;
|
var BufferReader = bitcore.encoding.BufferReader;
|
||||||
var $ = bitcore.util.preconditions;
|
var $ = bitcore.util.preconditions;
|
||||||
|
var _ = bitcore.deps._;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request peer to add data to a bloom filter already set by 'filterload'
|
* Request peer to add data to a bloom filter already set by 'filterload'
|
||||||
@ -21,6 +22,10 @@ function FilteraddMessage(arg, options) {
|
|||||||
Message.call(this, arg, options);
|
Message.call(this, arg, options);
|
||||||
this.magicNumber = options.magicNumber;
|
this.magicNumber = options.magicNumber;
|
||||||
this.command = 'filteradd';
|
this.command = 'filteradd';
|
||||||
|
$.checkArgument(
|
||||||
|
_.isUndefined(arg) || BufferUtil.isBuffer(arg),
|
||||||
|
'First argument is expected to be a Buffer or undefined'
|
||||||
|
);
|
||||||
this.data = arg || BufferUtil.EMPTY_BUFFER;
|
this.data = arg || BufferUtil.EMPTY_BUFFER;
|
||||||
}
|
}
|
||||||
inherits(FilteraddMessage, Message);
|
inherits(FilteraddMessage, Message);
|
||||||
|
|||||||
@ -102,6 +102,16 @@ describe('Command Messages', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('FilterAdd', function() {
|
||||||
|
|
||||||
|
it('should error if arg is not a buffer', function() {
|
||||||
|
(function() {
|
||||||
|
var message = messages.FilterAdd('not a buffer');
|
||||||
|
}).should.throw('First argument is expected to be a Buffer or undefined');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe('FilterLoad', function() {
|
describe('FilterLoad', function() {
|
||||||
|
|
||||||
it('should return a null payload', function() {
|
it('should return a null payload', function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user