add test that exposes bug
This commit is contained in:
parent
25eaae2b45
commit
722eddb894
|
@ -118,6 +118,7 @@ Block._fromBufferReader = function _fromBufferReader(br) {
|
|||
* @returns {Block} - An instance of block
|
||||
*/
|
||||
Block.fromBufferReader = function fromBufferReader(br) {
|
||||
$.checkArgument(br, 'br is required');
|
||||
var info = Block._fromBufferReader(br);
|
||||
return new Block(info);
|
||||
};
|
||||
|
@ -127,7 +128,7 @@ Block.fromBufferReader = function fromBufferReader(br) {
|
|||
* @returns {Block} - An instance of block
|
||||
*/
|
||||
Block.fromBuffer = function fromBuffer(buf) {
|
||||
return Block.fromBufferReader(BufferReader(buf));
|
||||
return Block.fromBufferReader(new BufferReader(buf));
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,9 +13,15 @@ var BufferReader = function BufferReader(buf) {
|
|||
this.set({
|
||||
buf: buf
|
||||
});
|
||||
} else if (buf) {
|
||||
} else if (_.isString(buf)) {
|
||||
this.set({
|
||||
buf: new Buffer(buf, 'hex'),
|
||||
});
|
||||
} else if (_.isObject(buf)) {
|
||||
var obj = buf;
|
||||
this.set(obj);
|
||||
} else {
|
||||
throw new TypeError('Unrecognized argument for BufferReader');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue