address/base58check: fix missing exceptions/tests

All the `invalid2` tests have been removed as they were not invalid
base58check.  They were actually valid in some cases.
They will be re-integrated in more specific bitcoin core tests in
relation to Address/ECKey respectively.
This commit is contained in:
Daniel Cousens 2014-05-28 13:34:10 +10:00
parent 47ae862ae9
commit 2fc69b0834
5 changed files with 28 additions and 88 deletions

View file

@ -3,13 +3,12 @@ var base58check = require('../src/base58check')
var fixtures = require('./fixtures/base58check.json')
function b2h(b) { return new Buffer(b).toString('hex') }
function h2b(h) { return new Buffer(h, 'hex') }
describe('base58check', function() {
describe('decode', function() {
it('can decode Bitcoin core test data', function() {
fixtures.valid.forEach(function(f) {
fixtures.valid.forEach(function(f) {
it('can decode ' + f.string, function() {
var actual = base58check.decode(f.string)
var expected = {
version: f.decode.version,
@ -25,22 +24,14 @@ describe('base58check', function() {
it('throws on ' + f.description, function() {
assert.throws(function() {
base58check.decode(f.string)
})
})
})
it('throws on [invalid] Bitcoin core test data', function() {
fixtures.invalid2.forEach(function(f) {
assert.throws(function() {
base58check.decode(f.string)
})
}, /Invalid checksum/)
})
})
})
describe('encode', function() {
it('can encode Bitcoin core test data', function() {
fixtures.valid.forEach(function(f) {
fixtures.valid.forEach(function(f) {
it('can encode ' + f.string, function() {
var actual = base58check.encode(h2b(f.decode.payload), f.decode.version)
var expected = f.string