added test for message utils

This commit is contained in:
Braydon Fuller 2015-03-13 21:59:32 -04:00
parent a15f11cc32
commit 6db209b9b6

33
test/messages/util.js Normal file
View File

@ -0,0 +1,33 @@
'use strict';
/* jshint unused: false */
var should = require('chai').should();
var utils = require('../../lib/messages/utils');
var bitcore = require('bitcore');
var BufferReader = bitcore.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');
});
});
});