From e354dea2831e6dce81019de0bfa1eb5325aeddbb Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 16 May 2016 17:05:36 -0700 Subject: [PATCH] varint assert. --- lib/bcoin/writer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/bcoin/writer.js b/lib/bcoin/writer.js index 55260f69..bec886bd 100644 --- a/lib/bcoin/writer.js +++ b/lib/bcoin/writer.js @@ -336,7 +336,11 @@ BufferWriter.prototype.writeDoubleBE = function writeDoubleBE(value) { */ BufferWriter.prototype.writeVarint = function writeVarint(value) { - assert(value >= 0); + if (typeof value === 'number') + assert(value >= 0); + else + assert(!value.isNeg()); + this.written += utils.sizeVarint(value); this.data.push([VARINT, value]); };