base58: fix missing exceptions

This commit is contained in:
Daniel Cousens 2014-05-28 13:29:01 +10:00
parent c9ad359520
commit 47ae862ae9
2 changed files with 7 additions and 2 deletions

View file

@ -5,6 +5,7 @@
// Merged Buffer refactorings from base58-native by Stephen Pair
// Copyright (c) 2013 BitPay Inc
var assert = require('assert')
var BigInteger = require('bigi')
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
@ -46,7 +47,11 @@ function decode(string) {
for (var i = 0; i < string.length; i++) {
num = num.multiply(BASE)
num = num.add(ALPHABET_MAP[string.charAt(i)])
var figure = ALPHABET_MAP[string.charAt(i)]
assert.notEqual(figure, undefined, 'Non-base58 character')
num = num.add(figure)
}
// deal with leading zeros

View file

@ -18,7 +18,7 @@ describe('base58', function() {
it('throws on ' + f.description, function() {
assert.throws(function() {
base58.decode(f.string)
})
}, /Non-base58 character/)
})
})
})