From 8f9f971e21f7f428d1928a918cc8ceb8c7fbcd64 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 30 Nov 2017 14:16:13 +1100 Subject: [PATCH] add more invalid hex tests --- test/constructor-test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/constructor-test.js b/test/constructor-test.js index 9f27203..385634b 100644 --- a/test/constructor-test.js +++ b/test/constructor-test.js @@ -108,6 +108,22 @@ describe('BN.js/Constructor', function () { res; }, /Invalid character/); }); + + it('should not accept non-hex characters', function () { + [ + '0000000z', + '000000gg', + '0000gg00', + 'ffffggff', + 'ffffggff', + 'hexadecimal' + ].forEach(function (str) { + assert.throws(function () { + var res = new BN(str, 16); + res; + }, /Invalid character in /); + }); + }) }); describe('with Array input', function () {