@dashevo/dashcore-p2p
Version:
Interface to the dash P2P network for Dashcore
40 lines (33 loc) • 1.26 kB
JavaScript
;
/* jshint unused: false */
var should = require('chai').should();
var utils = require('../../lib/messages/utils');
var dashcore = require('@dashevo/dashcore-lib');
var BufferReader = dashcore.encoding.BufferReader;
describe('Message Utils', function() {
describe('checkFinished', function() {
it('should throw an error if buffer reader is not finished', function() {
/*jshint immed: false */
var buffer = new Buffer(Array(32));
var br = new BufferReader(buffer);
(function() {
utils.checkFinished(br);
}).should.throw('Data still available after parsing');
});
});
describe('sanitizeStartStop', function() {
it('should throw an error if starts is invalid length', function() {
/*jshint immed: false */
var stop = '000000000000000013413cf2536b491bf0988f52e90c476ffeb701c8bfdb1db9';
(function() {
utils.sanitizeStartStop({starts: ['0000'], stop: stop});
}).should.throw('Invalid hash');
});
it('should keep buffers as buffers', function() {
/*jshint immed: false */
var starts = [new Buffer(Array(32))];
var obj = utils.sanitizeStartStop({starts: starts});
obj.starts[0].should.deep.equal(starts[0]);
});
});
});